1 /********************************************************************
3 stdpas.c - initializes the parser/semantic checker with a
4 standard pascal types, constants etc.
6 Niksa Orlic, 2004-04-29
8 ********************************************************************/
10 #include "../util/strings.h"
11 #include "../util/error.h"
12 //#include "../util/message.h"
13 #include "../structures/type_list.h"
14 #include "../structures/string_list.h"
15 #include "../structures/type.h"
16 #include "../structures/identifier.h"
17 #include "../structures/name_table.h"
18 #include "../classgen/bytecode.h"
19 #include "../structures/block.h"
20 //#include "../main/static_entry.h"
22 #include "../classgen/constant_pool.h"
30 #pragma warning (disable:4305)
31 #pragma warning (disable:4761)
33 int procedure_linenum
;
34 extern char *source_file_name
;
35 int usesForms
= 0; /* set to 1 if FS.class should be added into the generated JAR file */
36 int usesSupport
= 0; /* set to 1 if S.class should be added into the generated JAR file */
37 int usesFloat
= 0; /* set to 1 if Float.class should be added into the generated JAR file */
38 int usesRecordStore
= 0; /* set to 1 if RS.class should be added into the generated JAR file */
39 int usesHttp
= 0; /* if H.class should be added */
40 int usesPlayer
= 0; /* if P.class should be used */
41 int usesSMS
= 0; /* if uses SM.class */
44 //int usesRegisteredFeature = 0;
46 extern int canvasType
;
50 Creates and initializes the root block
51 with standard pascal types, constants etc.
53 block
* initialize_root_block()
57 root_block
= block_create(NULL
, NULL
);
59 add_std_types(root_block
);
60 add_std_constants(root_block
);
61 add_std_functions(root_block
);
68 Adds the standard pascal types into the block.
70 void add_std_types(block
*item
)
72 add_std_type(item
, integer_type
, "integer");
73 add_std_type(item
, real_type
, "real");
74 add_std_type(item
, boolean_type
, "boolean");
75 add_std_type(item
, char_type
, "char");
76 add_std_type(item
, string_type
, "string");
77 add_std_type(item
, image_type
, "image");
78 add_std_type(item
, command_type
, "command");
79 add_std_type(item
, stream_type
, "resource");
80 add_std_type(item
, record_store_type
, "recordstore");
81 add_std_type(item
, http_type
, "http");
85 Adds some constants into the block
87 void add_std_constants(block
*item
)
89 add_real_constant(item
, (float) 3.1415926535897932384626433832795, "pi");
92 add_integer_constant(item
, 0, "KE_NONE");
93 add_integer_constant(item
, 0, "GA_NONE");
95 add_integer_constant(item
, 1, "GA_UP");
96 add_integer_constant(item
, 6, "GA_DOWN");
97 add_integer_constant(item
, 2, "GA_LEFT");
98 add_integer_constant(item
, 5, "GA_RIGHT");
99 add_integer_constant(item
, 8, "GA_FIRE");
100 add_integer_constant(item
, 9, "GA_GAMEA");
101 add_integer_constant(item
, 10, "GA_GAMEB");
102 add_integer_constant(item
, 11, "GA_GAMEC");
103 add_integer_constant(item
, 12, "GA_GAMED");
105 add_integer_constant(item
, 48, "KE_KEY0");
106 add_integer_constant(item
, 49, "KE_KEY1");
107 add_integer_constant(item
, 50, "KE_KEY2");
108 add_integer_constant(item
, 51, "KE_KEY3");
109 add_integer_constant(item
, 52, "KE_KEY4");
110 add_integer_constant(item
, 53, "KE_KEY5");
111 add_integer_constant(item
, 54, "KE_KEY6");
112 add_integer_constant(item
, 55, "KE_KEY7");
113 add_integer_constant(item
, 56, "KE_KEY8");
114 add_integer_constant(item
, 57, "KE_KEY9");
115 add_integer_constant(item
, 42, "KE_STAR");
116 add_integer_constant(item
, 35, "KE_POUND");
119 add_integer_constant(item
, 0, "FONT_FACE_SYSTEM");
120 add_integer_constant(item
, 32, "FONT_FACE_MONOSPACE");
121 add_integer_constant(item
, 64, "FONT_FACE_PROPORTIONAL");
123 add_integer_constant(item
, 8, "FONT_SIZE_SMALL");
124 add_integer_constant(item
, 0, "FONT_SIZE_MEDIUM");
125 add_integer_constant(item
, 16, "FONT_SIZE_LARGE");
127 add_integer_constant(item
, 0, "FONT_STYLE_PLAIN");
128 add_integer_constant(item
, 1, "FONT_STYLE_BOLD");
129 add_integer_constant(item
, 2, "FONT_STYLE_ITALIC");
130 add_integer_constant(item
, 4, "FONT_STYLE_UNDERLINED");
132 /* command constants */
133 add_integer_constant(item
, 1, "CM_SCREEN");
134 add_integer_constant(item
, 2, "CM_BACK");
135 add_integer_constant(item
, 3, "CM_CANCEL");
136 add_integer_constant(item
, 4, "CM_OK");
137 add_integer_constant(item
, 5, "CM_HELP");
138 add_integer_constant(item
, 6, "CM_STOP");
139 add_integer_constant(item
, 7, "CM_EXIT");
140 add_integer_constant(item
, 8, "CM_ITEM");
142 /* text field constants */
143 add_integer_constant(item
, 0, "TF_ANY");
144 add_integer_constant(item
, 1, "TF_EMAIL");
145 add_integer_constant(item
, 2, "TF_NUMERIC");
146 add_integer_constant(item
, 3, "TF_PHONENUMBER");
147 add_integer_constant(item
, 4, "TF_URL");
148 add_integer_constant(item
, 0x10000, "TF_PASSWORD");
150 /* choice constants */
151 add_integer_constant(item
, 1, "CH_EXCLUSIVE");
152 add_integer_constant(item
, 2, "CH_MULTIPLE");
153 add_integer_constant(item
, 3, "CH_IMPLICIT");
156 add_string_constant(item
, string_from_cstr("GET"), "GET");
157 add_string_constant(item
, string_from_cstr("HEAD"), "HEAD");
158 add_string_constant(item
, string_from_cstr("POST"), "POST");
160 /* date field constants */
161 add_integer_constant(item
, 1, "DF_DATE");
162 add_integer_constant(item
, 2, "DF_TIME");
163 add_integer_constant(item
, 3, "DF_DATE_TIME");
165 add_integer_constant(item
, 1000, "EOF");
170 Adds standard functions and procedures
172 void add_std_functions(block
*item
)
175 add_special_function(item
, real_type
, real_type
, "sqrt");
176 add_special_function(item
, real_type
, integer_type
, "trunc");
177 // add_special_function(item, real_type, integer_type, "round");
178 add_special_function(item
, real_type
, real_type
, "sin");
179 add_special_function(item
, real_type
, real_type
, "cos");
180 add_special_function(item
, real_type
, real_type
, "atan");
181 add_special_function(item
, real_type
, real_type
, "log"); /* natural logarithm */
182 add_special_function(item
, real_type
, real_type
, "exp");
183 add_special_function(item
, real_type
, real_type
, "asin");
184 add_special_function(item
, real_type
, real_type
, "acos");
185 add_special_function(item
, real_type
, real_type
, "tan");
186 add_special_function(item
, real_type
, real_type
, "toDegrees");
187 add_special_function(item
, real_type
, real_type
, "toRadians");
188 add_special_function(item
, real_type
, real_type
, "frac");
189 add_special_function2(item
, real_type
, real_type
, real_type
, "atan2");
190 add_special_function(item
, real_type
, real_type
, "log10");
191 add_special_function2(item
, real_type
, real_type
, real_type
, "pow");
192 add_special_function2(item
, string_type
, integer_type
, real_type
, "stringToReal");
193 add_special_function(item
, real_type
, real_type
, "rabs");
195 add_special_function(item
, integer_type
, integer_type
, "sqr");
196 add_special_function(item
, integer_type
, integer_type
, "abs");
198 add_special_function(item
, integer_type
, boolean_type
, "odd");
199 add_special_function(item
, integer_type
, char_type
, "chr");
200 add_special_function(item
, char_type
, integer_type
, "ord");
202 add_special_function(item
, void_type
, void_type
, "halt");
203 add_special_function(item
, void_type
, boolean_type
, "isMidletPaused");
206 add_special_function(item
, void_type
, void_type
, "randomize");
207 add_special_function(item
, integer_type
, integer_type
, "random");
209 /* string functions */
210 add_special_function(item
, string_type
, string_type
, "upcase");
211 add_special_function(item
, string_type
, string_type
, "locase");
212 add_special_function(item
, string_type
, integer_type
, "length");
213 add_special_function3(item
, string_type
, integer_type
, integer_type
, string_type
, "copy");
214 add_special_function2(item
, string_type
, string_type
, integer_type
, "pos");
215 add_special_function(item
, string_type
, integer_type
, "stringToInteger");
216 add_special_function(item
, integer_type
, string_type
, "integerToString");
217 add_special_function2(item
, string_type
, integer_type
, char_type
, "getChar");
218 add_special_function3(item
, string_type
, char_type
, integer_type
, string_type
, "setChar");
220 /* midlet functions */
221 add_special_function(item
, string_type
, string_type
, "getproperty");
225 add_special_function(item
, integer_type
, void_type
, "delay");
226 add_special_function(item
, void_type
, integer_type
, "getRelativeTimeMs");
227 add_special_function(item
, void_type
, integer_type
, "getCurrentTime");
228 add_special_function(item
, integer_type
, integer_type
, "getDay");
229 add_special_function(item
, integer_type
, integer_type
, "getMonth");
230 add_special_function(item
, integer_type
, integer_type
, "getYear");
231 add_special_function(item
, integer_type
, integer_type
, "getSecond");
232 add_special_function(item
, integer_type
, integer_type
, "getMinute");
233 add_special_function(item
, integer_type
, integer_type
, "getHour");
234 add_special_function(item
, integer_type
, integer_type
, "getWeekDay");
235 add_special_function(item
, integer_type
, integer_type
, "getYearDay");
238 /* music functions */
239 add_special_function3(item
, integer_type
, integer_type
, integer_type
, void_type
, "playTone");
242 /* action functions */
243 add_special_function(item
, void_type
, integer_type
, "getKeyPressed");
244 add_special_function(item
, void_type
, integer_type
, "getKeyClicked");
245 add_special_function(item
, integer_type
, integer_type
, "keyToAction");
248 /* image functions */
249 add_special_function(item
, string_type
, image_type
, "loadImage");
250 add_special_function(item
, image_type
, integer_type
, "getImageWidth");
251 add_special_function(item
, image_type
, integer_type
, "getImageHeight");
252 add_special_function5(item
, image_type
, integer_type
, integer_type
, integer_type
, integer_type
, image_type
, "imageFromImage");
253 add_special_function4(item
, integer_type
, integer_type
, integer_type
, integer_type
, image_type
, "imageFromCanvas");
254 add_special_function2(item
, string_type
, integer_type
, image_type
, "imageFromBuffer");
256 /* drawing functions */
257 add_special_function(item
, void_type
, void_type
, "repaint");
259 add_special_function(item
, void_type
, integer_type
, "getWidth");
260 add_special_function(item
, void_type
, integer_type
, "getHeight");
261 add_special_function(item
, void_type
, boolean_type
, "isColorDisplay");
262 add_special_function(item
, void_type
, integer_type
, "getColorsNum");
265 add_special_function3(item
, string_type
, integer_type
, integer_type
, void_type
, "drawText");
266 add_special_function4(item
, integer_type
, integer_type
, integer_type
, integer_type
, void_type
, "setClip");
267 add_special_function4(item
, integer_type
, integer_type
, integer_type
, integer_type
, void_type
, "drawLine");
268 add_special_function3(item
, integer_type
, integer_type
, integer_type
, void_type
, "setColor");
269 add_special_function4(item
, integer_type
, integer_type
, integer_type
, integer_type
, void_type
, "drawEllipse");
270 add_special_function4(item
, integer_type
, integer_type
, integer_type
, integer_type
, void_type
, "fillEllipse");
271 add_special_function4(item
, integer_type
, integer_type
, integer_type
, integer_type
, void_type
, "drawRect");
272 add_special_function4(item
, integer_type
, integer_type
, integer_type
, integer_type
, void_type
, "fillRect");
273 add_special_function6(item
, integer_type
, integer_type
, integer_type
, integer_type
, integer_type
, integer_type
, void_type
, "drawArc");
274 add_special_function2(item
, integer_type
, integer_type
, void_type
, "plot");
275 add_special_function(item
, void_type
, integer_type
, "getColorRed");
276 add_special_function(item
, void_type
, integer_type
, "getColorGreen");
277 add_special_function(item
, void_type
, integer_type
, "getColorBlue");
278 add_special_function6(item
, integer_type
, integer_type
, integer_type
, integer_type
, integer_type
, integer_type
, void_type
, "drawRoundRect");
279 add_special_function6(item
, integer_type
, integer_type
, integer_type
, integer_type
, integer_type
, integer_type
, void_type
, "fillRoundRect");
281 add_special_function3(item
, integer_type
, integer_type
, integer_type
, void_type
, "setFont");
282 add_special_function(item
, void_type
, void_type
, "setDefaultFont");
284 add_special_function3(item
, image_type
, integer_type
, integer_type
, void_type
, "drawImage");
286 add_special_function(item
, string_type
, integer_type
, "getStringWidth");
287 add_special_function(item
, string_type
, integer_type
, "getStringHeight");
289 /* debug functions */
290 add_special_function(item
, string_type
, void_type
, "debug");
291 add_special_function(item
, boolean_type
, void_type
, "assert");
293 /* command & form functions */
294 add_special_function3(item
, string_type
, integer_type
, integer_type
, command_type
, "createCommand");
295 add_special_function(item
, void_type
, command_type
, "getClickedCommand");
296 add_special_function(item
, command_type
, void_type
, "addCommand");
297 add_special_function(item
, command_type
, void_type
, "removeCommand");
298 add_special_function(item
, void_type
, command_type
, "emptyCommand");
300 add_special_function(item
, void_type
, void_type
, "showForm");
301 add_special_function(item
, void_type
, void_type
, "showCanvas");
303 add_special_function(item
, string_type
, void_type
, "setTicker");
305 add_special_function(item
, void_type
, void_type
, "clearForm");
306 add_special_function(item
, integer_type
, void_type
, "formRemove");
307 add_special_function(item
, string_type
, integer_type
, "formAddString");
308 add_special_function(item
, void_type
, integer_type
, "formAddSpace");
309 add_special_function(item
, image_type
, integer_type
, "formAddImage");
310 add_special_function4(item
, string_type
, string_type
, integer_type
, integer_type
, integer_type
, "formAddTextField");
311 add_special_function4(item
, string_type
, boolean_type
, integer_type
, integer_type
, integer_type
, "formAddGauge");
312 add_special_function2(item
, string_type
, integer_type
, integer_type
, "formAddDateField");
313 add_special_function2(item
, integer_type
, integer_type
, void_type
, "formSetDate");
314 add_special_function(item
, integer_type
, integer_type
, "formGetDate");
316 add_special_function2(item
, string_type
, integer_type
, integer_type
, "formAddChoice");
318 add_special_function(item
, integer_type
, integer_type
, "formGetValue");
319 add_special_function(item
, integer_type
, string_type
, "formGetText");
320 add_special_function2(item
, integer_type
, integer_type
, void_type
, "formSetValue");
321 add_special_function2(item
, integer_type
, string_type
, void_type
, "formSetText");
323 add_special_function2(item
, integer_type
, string_type
, integer_type
, "choiceAppendString");
324 add_special_function3(item
, integer_type
, string_type
, image_type
, integer_type
, "choiceAppendStringImage");
325 add_special_function2(item
, integer_type
, integer_type
, boolean_type
, "choiceIsSelected");
326 add_special_function(item
, integer_type
, integer_type
, "choiceGetSelectedIndex");
328 add_special_function(item
, string_type
, void_type
, "setFormTitle");
329 add_special_function(item
, void_type
, void_type
, "removeFormTitle");
330 add_special_function(item
, void_type
, string_type
, "getFormTitle");
332 /* text box elements */
333 add_special_function4(item
, string_type
, string_type
, integer_type
, integer_type
, void_type
, "showTextBox");
334 add_special_function(item
, void_type
, string_type
, "getTextBoxString");
337 add_special_function4(item
, string_type
, string_type
, image_type
, alert_type
, void_type
, "showAlert");
338 add_special_function(item
, void_type
, void_type
, "playAlertSound");
339 add_special_function(item
, void_type
, alert_type
, "ALERT_INFO");
340 add_special_function(item
, void_type
, alert_type
, "ALERT_WARNING");
341 add_special_function(item
, void_type
, alert_type
, "ALERT_ERROR");
342 add_special_function(item
, void_type
, alert_type
, "ALERT_ALARM");
343 add_special_function(item
, void_type
, alert_type
, "ALERT_CONFIRMATION");
346 add_special_function2(item
, string_type
, integer_type
, void_type
, "showMenu");
347 add_special_function(item
, string_type
, integer_type
, "menuAppendString");
348 add_special_function2(item
, string_type
, image_type
, integer_type
, "menuAppendStringImage");
349 add_special_function(item
, integer_type
, boolean_type
, "menuIsSelected");
350 add_special_function(item
, void_type
, integer_type
, "menuGetSelectedIndex");
353 /* record store functions */
354 add_special_function(item
, string_type
, record_store_type
, "openRecordStore");
355 add_special_function(item
, record_store_type
, void_type
, "closeRecordStore");
356 add_special_function(item
, string_type
, void_type
, "deleteRecordStore");
357 add_special_function2(item
, record_store_type
, integer_type
, void_type
, "deleteRecordStoreEntry");
358 add_special_function2(item
, record_store_type
, string_type
, integer_type
, "addRecordStoreEntry");
359 add_special_function2(item
, record_store_type
, integer_type
, string_type
, "readRecordStoreEntry");
360 add_special_function(item
, record_store_type
, integer_type
, "getRecordStoreSize");
361 add_special_function3(item
, record_store_type
, string_type
, integer_type
, void_type
, "modifyRecordStoreEntry");
362 add_special_function(item
, record_store_type
, integer_type
, "getRecordStoreNextId");
364 /* http connectivity functions */
365 add_special_function2(item
, http_type
, string_type
, boolean_type
, "openHttp");
366 add_special_function(item
, http_type
, boolean_type
, "isHttpOpen");
367 add_special_function(item
, http_type
, void_type
, "closeHttp");
368 add_special_function3(item
, http_type
, string_type
, string_type
, void_type
, "addHttpHeader");
369 add_special_function2(item
, http_type
, string_type
, void_type
, "setHttpMethod");
370 add_special_function(item
, http_type
, integer_type
, "sendHttpMessage");
371 add_special_function2(item
, http_type
, string_type
, string_type
, "getHttpHeader");
372 add_special_function2(item
, http_type
, string_type
, void_type
, "addHttpBody");
373 add_special_function(item
, http_type
, string_type
, "getHttpResponse");
376 /* resource-handling functions */
377 add_special_function(item
, string_type
, stream_type
, "openResource");
378 add_special_function(item
, stream_type
, void_type
, "closeResource");
379 add_special_function(item
, stream_type
, integer_type
, "readByte");
380 add_special_function(item
, stream_type
, string_type
, "readLine");
381 add_special_function(item
, stream_type
, boolean_type
, "resourceAvailable");
383 /* player functions */
384 add_special_function2(item
, string_type
, string_type
, boolean_type
, "openPlayer");
385 add_special_function(item
, void_type
, boolean_type
, "startPlayer");
386 add_special_function(item
, void_type
, void_type
, "stopPlayer");
387 add_special_function(item
, integer_type
, boolean_type
, "setPlayerCount");
388 add_special_function(item
, void_type
, integer_type
, "getPlayerDuration");
392 add_special_function2(item
, string_type
, string_type
, boolean_type
, "smsStartSend");
393 add_special_function(item
, void_type
, boolean_type
, "smsIsSending");
394 add_special_function(item
, void_type
, boolean_type
, "smsWasSuccessfull");
400 Adds a single type into the block
402 void add_std_type(block
*item
, enum en_type_class type_class
, char *cstr_name
)
405 identifier
*descriptor
;
407 name
= string_from_cstr(cstr_name
);
408 descriptor
= identifier_create();
409 descriptor
->identifier_class
= type_name
;
410 descriptor
->defined_type
= type_create();
411 descriptor
->defined_type
->type_class
= type_class
;
412 name_table_insert(item
->names
, name
, descriptor
);
417 Add a standard function
419 void add_std_function(block
*item
, char *cstr_name
, type_list
*params
, type
*return_type
)
422 identifier
*descriptor
;
424 name
= string_from_cstr(cstr_name
);
425 descriptor
= identifier_create();
426 descriptor
->identifier_class
= function_name
;
427 descriptor
->return_type
= return_type
;
428 descriptor
->parameters
= params
;
429 descriptor
->variables
= NULL
;
430 descriptor
->standard_function
= 1;
431 name_table_insert(item
->names
, name
, descriptor
);
436 Add a standard procedure
438 void add_std_procedure(block
*item
, char *cstr_name
, type_list
*params
)
441 identifier
*descriptor
;
443 name
= string_from_cstr(cstr_name
);
444 descriptor
= identifier_create();
445 descriptor
->identifier_class
= procedure_name
;
446 descriptor
->parameters
= params
;
447 descriptor
->variables
= NULL
;
448 descriptor
->standard_function
= 1;
449 name_table_insert(item
->names
, name
, descriptor
);
454 Creates the 'prefix' code, the code that is executed before the arguments are evaluated
456 void create_std_function_prefix(bytecode
*code
, char *name
)
460 if ( (strcmp(name
, "drawtext") == 0)
461 || (strcmp(name
, "drawline") == 0)
462 || (strcmp(name
, "setcolor") == 0)
463 || (strcmp(name
, "drawellipse") == 0)
464 || (strcmp(name
, "fillellipse") == 0)
465 || (strcmp(name
, "drawrect") == 0)
466 || (strcmp(name
, "fillrect") == 0)
467 || (strcmp(name
, "drawarc") == 0)
468 || (strcmp(name
, "plot") == 0)
469 || (strcmp(name
, "getcolorred") == 0)
470 || (strcmp(name
, "getcolorblue") == 0)
471 || (strcmp(name
, "getcolorgreen") == 0)
472 || (strcmp(name
, "drawroundrect") == 0)
473 || (strcmp(name
, "fillroundrect") == 0)
474 || (strcmp(name
, "setfont") == 0)
475 || (strcmp(name
, "setdefaultfont") == 0)
476 || (strcmp(name
, "drawimage") == 0)
477 || (strcmp(name
, "getstringheight") == 0)
478 || (strcmp(name
, "setclip") == 0)
481 int field_index
= cp_add_fieldref("M", "G", "Ljavax/microedition/lcdui/Graphics;");
483 bytecode_append(code
, getstatic$
);
484 bytecode_append_short_int(code
, field_index
);
489 if ( (strcmp(name
, "getwidth") == 0)
490 || (strcmp(name
, "getheight") == 0)
493 int field_index
= cp_add_fieldref("M", "I", "Ljavax/microedition/lcdui/Image;");
495 bytecode_append(code
, getstatic$
);
496 bytecode_append_short_int(code
, field_index
);
501 if ((strcmp(name
, "getsecond") == 0)
502 || (strcmp(name
, "getminute") == 0)
503 || (strcmp(name
, "gethour") == 0)
504 || (strcmp(name
, "getday") == 0)
505 || (strcmp(name
, "getmonth") == 0)
506 || (strcmp(name
, "getyear") == 0)
507 || (strcmp(name
, "getweekday") == 0)
508 || (strcmp(name
, "getyearday") == 0)
512 method1
= cp_add_methodref("java/util/Calendar", "getInstance", "()Ljava/util/Calendar;");
513 class1
= cp_add_class("java/util/Date");
515 bytecode_append(code
, invokestatic$
);
516 bytecode_append_short_int(code
, method1
);
518 bytecode_append(code
, dup$
);
520 bytecode_append(code
, new$
);
521 bytecode_append_short_int(code
, class1
);
523 bytecode_append(code
, dup$
);
528 if (strcmp(name
, "createcommand") == 0)
530 bytecode_append(code
, new$
);
531 bytecode_append_short_int(code
, cp_add_class("javax/microedition/lcdui/Command"));
532 bytecode_append(code
, dup$
);
537 if ((strcmp(name
, "vibrate") == 0)
538 || (strcmp(name
, "iscolordisplay") == 0)
539 || (strcmp(name
, "getcolorsnum") == 0))
541 bytecode_append(code
, getstatic$
);
542 bytecode_append_short_int(code
, cp_add_fieldref("FW", "fw", "LFW;"));
544 bytecode_append(code
, invokestatic$
);
545 bytecode_append_short_int(code
, cp_add_methodref("javax/microedition/lcdui/Display",
546 "getDisplay", "(Ljavax/microedition/midlet/MIDlet;)Ljavax/microedition/lcdui/Display;"));
550 if (strcmp(name
, "showtextbox") == 0)
552 bytecode_append(code
, new$
);
553 bytecode_append_short_int(code
, cp_add_class("javax/microedition/lcdui/TextBox"));
554 bytecode_append(code
, dup$
);
558 if (strcmp(name
, "showalert") == 0)
560 bytecode_append(code
, new$
);
561 bytecode_append_short_int(code
, cp_add_class("javax/microedition/lcdui/Alert"));
562 bytecode_append(code
, dup$
);
566 if (strcmp(name
, "showmenu") == 0)
568 bytecode_append(code
, new$
);
569 bytecode_append_short_int(code
, cp_add_class("javax/microedition/lcdui/List"));
570 bytecode_append(code
, dup$
);
574 if ((strcmp(name
, "menuappendstring") == 0)
575 || (strcmp(name
, "menuappendstringimage") == 0)
576 || (strcmp(name
, "menuisselected") == 0)
577 || (strcmp(name
, "menugetselectedindex") == 0))
580 bytecode_append(code
, getstatic$
);
581 bytecode_append_short_int(code
, cp_add_fieldref("FW", "L", "Ljavax/microedition/lcdui/List;"));
585 if (strcmp(name
, "stringtoreal") == 0)
589 bytecode_append(code
, new$
);
590 bytecode_append_short_int(code
, cp_add_class("Real"));
591 bytecode_append(code
, dup$
);
598 Create the bytecode for the standard function or procedure
600 void create_std_function_code(bytecode
*code
, char *name
)
608 case 'a': goto letter_a
;
609 case 'b': goto letter_b
;
610 case 'c': goto letter_c
;
611 case 'd': goto letter_d
;
612 case 'e': goto letter_e
;
613 case 'f': goto letter_f
;
614 case 'g': goto letter_g
;
615 case 'h': goto letter_h
;
616 case 'i': goto letter_i
;
617 case 'j': goto letter_j
;
618 case 'k': goto letter_k
;
619 case 'l': goto letter_l
;
620 case 'm': goto letter_m
;
621 case 'n': goto letter_n
;
622 case 'o': goto letter_o
;
623 case 'p': goto letter_p
;
624 case 'q': goto letter_q
;
625 case 'r': goto letter_r
;
626 case 's': goto letter_s
;
627 case 't': goto letter_t
;
628 case 'u': goto letter_u
;
629 case 'v': goto letter_v
;
630 case 'w': goto letter_w
;
631 case 'x': goto letter_x
;
632 case 'y': goto letter_y
;
633 case 'z': goto letter_z
;
637 if (strcmp(name
, "addhttpbody") == 0)
640 bytecode_append(code
, invokevirtual$
);
641 bytecode_append_short_int(code
, cp_add_methodref("H", "o", "(Ljava/lang/String;)I"));
642 bytecode_append(code
, pop$
);
646 if (strcmp(name
, "addcommand") == 0)
648 if (canvasType
== FULL_NOKIA
)
650 bytecode_append(code
, getstatic$
);
651 bytecode_append_short_int(code
, cp_add_fieldref("FW", "CD", "Ljavax/microedition/lcdui/Displayable;"));
653 bytecode_append(code
, dup$
);
654 bytecode_append(code
, instanceof$
);
655 bytecode_append_short_int(code
, cp_add_class("com/nokia/mid/ui/FullCanvas"));
657 bytecode_append(code
, ifne$
);
658 bytecode_append_short_int(code
, 10);
660 bytecode_append(code
, swap$
);
661 bytecode_append(code
, invokevirtual$
);
662 bytecode_append_short_int(code
, cp_add_methodref("javax/microedition/lcdui/Displayable", "addCommand", "(Ljavax/microedition/lcdui/Command;)V"));
663 bytecode_append(code
, goto$
);
664 bytecode_append_short_int(code
, 4);
666 bytecode_append(code
, pop2$
);
670 bytecode_append(code
, getstatic$
);
671 bytecode_append_short_int(code
, cp_add_fieldref("FW", "CD", "Ljavax/microedition/lcdui/Displayable;"));
672 bytecode_append(code
, swap$
);
673 bytecode_append(code
, invokevirtual$
);
674 bytecode_append_short_int(code
, cp_add_methodref("javax/microedition/lcdui/Displayable", "addCommand", "(Ljavax/microedition/lcdui/Command;)V"));
680 if (strcmp(name
, "addrecordstoreentry") == 0)
683 bytecode_append(code
, invokestatic$
);
684 bytecode_append_short_int(code
,
685 cp_add_methodref("RS", "L", "(Ljavax/microedition/rms/RecordStore;Ljava/lang/String;)I"));
689 if (strcmp(name
, "assert") == 0)
691 char assert_text
[128];
692 sprintf(assert_text
, "Assertion failed at: %s:%d", source_file_name
,procedure_linenum
);
693 bytecode_append(code
, ifne$
);
694 bytecode_append_short_int(code
, 12);
696 bytecode_append(code
, getstatic$
);
697 bytecode_append_short_int(code
, cp_add_fieldref("java/lang/System", "out", "Ljava/io/PrintStream;"));
698 bytecode_append(code
, ldc_w$
);
699 bytecode_append_short_int(code
, cp_add_string(assert_text
));
700 bytecode_append(code
, invokevirtual$
);
701 bytecode_append_short_int(code
, cp_add_methodref("java/io/PrintStream", "println", "(Ljava/lang/String;)V"));
705 if (strcmp(name
, "abs") == 0)
709 method_index
= cp_add_methodref("java/lang/Math", "abs", "(I)I");
711 bytecode_append(code
, invokestatic$
);
712 bytecode_append_short_int(code
, method_index
);
717 if (strcmp(name
, "atan") == 0)
722 bytecode_append(code
, invokestatic$
);
723 bytecode_append_short_int(code
, cp_add_methodref("F", "atan", "(I)I"));
727 bytecode_append(code
, new$
);
728 bytecode_append_short_int(code
, cp_add_class("Real"));
729 bytecode_append(code
, dup_x1$
);
730 bytecode_append(code
, swap$
);
731 bytecode_append(code
, invokespecial$
);
732 bytecode_append_short_int(code
, cp_add_methodref("Real", "<init>", "(LReal;)V"));
733 bytecode_append(code
, dup$
);
734 bytecode_append(code
, invokevirtual$
);
735 bytecode_append_short_int(code
, cp_add_methodref("Real", "atan", "()V"));
741 if (strcmp(name
, "atan2") == 0)
746 bytecode_append(code
, invokestatic$
);
747 bytecode_append_short_int(code
, cp_add_methodref("F", "atan2", "(II)I"));
751 bytecode_append(code
, new$
);
752 bytecode_append_short_int(code
, cp_add_class("Real"));
753 bytecode_append(code
, dup_x1$
);
754 bytecode_append(code
, swap$
);
755 bytecode_append(code
, invokespecial$
);
756 bytecode_append_short_int(code
, cp_add_methodref("Real", "<init>", "(LReal;)V"));
758 bytecode_append(code
, swap$
);
760 bytecode_append(code
, new$
);
761 bytecode_append_short_int(code
, cp_add_class("Real"));
762 bytecode_append(code
, dup_x1$
);
763 bytecode_append(code
, swap$
);
764 bytecode_append(code
, invokespecial$
);
765 bytecode_append_short_int(code
, cp_add_methodref("Real", "<init>", "(LReal;)V"));
767 bytecode_append(code
, dup_x1$
);
768 bytecode_append(code
, swap$
);
770 bytecode_append(code
, invokevirtual$
);
771 bytecode_append_short_int(code
, cp_add_methodref("Real", "atan2", "(LReal;)V"));
777 if (strcmp(name
, "asin") == 0)
782 bytecode_append(code
, invokestatic$
);
783 bytecode_append_short_int(code
, cp_add_methodref("F", "AS", "(I)I"));
787 bytecode_append(code
, new$
);
788 bytecode_append_short_int(code
, cp_add_class("Real"));
789 bytecode_append(code
, dup_x1$
);
790 bytecode_append(code
, swap$
);
791 bytecode_append(code
, invokespecial$
);
792 bytecode_append_short_int(code
, cp_add_methodref("Real", "<init>", "(LReal;)V"));
793 bytecode_append(code
, dup$
);
794 bytecode_append(code
, invokevirtual$
);
795 bytecode_append_short_int(code
, cp_add_methodref("Real", "asin", "()V"));
801 if (strcmp(name
, "acos") == 0)
806 bytecode_append(code
, invokestatic$
);
807 bytecode_append_short_int(code
, cp_add_methodref("F", "AC", "(I)I"));
811 bytecode_append(code
, new$
);
812 bytecode_append_short_int(code
, cp_add_class("Real"));
813 bytecode_append(code
, dup_x1$
);
814 bytecode_append(code
, swap$
);
815 bytecode_append(code
, invokespecial$
);
816 bytecode_append_short_int(code
, cp_add_methodref("Real", "<init>", "(LReal;)V"));
817 bytecode_append(code
, dup$
);
818 bytecode_append(code
, invokevirtual$
);
819 bytecode_append_short_int(code
, cp_add_methodref("Real", "acos", "()V"));
825 if (strcmp(name
, "addhttpheader") == 0)
828 //usesRegisteredFeature = 1;
829 bytecode_append(code
, invokevirtual$
);
830 bytecode_append_short_int(code
, cp_add_methodref("H", "L", "(Ljava/lang/String;Ljava/lang/String;)V"));
834 if (strcmp(name
, "alert_alarm") == 0)
836 bytecode_append(code
, getstatic$
);
837 bytecode_append_short_int(code
, cp_add_fieldref("javax/microedition/lcdui/AlertType",
838 "ALARM", "Ljavax/microedition/lcdui/AlertType;"));
842 if (strcmp(name
, "alert_confirmation") == 0)
844 bytecode_append(code
, getstatic$
);
845 bytecode_append_short_int(code
, cp_add_fieldref("javax/microedition/lcdui/AlertType",
846 "CONFIRMATION", "Ljavax/microedition/lcdui/AlertType;"));
850 if (strcmp(name
, "alert_error") == 0)
852 bytecode_append(code
, getstatic$
);
853 bytecode_append_short_int(code
, cp_add_fieldref("javax/microedition/lcdui/AlertType",
854 "ERROR", "Ljavax/microedition/lcdui/AlertType;"));
858 if (strcmp(name
, "alert_info") == 0)
860 bytecode_append(code
, getstatic$
);
861 bytecode_append_short_int(code
, cp_add_fieldref("javax/microedition/lcdui/AlertType",
862 "INFO", "Ljavax/microedition/lcdui/AlertType;"));
866 if (strcmp(name
, "alert_warning") == 0)
868 bytecode_append(code
, getstatic$
);
869 bytecode_append_short_int(code
, cp_add_fieldref("javax/microedition/lcdui/AlertType",
870 "WARNING", "Ljavax/microedition/lcdui/AlertType;"));
877 if (strcmp(name
, "closeresource") == 0)
880 bytecode_append(code
, invokestatic$
);
881 bytecode_append_short_int(code
, cp_add_methodref("S", "r", "(Ljava/io/InputStream;)V"));
885 if (strcmp(name
, "createcommand") == 0)
887 int method_index
= cp_add_methodref("javax/microedition/lcdui/Command", "<init>", "(Ljava/lang/String;II)V");
888 bytecode_append(code
, invokespecial$
);
889 bytecode_append_short_int(code
, method_index
);
894 if (strcmp(name
, "cos") == 0)
899 bytecode_append(code
, invokestatic$
);
900 bytecode_append_short_int(code
, cp_add_methodref("F", "C", "(I)I"));
904 bytecode_append(code
, new$
);
905 bytecode_append_short_int(code
, cp_add_class("Real"));
906 bytecode_append(code
, dup_x1$
);
907 bytecode_append(code
, swap$
);
908 bytecode_append(code
, invokespecial$
);
909 bytecode_append_short_int(code
, cp_add_methodref("Real", "<init>", "(LReal;)V"));
910 bytecode_append(code
, dup$
);
911 bytecode_append(code
, invokevirtual$
);
912 bytecode_append_short_int(code
, cp_add_methodref("Real", "cos", "()V"));
918 if (strcmp(name
, "chr") == 0)
920 /* do nothing since we represent chars and integers internally in the same way */
924 if (strcmp(name
, "copy") == 0)
928 method_index
= cp_add_methodref("java/lang/String", "substring", "(II)Ljava/lang/String;");
930 bytecode_append(code
, invokevirtual$
);
931 bytecode_append_short_int(code
, method_index
);
935 if (strcmp(name
, "clearform") == 0)
937 bytecode_append(code
, new$
);
938 bytecode_append_short_int(code
, cp_add_class("javax/microedition/lcdui/Form"));
939 bytecode_append(code
, dup$
);
941 bytecode_append(code
, new$
);
942 bytecode_append_short_int(code
, cp_add_class("java/lang/String"));
943 bytecode_append(code
, dup$
);
944 bytecode_append(code
, invokespecial$
);
945 bytecode_append_short_int(code
, cp_add_methodref("java/lang/String", "<init>", "()V"));
947 bytecode_append(code
, invokespecial$
);
948 bytecode_append_short_int(code
, cp_add_methodref("javax/microedition/lcdui/Form", "<init>", "(Ljava/lang/String;)V"));
950 bytecode_append(code
, dup$
);
951 bytecode_append(code
, putstatic$
);
952 bytecode_append_short_int(code
, cp_add_fieldref("FW", "F", "Ljavax/microedition/lcdui/Form;"));
954 bytecode_append(code
, getstatic$
);
955 bytecode_append_short_int(code
, cp_add_fieldref("FW", "fw", "LFW;"));
957 bytecode_append(code
, invokevirtual$
);
958 bytecode_append_short_int(code
, cp_add_methodref("javax/microedition/lcdui/Displayable", "setCommandListener", "(Ljavax/microedition/lcdui/CommandListener;)V"));
965 if(strcmp(name
, "choiceappendstring") == 0)
968 bytecode_append(code
, invokestatic$
);
969 bytecode_append_short_int(code
, cp_add_methodref("FS", "I", "(ILjava/lang/String;)I"));
973 if(strcmp(name
, "choiceappendstringimage") == 0)
976 //usesRegisteredFeature = 1;
977 bytecode_append(code
, invokestatic$
);
978 bytecode_append_short_int(code
, cp_add_methodref("FS", "I", "(ILjava/lang/String;Ljavax/microedition/lcdui/Image;)I"));
982 if(strcmp(name
, "choiceisselected") == 0)
985 bytecode_append(code
, invokestatic$
);
986 bytecode_append_short_int(code
, cp_add_methodref("FS", "L", "(II)I"));
990 if (strcmp(name
, ""))
992 if(strcmp(name
, "choicegetselectedindex") == 0)
995 bytecode_append(code
, invokestatic$
);
996 bytecode_append_short_int(code
, cp_add_methodref("FS", "L", "(I)I"));
1000 if (strcmp(name
, "closerecordstore") == 0)
1002 usesRecordStore
= 1;
1003 bytecode_append(code
, invokestatic$
);
1004 bytecode_append_short_int(code
, cp_add_methodref("RS", "L", "(Ljavax/microedition/rms/RecordStore;)V"));
1008 if (strcmp(name
, "closehttp") == 0)
1011 bytecode_append(code
, invokevirtual$
);
1012 bytecode_append_short_int(code
, cp_add_methodref("H", "c", "()V"));
1017 if (strcmp(name
, "deleterecordstore") == 0)
1019 usesRecordStore
= 1;
1020 //usesRegisteredFeature = 1;
1021 bytecode_append(code
, invokestatic$
);
1022 bytecode_append_short_int(code
, cp_add_methodref("RS", "L", "(Ljava/lang/String;)V"));
1026 if (strcmp(name
, "deleterecordstoreentry") == 0)
1028 usesRecordStore
= 1;
1029 //usesRegisteredFeature = 1;
1030 bytecode_append(code
, invokestatic$
);
1031 bytecode_append_short_int(code
,
1032 cp_add_methodref("RS", "L", "(Ljavax/microedition/rms/RecordStore;I)V"));
1036 if (strcmp(name
, "debug") == 0)
1038 bytecode_append(code
, getstatic$
);
1039 bytecode_append_short_int(code
, cp_add_fieldref("java/lang/System", "out", "Ljava/io/PrintStream;"));
1040 bytecode_append(code
, swap$
);
1041 bytecode_append(code
, invokevirtual$
);
1042 bytecode_append_short_int(code
, cp_add_methodref("java/io/PrintStream", "println", "(Ljava/lang/String;)V"));
1046 if (strcmp(name
, "delay") == 0)
1050 method_index
= cp_add_methodref("java/lang/Thread", "sleep", "(J)V");
1052 bytecode_append(code
, i2l$
);
1053 bytecode_append(code
, invokestatic$
);
1054 bytecode_append_short_int(code
, method_index
);
1059 if (strcmp(name
, "drawtext") == 0)
1063 method_index
= cp_add_methodref("javax/microedition/lcdui/Graphics", "drawString", "(Ljava/lang/String;III)V");
1065 bytecode_append(code
, bipush$
);
1066 bytecode_append(code
, 20);
1068 bytecode_append(code
, invokevirtual$
);
1069 bytecode_append_short_int(code
, method_index
);
1074 if (strcmp(name
, "drawline") == 0)
1078 method_index
= cp_add_methodref("javax/microedition/lcdui/Graphics", "drawLine", "(IIII)V");
1080 bytecode_append(code
, invokevirtual$
);
1081 bytecode_append_short_int(code
, method_index
);
1086 if (strcmp(name
, "drawellipse") == 0)
1090 method_index
= cp_add_methodref("javax/microedition/lcdui/Graphics", "drawArc", "(IIIIII)V");
1092 bytecode_append(code
, bipush$
);
1093 bytecode_append(code
, 0);
1094 bytecode_append(code
, sipush$
);
1095 bytecode_append_short_int(code
, 360);
1097 bytecode_append(code
, invokevirtual$
);
1098 bytecode_append_short_int(code
, method_index
);
1103 if (strcmp(name
, "drawarc") == 0)
1107 method_index
= cp_add_methodref("javax/microedition/lcdui/Graphics", "drawArc", "(IIIIII)V");
1109 bytecode_append(code
, invokevirtual$
);
1110 bytecode_append_short_int(code
, method_index
);
1115 if (strcmp(name
, "drawrect") == 0)
1119 method_index
= cp_add_methodref("javax/microedition/lcdui/Graphics", "drawRect", "(IIII)V");
1121 bytecode_append(code
, invokevirtual$
);
1122 bytecode_append_short_int(code
, method_index
);
1127 if (strcmp(name
, "drawroundrect") == 0)
1131 method_index
= cp_add_methodref("javax/microedition/lcdui/Graphics", "drawRoundRect", "(IIIIII)V");
1133 bytecode_append(code
, invokevirtual$
);
1134 bytecode_append_short_int(code
, method_index
);
1139 if (strcmp(name
, "drawimage") == 0)
1141 int method_index
= cp_add_methodref("javax/microedition/lcdui/Graphics", "drawImage", "(Ljavax/microedition/lcdui/Image;III)V");
1143 bytecode_append(code
, bipush$
);
1144 bytecode_append(code
, 20);
1146 bytecode_append(code
, invokevirtual$
);
1147 bytecode_append_short_int(code
, method_index
);
1152 if (strcmp(name
, "emptycommand") == 0)
1154 bytecode_append(code
, aconst_null$
);
1158 if (strcmp(name
, "exp") == 0)
1163 bytecode_append(code
, invokestatic$
);
1164 bytecode_append_short_int(code
, cp_add_methodref("F", "e", "(I)I"));
1168 bytecode_append(code
, new$
);
1169 bytecode_append_short_int(code
, cp_add_class("Real"));
1170 bytecode_append(code
, dup_x1$
);
1171 bytecode_append(code
, swap$
);
1172 bytecode_append(code
, invokespecial$
);
1173 bytecode_append_short_int(code
, cp_add_methodref("Real", "<init>", "(LReal;)V"));
1174 bytecode_append(code
, dup$
);
1175 bytecode_append(code
, invokevirtual$
);
1176 bytecode_append_short_int(code
, cp_add_methodref("Real", "exp", "()V"));
1183 if (strcmp(name
, "frac") == 0)
1188 bytecode_append(code
, sipush$
);
1189 bytecode_append_short_int(code
, 0x0FFF);
1190 bytecode_append(code
, iand$
);
1194 bytecode_append(code
, new$
);
1195 bytecode_append_short_int(code
, cp_add_class("Real"));
1196 bytecode_append(code
, dup_x1$
);
1197 bytecode_append(code
, swap$
);
1198 bytecode_append(code
, invokespecial$
);
1199 bytecode_append_short_int(code
, cp_add_methodref("Real", "<init>", "(LReal;)V"));
1200 bytecode_append(code
, dup$
);
1201 bytecode_append(code
, invokevirtual$
);
1202 bytecode_append_short_int(code
, cp_add_methodref("Real", "frac", "()V"));
1208 if (strcmp(name
, "fillellipse") == 0)
1212 method_index
= cp_add_methodref("javax/microedition/lcdui/Graphics", "fillArc", "(IIIIII)V");
1214 bytecode_append(code
, bipush$
);
1215 bytecode_append(code
, 0);
1216 bytecode_append(code
, sipush$
);
1217 bytecode_append_short_int(code
, 360);
1219 bytecode_append(code
, invokevirtual$
);
1220 bytecode_append_short_int(code
, method_index
);
1225 if (strcmp(name
, "fillrect") == 0)
1229 method_index
= cp_add_methodref("javax/microedition/lcdui/Graphics", "fillRect", "(IIII)V");
1231 bytecode_append(code
, invokevirtual$
);
1232 bytecode_append_short_int(code
, method_index
);
1238 if (strcmp(name
, "fillroundrect") == 0)
1242 method_index
= cp_add_methodref("javax/microedition/lcdui/Graphics", "fillRoundRect", "(IIIIII)V");
1244 bytecode_append(code
, invokevirtual$
);
1245 bytecode_append_short_int(code
, method_index
);
1250 if (strcmp(name
, "formaddstring") == 0)
1252 bytecode_append(code
, getstatic$
);
1253 bytecode_append_short_int(code
, cp_add_fieldref("FW", "F", "Ljavax/microedition/lcdui/Form;"));
1255 bytecode_append(code
, swap$
);
1257 bytecode_append(code
, invokevirtual$
);
1258 bytecode_append_short_int(code
, cp_add_methodref("javax/microedition/lcdui/Form", "append", "(Ljava/lang/String;)I"));
1262 if (strcmp(name
, "formaddimage") == 0)
1264 bytecode_append(code
, getstatic$
);
1265 bytecode_append_short_int(code
, cp_add_fieldref("FW", "F", "Ljavax/microedition/lcdui/Form;"));
1267 bytecode_append(code
, swap$
);
1269 bytecode_append(code
, invokevirtual$
);
1270 bytecode_append_short_int(code
, cp_add_methodref("javax/microedition/lcdui/Form", "append", "(Ljavax/microedition/lcdui/Image;)I"));
1274 if (strcmp(name
, "formadddatefield") == 0)
1278 bytecode_append(code
, invokestatic$
);
1279 bytecode_append_short_int(code
, cp_add_methodref("FS", "dd", "(Ljava/lang/String;I)I"));
1283 if (strcmp(name
, "formsetdate") == 0)
1287 bytecode_append(code
, invokestatic$
);
1288 bytecode_append_short_int(code
, cp_add_methodref("FS", "dd", "(II)V"));
1292 if (strcmp(name
, "formgetdate") == 0)
1296 bytecode_append(code
, invokestatic$
);
1297 bytecode_append_short_int(code
, cp_add_methodref("FS", "dd", "(I)I"));
1301 if (strcmp(name
, "formaddspace") == 0)
1304 bytecode_append(code
, getstatic$
);
1305 bytecode_append_short_int(code
, cp_add_fieldref("FW", "F", "Ljavax/microedition/lcdui/Form;"));
1308 bytecode_append(code
, new$
);
1309 bytecode_append_short_int(code
, cp_add_class("javax/microedition/lcdui/Spacer"));
1311 bytecode_append(code
, dup$
);
1313 /* init spacer(10, 10)*/
1314 bytecode_append(code
, bipush$
);
1315 bytecode_append(code
, 10);
1316 bytecode_append(code
, dup$
);
1317 bytecode_append(code
, invokespecial$
);
1318 bytecode_append_short_int(code
, cp_add_methodref("javax/microedition/lcdui/Spacer", "<init>", "(II)V"));
1320 /* form.append(Spacer)*/
1321 bytecode_append(code
, invokevirtual$
);
1322 bytecode_append_short_int(code
, cp_add_methodref("javax/microedition/lcdui/Form", "append", "(Ljavax/microedition/lcdui/Item;)I"));
1326 if (strcmp(name
, "formaddtextfield") == 0)
1330 bytecode_append(code
, invokestatic$
);
1331 bytecode_append_short_int(code
, cp_add_methodref("FS", "Lj", "(Ljava/lang/String;Ljava/lang/String;II)I"));
1335 if (strcmp(name
, "formaddgauge") == 0)
1339 bytecode_append(code
, invokestatic$
);
1340 bytecode_append_short_int(code
, cp_add_methodref("FS", "Lj", "(Ljava/lang/String;III)I"));
1344 if (strcmp(name
, "formremove") == 0)
1346 bytecode_append(code
, getstatic$
);
1347 bytecode_append_short_int(code
, cp_add_fieldref("FW", "F", "Ljavax/microedition/lcdui/Form;"));
1349 bytecode_append(code
, swap$
);
1351 bytecode_append(code
, invokevirtual$
);
1352 bytecode_append_short_int(code
, cp_add_methodref("javax/microedition/lcdui/Form", "delete", "(I)V"));
1357 if (strcmp(name
, "formaddchoice") == 0)
1361 bytecode_append(code
, invokestatic$
);
1362 bytecode_append_short_int(code
, cp_add_methodref("FS", "Lj", "(Ljava/lang/String;I)I"));
1366 if (strcmp(name
, "formgetvalue") == 0)
1370 bytecode_append(code
, invokestatic$
);
1371 bytecode_append_short_int(code
, cp_add_methodref("FS", "Lja", "(I)I"));
1375 if (strcmp(name
, "formsetvalue") == 0)
1379 bytecode_append(code
, invokestatic$
);
1380 bytecode_append_short_int(code
, cp_add_methodref("FS", "Lja", "(II)V"));
1384 if (strcmp(name
, "formgettext") == 0)
1388 bytecode_append(code
, invokestatic$
);
1389 bytecode_append_short_int(code
, cp_add_methodref("FS", "ja", "(I)Ljava/lang/String;"));
1393 if (strcmp(name
, "formsettext") == 0)
1397 bytecode_append(code
, invokestatic$
);
1398 bytecode_append_short_int(code
, cp_add_methodref("FS", "ja", "(ILjava/lang/String;)V"));
1403 if (strcmp(name
, "getformtitle") == 0)
1407 bytecode_append(code
, invokestatic$
);
1408 bytecode_append_short_int(code
, cp_add_methodref("FS", "gft", "()Ljava/lang/String;"));
1412 if (strcmp(name
, "getrecordstorenextid") == 0)
1414 usesRecordStore
= 1;
1415 bytecode_append(code
, invokestatic$
);
1416 bytecode_append_short_int(code
,
1417 cp_add_methodref("RS", "Lja", "(Ljavax/microedition/rms/RecordStore;)I"));
1421 if (strcmp(name
, "getplayerduration") == 0)
1425 bytecode_append(code
, invokestatic$
);
1426 bytecode_append_short_int(code
, cp_add_methodref("P", "c", "()I"));
1430 if (strcmp(name
, "getchar") == 0)
1434 bytecode_append(code
, invokestatic$
);
1435 bytecode_append_short_int(code
, cp_add_methodref("S", "gc", "(Ljava/lang/String;I)I"));
1439 if (strcmp(name
, "getrecordstoresize") == 0)
1441 usesRecordStore
= 1;
1442 bytecode_append(code
, invokestatic$
);
1443 bytecode_append_short_int(code
, cp_add_methodref("RS", "j", "(Ljavax/microedition/rms/RecordStore;)I"));
1447 if (strcmp(name
, "getclickedcommand") == 0)
1450 bytecode_append(code
, getstatic$
);
1451 bytecode_append_short_int(code
, cp_add_fieldref("FW", "LC", "Ljavax/microedition/lcdui/Command;"));
1454 bytecode_append(code
, aconst_null$
);
1455 bytecode_append(code
, putstatic$
);
1456 bytecode_append_short_int(code
, cp_add_fieldref("FW", "LC", "Ljavax/microedition/lcdui/Command;"));
1460 if (strcmp(name
, "gettextboxstring") == 0)
1462 bytecode_append(code
, getstatic$
);
1463 bytecode_append_short_int(code
, cp_add_fieldref("FW", "TB", "Ljavax/microedition/lcdui/TextBox;"));
1465 bytecode_append(code
, invokevirtual$
);
1466 bytecode_append_short_int(code
, cp_add_methodref("javax/microedition/lcdui/TextBox", "getString", "()Ljava/lang/String;"));
1470 if (strcmp(name
, "getrelativetimems") == 0)
1474 method_index
= cp_add_methodref("java/lang/System", "currentTimeMillis", "()J");
1475 bytecode_append(code
, invokestatic$
);
1476 bytecode_append_short_int(code
, method_index
);
1477 bytecode_append(code
, l2i$
);
1481 if (strcmp(name
, "getcurrenttime") == 0)
1485 method_index
= cp_add_methodref("java/lang/System", "currentTimeMillis", "()J");
1486 bytecode_append(code
, invokestatic$
);
1487 bytecode_append_short_int(code
, method_index
);
1488 bytecode_append(code
, sipush$
);
1489 bytecode_append_short_int(code
, 1000);
1490 bytecode_append(code
, i2l$
);
1491 bytecode_append(code
, ldiv$
);
1492 bytecode_append(code
, l2i$
);
1496 if (strcmp(name
, "getday") == 0)
1498 int method1
, method2
, method3
, method4
;
1499 method1
= cp_add_methodref("java/util/Calendar", "getInstance", "()Ljava/util/Calendar;");
1500 method2
= cp_add_methodref("java/util/Calendar", "setTime", "(Ljava/util/Date;)V");
1501 method3
= cp_add_methodref("java/util/Calendar", "get", "(I)I");
1502 method4
= cp_add_methodref("java/util/Date", "<init>", "(J)V");
1504 /* time as int-seconds traslate into millis-long */
1505 bytecode_append(code
, i2l$
);
1506 bytecode_append(code
, sipush$
);
1507 bytecode_append_short_int(code
, 1000);
1508 bytecode_append(code
, i2l$
);
1509 bytecode_append(code
, lmul$
);
1511 /* the stack is now: ..., Calendar, Calendar, Date, Date, Millis */
1512 bytecode_append(code
, invokespecial$
);
1513 bytecode_append_short_int(code
, method4
);
1515 /* stack is now Calendar, Calendar, Date*/
1516 bytecode_append(code
, invokevirtual$
);
1517 bytecode_append_short_int(code
, method2
);
1519 bytecode_append(code
, bipush$
);
1520 bytecode_append(code
, 5);
1522 bytecode_append(code
, invokevirtual$
);
1523 bytecode_append_short_int(code
, method3
);
1528 if (strcmp(name
, "getweekday") == 0)
1530 int method1
, method2
, method3
, method4
;
1531 method1
= cp_add_methodref("java/util/Calendar", "getInstance", "()Ljava/util/Calendar;");
1532 method2
= cp_add_methodref("java/util/Calendar", "setTime", "(Ljava/util/Date;)V");
1533 method3
= cp_add_methodref("java/util/Calendar", "get", "(I)I");
1534 method4
= cp_add_methodref("java/util/Date", "<init>", "(J)V");
1536 /* time as int-seconds traslate into millis-long */
1537 bytecode_append(code
, i2l$
);
1538 bytecode_append(code
, sipush$
);
1539 bytecode_append_short_int(code
, 1000);
1540 bytecode_append(code
, i2l$
);
1541 bytecode_append(code
, lmul$
);
1543 /* the stack is now: ..., Calendar, Calendar, Date, Date, Millis */
1544 bytecode_append(code
, invokespecial$
);
1545 bytecode_append_short_int(code
, method4
);
1547 /* stack is now Calendar, Calendar, Date*/
1548 bytecode_append(code
, invokevirtual$
);
1549 bytecode_append_short_int(code
, method2
);
1551 bytecode_append(code
, bipush$
);
1552 bytecode_append(code
, 7);
1554 bytecode_append(code
, invokevirtual$
);
1555 bytecode_append_short_int(code
, method3
);
1560 if (strcmp(name
, "getyearday") == 0)
1562 int method1
, method2
, method3
, method4
;
1563 method1
= cp_add_methodref("java/util/Calendar", "getInstance", "()Ljava/util/Calendar;");
1564 method2
= cp_add_methodref("java/util/Calendar", "setTime", "(Ljava/util/Date;)V");
1565 method3
= cp_add_methodref("java/util/Calendar", "get", "(I)I");
1566 method4
= cp_add_methodref("java/util/Date", "<init>", "(J)V");
1568 /* time as int-seconds traslate into millis-long */
1569 bytecode_append(code
, i2l$
);
1570 bytecode_append(code
, sipush$
);
1571 bytecode_append_short_int(code
, 1000);
1572 bytecode_append(code
, i2l$
);
1573 bytecode_append(code
, lmul$
);
1575 /* the stack is now: ..., Calendar, Calendar, Date, Date, Millis */
1576 bytecode_append(code
, invokespecial$
);
1577 bytecode_append_short_int(code
, method4
);
1579 /* stack is now Calendar, Calendar, Date*/
1580 bytecode_append(code
, invokevirtual$
);
1581 bytecode_append_short_int(code
, method2
);
1583 bytecode_append(code
, bipush$
);
1584 bytecode_append(code
, 6);
1586 bytecode_append(code
, invokevirtual$
);
1587 bytecode_append_short_int(code
, method3
);
1592 if (strcmp(name
, "getmonth") == 0)
1594 int method1
, method2
, method3
, method4
;
1595 method1
= cp_add_methodref("java/util/Calendar", "getInstance", "()Ljava/util/Calendar;");
1596 method2
= cp_add_methodref("java/util/Calendar", "setTime", "(Ljava/util/Date;)V");
1597 method3
= cp_add_methodref("java/util/Calendar", "get", "(I)I");
1598 method4
= cp_add_methodref("java/util/Date", "<init>", "(J)V");
1600 /* time as int-seconds traslate into millis-long */
1601 bytecode_append(code
, i2l$
);
1602 bytecode_append(code
, sipush$
);
1603 bytecode_append_short_int(code
, 1000);
1604 bytecode_append(code
, i2l$
);
1605 bytecode_append(code
, lmul$
);
1607 /* the stack is now: ..., Calendar, Calendar, Date, Date, Millis */
1608 bytecode_append(code
, invokespecial$
);
1609 bytecode_append_short_int(code
, method4
);
1611 /* stack is now Calendar, Calendar, Date*/
1612 bytecode_append(code
, invokevirtual$
);
1613 bytecode_append_short_int(code
, method2
);
1615 bytecode_append(code
, bipush$
);
1616 bytecode_append(code
, 2);
1618 bytecode_append(code
, invokevirtual$
);
1619 bytecode_append_short_int(code
, method3
);
1621 bytecode_append(code
, iconst_0$
);
1622 bytecode_append(code
, iadd$
);
1627 if (strcmp(name
, "getyear") == 0)
1629 int method1
, method2
, method3
, method4
;
1630 method1
= cp_add_methodref("java/util/Calendar", "getInstance", "()Ljava/util/Calendar;");
1631 method2
= cp_add_methodref("java/util/Calendar", "setTime", "(Ljava/util/Date;)V");
1632 method3
= cp_add_methodref("java/util/Calendar", "get", "(I)I");
1633 method4
= cp_add_methodref("java/util/Date", "<init>", "(J)V");
1635 /* time as int-seconds traslate into millis-long */
1636 bytecode_append(code
, i2l$
);
1637 bytecode_append(code
, sipush$
);
1638 bytecode_append_short_int(code
, 1000);
1639 bytecode_append(code
, i2l$
);
1640 bytecode_append(code
, lmul$
);
1642 /* the stack is now: ..., Calendar, Calendar, Date, Date, Millis */
1643 bytecode_append(code
, invokespecial$
);
1644 bytecode_append_short_int(code
, method4
);
1646 /* stack is now Calendar, Calendar, Date*/
1647 bytecode_append(code
, invokevirtual$
);
1648 bytecode_append_short_int(code
, method2
);
1650 bytecode_append(code
, bipush$
);
1651 bytecode_append(code
, 1);
1653 bytecode_append(code
, invokevirtual$
);
1654 bytecode_append_short_int(code
, method3
);
1659 if (strcmp(name
, "getsecond") == 0)
1661 int method1
, method2
, method3
, method4
;
1662 method1
= cp_add_methodref("java/util/Calendar", "getInstance", "()Ljava/util/Calendar;");
1663 method2
= cp_add_methodref("java/util/Calendar", "setTime", "(Ljava/util/Date;)V");
1664 method3
= cp_add_methodref("java/util/Calendar", "get", "(I)I");
1665 method4
= cp_add_methodref("java/util/Date", "<init>", "(J)V");
1667 /* time as int-seconds traslate into millis-long */
1668 bytecode_append(code
, i2l$
);
1669 bytecode_append(code
, sipush$
);
1670 bytecode_append_short_int(code
, 1000);
1671 bytecode_append(code
, i2l$
);
1672 bytecode_append(code
, lmul$
);
1674 /* the stack is now: ..., Calendar, Calendar, Date, Date, Millis */
1675 bytecode_append(code
, invokespecial$
);
1676 bytecode_append_short_int(code
, method4
);
1678 /* stack is now Calendar, Calendar, Date*/
1679 bytecode_append(code
, invokevirtual$
);
1680 bytecode_append_short_int(code
, method2
);
1682 bytecode_append(code
, bipush$
);
1683 bytecode_append(code
, 13);
1685 bytecode_append(code
, invokevirtual$
);
1686 bytecode_append_short_int(code
, method3
);
1691 if (strcmp(name
, "getminute") == 0)
1693 int method1
, method2
, method3
, method4
;
1694 method1
= cp_add_methodref("java/util/Calendar", "getInstance", "()Ljava/util/Calendar;");
1695 method2
= cp_add_methodref("java/util/Calendar", "setTime", "(Ljava/util/Date;)V");
1696 method3
= cp_add_methodref("java/util/Calendar", "get", "(I)I");
1697 method4
= cp_add_methodref("java/util/Date", "<init>", "(J)V");
1699 /* time as int-seconds traslate into millis-long */
1700 bytecode_append(code
, i2l$
);
1701 bytecode_append(code
, sipush$
);
1702 bytecode_append_short_int(code
, 1000);
1703 bytecode_append(code
, i2l$
);
1704 bytecode_append(code
, lmul$
);
1706 /* the stack is now: ..., Calendar, Calendar, Date, Date, Millis */
1707 bytecode_append(code
, invokespecial$
);
1708 bytecode_append_short_int(code
, method4
);
1710 /* stack is now Calendar, Calendar, Date*/
1711 bytecode_append(code
, invokevirtual$
);
1712 bytecode_append_short_int(code
, method2
);
1714 bytecode_append(code
, bipush$
);
1715 bytecode_append(code
, 12);
1717 bytecode_append(code
, invokevirtual$
);
1718 bytecode_append_short_int(code
, method3
);
1723 if (strcmp(name
, "gethour") == 0)
1725 int method1
, method2
, method3
, method4
;
1726 method1
= cp_add_methodref("java/util/Calendar", "getInstance", "()Ljava/util/Calendar;");
1727 method2
= cp_add_methodref("java/util/Calendar", "setTime", "(Ljava/util/Date;)V");
1728 method3
= cp_add_methodref("java/util/Calendar", "get", "(I)I");
1729 method4
= cp_add_methodref("java/util/Date", "<init>", "(J)V");
1731 /* time as int-seconds traslate into millis-long */
1732 bytecode_append(code
, i2l$
);
1733 bytecode_append(code
, sipush$
);
1734 bytecode_append_short_int(code
, 1000);
1735 bytecode_append(code
, i2l$
);
1736 bytecode_append(code
, lmul$
);
1738 /* the stack is now: ..., Calendar, Calendar, Date, Date, Millis */
1739 bytecode_append(code
, invokespecial$
);
1740 bytecode_append_short_int(code
, method4
);
1742 /* stack is now Calendar, Calendar, Date*/
1743 bytecode_append(code
, invokevirtual$
);
1744 bytecode_append_short_int(code
, method2
);
1746 bytecode_append(code
, bipush$
);
1747 bytecode_append(code
, 11);
1749 bytecode_append(code
, invokevirtual$
);
1750 bytecode_append_short_int(code
, method3
);
1755 if (strcmp(name
, "getkeypressed") == 0)
1757 int field_index
= cp_add_fieldref("M", "KP", "I");
1759 bytecode_append(code
, getstatic$
);
1760 bytecode_append_short_int(code
, field_index
);
1765 if (strcmp(name
, "getkeyclicked") == 0)
1767 int field_index
= cp_add_fieldref("M", "KC", "I");
1769 bytecode_append(code
, getstatic$
);
1770 bytecode_append_short_int(code
, field_index
);
1771 bytecode_append(code
, iconst_0$
);
1772 bytecode_append(code
, putstatic$
);
1773 bytecode_append_short_int(code
, field_index
);
1778 if (strcmp(name
, "getcolorred") == 0)
1782 method_index
= cp_add_methodref("javax/microedition/lcdui/Graphics", "getRedComponent", "()I");
1784 bytecode_append(code
, invokevirtual$
);
1785 bytecode_append_short_int(code
, method_index
);
1790 if (strcmp(name
, "getcolorgreen") == 0)
1794 method_index
= cp_add_methodref("javax/microedition/lcdui/Graphics", "getGreenComponent", "()I");
1796 bytecode_append(code
, invokevirtual$
);
1797 bytecode_append_short_int(code
, method_index
);
1802 if (strcmp(name
, "getcolorblue") == 0)
1806 method_index
= cp_add_methodref("javax/microedition/lcdui/Graphics", "getBlueComponent", "()I");
1808 bytecode_append(code
, invokevirtual$
);
1809 bytecode_append_short_int(code
, method_index
);
1814 if (strcmp(name
, "getwidth") == 0)
1818 method_index
= cp_add_methodref("javax/microedition/lcdui/Image", "getWidth", "()I");
1820 bytecode_append(code
, invokevirtual$
);
1821 bytecode_append_short_int(code
, method_index
);
1826 if (strcmp(name
, "getheight") == 0)
1830 method_index
= cp_add_methodref("javax/microedition/lcdui/Image", "getHeight", "()I");
1832 bytecode_append(code
, invokevirtual$
);
1833 bytecode_append_short_int(code
, method_index
);
1838 if (strcmp(name
, "getimagewidth") == 0)
1840 int method_index
= cp_add_methodref("javax/microedition/lcdui/Image", "getWidth", "()I");
1842 bytecode_append(code
, invokevirtual$
);
1843 bytecode_append_short_int(code
, method_index
);
1847 if (strcmp(name
, "getimageheight") == 0)
1849 int method_index
= cp_add_methodref("javax/microedition/lcdui/Image", "getHeight", "()I");
1851 bytecode_append(code
, invokevirtual$
);
1852 bytecode_append_short_int(code
, method_index
);
1856 if (strcmp(name
, "getstringheight") == 0)
1859 method_index
= cp_add_methodref("javax/microedition/lcdui/Graphics", "getFont", "()Ljavax/microedition/lcdui/Font;");
1860 bytecode_append(code
, pop$
);
1861 bytecode_append(code
, invokevirtual$
);
1862 bytecode_append_short_int(code
, method_index
);
1863 method_index
= cp_add_methodref("javax/microedition/lcdui/Font", "getHeight", "()I");
1864 bytecode_append(code
, invokevirtual$
);
1865 bytecode_append_short_int(code
, method_index
);
1869 if (strcmp(name
, "getstringwidth") == 0)
1872 int field_index
= cp_add_fieldref("M", "G", "Ljavax/microedition/lcdui/Graphics;");
1874 bytecode_append(code
, getstatic$
);
1875 bytecode_append_short_int(code
, field_index
);
1877 method_index
= cp_add_methodref("javax/microedition/lcdui/Graphics", "getFont", "()Ljavax/microedition/lcdui/Font;");
1878 bytecode_append(code
, invokevirtual$
);
1879 bytecode_append_short_int(code
, method_index
);
1881 bytecode_append(code
, swap$
);
1882 method_index
= cp_add_methodref("javax/microedition/lcdui/Font", "stringWidth", "(Ljava/lang/String;)I");
1883 bytecode_append(code
, invokevirtual$
);
1884 bytecode_append_short_int(code
, method_index
);
1889 if (strcmp(name
, "getproperty") == 0)
1891 bytecode_append(code
, invokestatic$
);
1892 bytecode_append_short_int(code
, cp_add_methodref("java/lang/System", "getProperty", "(Ljava/lang/String;)Ljava/lang/String;"));
1893 bytecode_append(code
, dup$
);
1894 bytecode_append(code
, ifnonnull$
);
1895 bytecode_append_short_int(code
, 11);
1897 /* if the returned string is null, create an empty string */
1898 bytecode_append(code
, pop$
);
1899 bytecode_append(code
, new$
);
1900 bytecode_append_short_int(code
, cp_add_class("java/lang/String"));
1901 bytecode_append(code
, dup$
);
1902 bytecode_append(code
, invokespecial$
);
1903 bytecode_append_short_int(code
, cp_add_methodref("java/lang/String", "<init>", "()V"));
1907 if (strcmp(name
, "getcolorsnum") == 0)
1909 bytecode_append(code
, invokevirtual$
);
1910 bytecode_append_short_int(code
, cp_add_methodref("javax/microedition/lcdui/Display", "numColors", "()I"));
1914 if (strcmp(name
, "gethttpheader") == 0)
1917 //usesRegisteredFeature = 1;
1918 bytecode_append(code
, invokevirtual$
);
1919 bytecode_append_short_int(code
, cp_add_methodref("H", "i", "(Ljava/lang/String;)Ljava/lang/String;"));
1923 if (strcmp(name
, "gethttpresponse") == 0)
1926 bytecode_append(code
, invokevirtual$
);
1927 bytecode_append_short_int(code
, cp_add_methodref("H", "j", "()Ljava/lang/String;"));
1932 if (strcmp(name
, "halt") == 0)
1937 field_index
= cp_add_fieldref("FW", "fw", "LFW;");
1938 method_index
= cp_add_methodref("FW", "destroyApp", "(Z)V");
1940 bytecode_append(code
, getstatic$
);
1941 bytecode_append_short_int(code
, field_index
);
1942 bytecode_append(code
, iconst_1$
);
1943 bytecode_append(code
, invokevirtual$
);
1944 bytecode_append_short_int(code
, method_index
);
1946 bytecode_append(code
, invokestatic$
);
1947 bytecode_append_short_int(code
, cp_add_methodref("java/lang/Thread", "currentThread", "()Ljava/lang/Thread;"));
1949 bytecode_append(code
, invokevirtual$
);
1950 bytecode_append_short_int(code
, cp_add_methodref("java/lang/Thread", "join", "()V"));
1952 bytecode_append(code
, sipush$
);
1953 bytecode_append_short_int(code
, 1000);
1954 bytecode_append(code
, i2l$
);
1955 bytecode_append(code
, invokestatic$
);
1956 bytecode_append_short_int(code
, cp_add_methodref("java/lang/Thread", "sleep", "(J)V"));
1962 if (strcmp(name
, "imagefromimage") == 0)
1966 bytecode_append(code
, invokestatic$
);
1967 bytecode_append_short_int(code
, cp_add_methodref("S", "ii", "(Ljavax/microedition/lcdui/Image;IIII)Ljavax/microedition/lcdui/Image;"));
1971 if (strcmp(name
, "imagefromcanvas") == 0)
1975 bytecode_append(code
, invokestatic$
);
1976 bytecode_append_short_int(code
, cp_add_methodref("S", "ii", "(IIII)Ljavax/microedition/lcdui/Image;"));
1980 if (strcmp(name
, "imagefrombuffer") == 0)
1984 bytecode_append(code
, invokestatic$
);
1985 bytecode_append_short_int(code
, cp_add_methodref("S", "ii", "(Ljava/lang/String;I)Ljavax/microedition/lcdui/Image;"));
1989 if (strcmp(name
, "integertostring") == 0)
1991 bytecode_append(code
, new$
);
1992 bytecode_append_short_int(code
, cp_add_class("java/lang/StringBuffer"));
1993 bytecode_append(code
, dup$
);
1994 bytecode_append(code
, invokespecial$
);
1995 bytecode_append_short_int(code
, cp_add_methodref("java/lang/StringBuffer", "<init>", "()V"));
1997 bytecode_append(code
, swap$
);
1999 bytecode_append(code
, invokevirtual$
);
2000 bytecode_append_short_int(code
, cp_add_methodref("java/lang/StringBuffer", "append", "(I)Ljava/lang/StringBuffer;"));
2002 bytecode_append(code
, invokevirtual$
);
2003 bytecode_append_short_int(code
, cp_add_methodref("java/lang/StringBuffer", "toString", "()Ljava/lang/String;"));
2007 if (strcmp(name
, "ismidletpaused") == 0)
2009 int field_index
= cp_add_fieldref("FW", "MP", "I");
2011 bytecode_append(code
, getstatic$
);
2012 bytecode_append_short_int(code
, field_index
);
2017 if (strcmp(name
, "ishttpopen") == 0)
2019 bytecode_append(code
, invokevirtual$
);
2020 bytecode_append_short_int(code
, cp_add_methodref("H", "L", "()I"));
2024 if (strcmp(name
, "iscolordisplay") == 0)
2026 bytecode_append(code
, invokevirtual$
);
2027 bytecode_append_short_int(code
, cp_add_methodref("javax/microedition/lcdui/Display", "isColor", "()Z"));
2029 bytecode_append(code
, ifeq$
);
2030 bytecode_append_short_int(code
, 7);
2032 bytecode_append(code
, iconst_m1$
);
2033 bytecode_append(code
, goto$
);
2034 bytecode_append_short_int(code
, 4);
2036 bytecode_append(code
, iconst_0$
);
2043 if (strcmp(name
, "keytoaction") == 0)
2045 int field_index
= cp_add_fieldref("M", "T", "LM;");
2047 /* check if the argument is zero, goto (1)*/
2048 bytecode_append(code
, dup$
);
2049 bytecode_append(code
, ifeq$
);
2050 bytecode_append_short_int(code
, 13);
2052 /* otherwise call the getGameAction*/
2053 bytecode_append(code
, getstatic$
);
2054 bytecode_append_short_int(code
, field_index
);
2055 bytecode_append(code
, swap$
);
2056 bytecode_append(code
, invokevirtual$
);
2057 bytecode_append_short_int(code
, cp_add_methodref("M", "getGameAction", "(I)I"));
2060 bytecode_append(code
, goto$
);
2061 bytecode_append_short_int(code
, 5);
2063 /* (1): pop the operands, push 0 to the stack */
2064 bytecode_append(code
, pop$
);
2065 bytecode_append(code
, iconst_0$
);
2073 if (strcmp(name
, "log") == 0)
2078 bytecode_append(code
, invokestatic$
);
2079 bytecode_append_short_int(code
, cp_add_methodref("F", "log", "(I)I"));
2083 bytecode_append(code
, new$
);
2084 bytecode_append_short_int(code
, cp_add_class("Real"));
2085 bytecode_append(code
, dup_x1$
);
2086 bytecode_append(code
, swap$
);
2087 bytecode_append(code
, invokespecial$
);
2088 bytecode_append_short_int(code
, cp_add_methodref("Real", "<init>", "(LReal;)V"));
2089 bytecode_append(code
, dup$
);
2090 bytecode_append(code
, invokevirtual$
);
2091 bytecode_append_short_int(code
, cp_add_methodref("Real", "ln", "()V"));
2097 if (strcmp(name
, "log10") == 0)
2102 bytecode_append(code
, invokestatic$
);
2103 bytecode_append_short_int(code
, cp_add_methodref("F", "log10", "(I)I"));
2107 bytecode_append(code
, new$
);
2108 bytecode_append_short_int(code
, cp_add_class("Real"));
2109 bytecode_append(code
, dup_x1$
);
2110 bytecode_append(code
, swap$
);
2111 bytecode_append(code
, invokespecial$
);
2112 bytecode_append_short_int(code
, cp_add_methodref("Real", "<init>", "(LReal;)V"));
2113 bytecode_append(code
, dup$
);
2114 bytecode_append(code
, invokevirtual$
);
2115 bytecode_append_short_int(code
, cp_add_methodref("Real", "log10", "()V"));
2121 if (strcmp(name
, "length") == 0)
2123 int method_index
= cp_add_methodref("java/lang/String", "length", "()I");
2124 bytecode_append(code
, invokevirtual$
);
2125 bytecode_append_short_int(code
, method_index
);
2129 if (strcmp(name
, "locase") == 0)
2135 class_index
= cp_add_class("java/lang/String");
2136 init_index
= cp_add_methodref("java/lang/String", "<init>", "(Ljava/lang/String;)V");
2137 method_index
= cp_add_methodref("java/lang/String", "toLowerCase", "()Ljava/lang/String;");
2139 bytecode_append(code
, new$
);
2140 bytecode_append_short_int(code
, class_index
);
2141 bytecode_append(code
, dup_x1$
);
2142 bytecode_append(code
, swap$
);
2143 bytecode_append(code
, invokespecial$
);
2144 bytecode_append_short_int(code
, init_index
);
2146 bytecode_append(code
, invokevirtual$
);
2147 bytecode_append_short_int(code
, method_index
);
2151 if (strcmp(name
, "loadimage") == 0)
2153 int method_index
= cp_add_methodref("javax/microedition/lcdui/Image", "createImage", "(Ljava/lang/String;)Ljavax/microedition/lcdui/Image;");
2155 bytecode_append(code
, invokestatic$
);
2156 bytecode_append_short_int(code
, method_index
);
2161 if (strcmp(name
, "modifyrecordstoreentry") == 0)
2163 usesRecordStore
= 1;
2164 bytecode_append(code
, invokestatic$
);
2165 bytecode_append_short_int(code
,
2166 cp_add_methodref("RS", "L", "(Ljavax/microedition/rms/RecordStore;Ljava/lang/String;I)V"));
2171 if (strcmp(name
, "menuappendstring") == 0)
2173 bytecode_append(code
, aconst_null$
);
2175 bytecode_append(code
, invokevirtual$
);
2176 bytecode_append_short_int(code
, cp_add_methodref("javax/microedition/lcdui/List",
2178 "(Ljava/lang/String;Ljavax/microedition/lcdui/Image;)I"));
2182 if (strcmp(name
, "menuappendstringimage") == 0)
2184 //usesRegisteredFeature = 1;
2185 bytecode_append(code
, invokevirtual$
);
2186 bytecode_append_short_int(code
, cp_add_methodref("javax/microedition/lcdui/List",
2188 "(Ljava/lang/String;Ljavax/microedition/lcdui/Image;)I"));
2192 if (strcmp(name
, "menuisselected") == 0)
2194 bytecode_append(code
, invokevirtual$
);
2195 bytecode_append_short_int(code
, cp_add_methodref("javax/microedition/lcdui/List",
2199 bytecode_append(code
, ifeq$
);
2200 bytecode_append_short_int(code
, 7);
2201 bytecode_append(code
, iconst_m1$
);
2202 bytecode_append(code
, goto$
);
2203 bytecode_append_short_int(code
, 4);
2204 bytecode_append(code
, iconst_0$
);
2209 if (strcmp(name
, "menugetselectedindex") == 0)
2211 bytecode_append(code
, invokevirtual$
);
2212 bytecode_append_short_int(code
, cp_add_methodref("javax/microedition/lcdui/List",
2223 if (strcmp(name
, "openplayer") == 0)
2226 bytecode_append(code
, invokestatic$
);
2227 bytecode_append_short_int(code
, cp_add_methodref("P", "a", "(Ljava/lang/String;Ljava/lang/String;)I"));
2231 if (strcmp(name
, "openresource") == 0)
2234 bytecode_append(code
, invokestatic$
);
2235 bytecode_append_short_int(code
, cp_add_methodref("S", "r", "(Ljava/lang/String;)Ljava/io/InputStream;"));
2239 if (strcmp(name
, "ord") == 0)
2241 /* do nothing, opposite of chr */
2245 if (strcmp(name
, "openhttp") == 0)
2248 bytecode_append(code
, invokevirtual$
);
2249 bytecode_append_short_int(code
, cp_add_methodref("H", "L", "(Ljava/lang/String;)I"));
2253 if (strcmp(name
, "odd") == 0)
2255 /* just leave the last bit: if it is zero, the number is even and the 0 (false)
2256 will be on the stack */
2257 bytecode_append(code
, iconst_1$
);
2258 bytecode_append(code
, iand$
);
2259 bytecode_append(code
, iconst_m1$
);
2260 bytecode_append(code
, imul$
);
2265 if (strcmp(name
, "openrecordstore") == 0)
2267 usesRecordStore
= 1;
2269 bytecode_append(code
, invokestatic$
);
2270 bytecode_append_short_int(code
, cp_add_methodref("RS", "j", "(Ljava/lang/String;)Ljavax/microedition/rms/RecordStore;"));
2275 if (strcmp(name
, "playtone") == 0)
2277 int method_index
= cp_add_methodref("javax/microedition/media/Manager", "playTone", "(III)V");
2279 bytecode_append(code
, invokestatic$
);
2280 bytecode_append_short_int(code
, method_index
);
2285 if (strcmp(name
, "playalertsound") == 0)
2287 bytecode_append(code
, getstatic$
);
2288 bytecode_append_short_int(code
, cp_add_fieldref("FW", "A", "Ljavax/microedition/lcdui/Alert;"));
2290 bytecode_append(code
, invokevirtual$
);
2291 bytecode_append_short_int(code
, cp_add_methodref("javax/microedition/lcdui/Alert", "getType", "()Ljavax/microedition/lcdui/AlertType;"));
2293 bytecode_append(code
, getstatic$
);
2294 bytecode_append_short_int(code
, cp_add_fieldref("FW", "fw", "LFW;"));
2296 bytecode_append(code
, invokestatic$
);
2297 bytecode_append_short_int(code
, cp_add_methodref("javax/microedition/lcdui/Display", "getDisplay", "(Ljavax/microedition/midlet/MIDlet;)Ljavax/microedition/lcdui/Display;"));
2299 bytecode_append(code
, invokevirtual$
);
2300 bytecode_append_short_int(code
, cp_add_methodref(
2301 "javax/microedition/lcdui/AlertType",
2303 "(Ljavax/microedition/lcdui/Display;)Z"));
2305 bytecode_append(code
, pop$
);
2309 if (strcmp(name
, "pow") == 0)
2314 bytecode_append(code
, invokestatic$
);
2315 bytecode_append_short_int(code
, cp_add_methodref("F", "p", "(II)I"));
2319 bytecode_append(code
, new$
);
2320 bytecode_append_short_int(code
, cp_add_class("Real"));
2321 bytecode_append(code
, dup_x1$
);
2322 bytecode_append(code
, swap$
);
2323 bytecode_append(code
, invokespecial$
);
2324 bytecode_append_short_int(code
, cp_add_methodref("Real", "<init>", "(LReal;)V"));
2326 bytecode_append(code
, swap$
);
2328 bytecode_append(code
, new$
);
2329 bytecode_append_short_int(code
, cp_add_class("Real"));
2330 bytecode_append(code
, dup_x1$
);
2331 bytecode_append(code
, swap$
);
2332 bytecode_append(code
, invokespecial$
);
2333 bytecode_append_short_int(code
, cp_add_methodref("Real", "<init>", "(LReal;)V"));
2335 bytecode_append(code
, dup_x1$
);
2336 bytecode_append(code
, swap$
);
2338 bytecode_append(code
, invokevirtual$
);
2339 bytecode_append_short_int(code
, cp_add_methodref("Real", "pow", "(LReal;)V"));
2345 if (strcmp(name
, "pos") == 0)
2349 method_index
= cp_add_methodref("java/lang/String", "indexOf", "(Ljava/lang/String;)I");
2351 bytecode_append(code
, invokevirtual$
);
2352 bytecode_append_short_int(code
, method_index
);
2356 if (strcmp(name
, "plot") == 0)
2360 method_index
= cp_add_methodref("javax/microedition/lcdui/Graphics", "fillRect", "(IIII)V");
2362 bytecode_append(code
, iconst_1$
);
2363 bytecode_append(code
, dup$
);
2365 bytecode_append(code
, invokevirtual$
);
2366 bytecode_append_short_int(code
, method_index
);
2373 if (strcmp(name
, "removeformtitle") == 0)
2376 bytecode_append(code
, getstatic$
);
2377 bytecode_append_short_int(code
, cp_add_fieldref("FW", "F", "Ljavax/microedition/lcdui/Form;"));
2379 /* set the form's title to null */
2380 bytecode_append(code
, aconst_null$
);
2381 bytecode_append(code
, invokevirtual$
);
2382 bytecode_append_short_int(code
, cp_add_methodref("javax/microedition/lcdui/Form", "setTitle", "(Ljava/lang/String;)V"));
2387 if (strcmp(name
, "resourceavailable") == 0)
2389 bytecode_append(code
, aconst_null$
);
2390 bytecode_append(code
, if_acmpeq$
);
2391 bytecode_append_short_int(code
, 7);
2393 bytecode_append(code
, iconst_m1$
);
2394 bytecode_append(code
, goto$
);
2395 bytecode_append_short_int(code
, 4);
2397 bytecode_append(code
, iconst_0$
);
2401 if (strcmp(name
, "readbyte") == 0)
2403 bytecode_append(code
, invokestatic$
);
2404 bytecode_append_short_int(code
, cp_add_methodref("S", "rb", "(Ljava/io/InputStream;)I"));
2408 if (strcmp(name
, "readline") == 0)
2410 bytecode_append(code
, invokestatic$
);
2411 bytecode_append_short_int(code
, cp_add_methodref("S", "nl", "(Ljava/io/InputStream;)Ljava/lang/String;"));
2415 if (strcmp(name
, "readrecordstoreentry") == 0)
2417 usesRecordStore
= 1;
2419 bytecode_append(code
, invokestatic$
);
2420 bytecode_append_short_int(code
, cp_add_methodref("RS", "j", "(Ljavax/microedition/rms/RecordStore;I)Ljava/lang/String;"));
2424 if (strcmp(name
, "round") == 0)
2428 method_index
= cp_add_methodref("java/lang/Math", "round", "(F)I");
2430 bytecode_append(code
, invokestatic$
);
2431 bytecode_append_short_int(code
, method_index
);
2436 if (strcmp(name
, "rabs") == 0)
2441 bytecode_append(code
, invokestatic$
);
2442 bytecode_append_short_int(code
, cp_add_methodref("F", "A", "(I)I"));
2446 bytecode_append(code
, new$
);
2447 bytecode_append_short_int(code
, cp_add_class("Real"));
2448 bytecode_append(code
, dup_x1$
);
2449 bytecode_append(code
, swap$
);
2450 bytecode_append(code
, invokespecial$
);
2451 bytecode_append_short_int(code
, cp_add_methodref("Real", "<init>", "(LReal;)V"));
2452 bytecode_append(code
, dup$
);
2453 bytecode_append(code
, invokevirtual$
);
2454 bytecode_append_short_int(code
, cp_add_methodref("Real", "abs", "()V"));
2460 if (strcmp(name
, "randomize") == 0)
2462 /* re-initialize the random number generator */
2463 int random_field_index
;
2464 int random_class_index
;
2465 int random_method_index
;
2467 random_field_index
= cp_add_fieldref("M", "RNG", "Ljava/util/Random;");
2468 random_class_index
= cp_add_class("java/util/Random");
2469 random_method_index
= cp_add_methodref("java/util/Random", "<init>", "()V");
2471 bytecode_append(code
, new$
);
2472 bytecode_append_short_int(code
, random_class_index
);
2474 bytecode_append(code
, dup$
);
2476 bytecode_append(code
, invokespecial$
);
2477 bytecode_append_short_int(code
, random_method_index
);
2479 bytecode_append(code
, putstatic$
);
2480 bytecode_append_short_int(code
, random_field_index
);
2484 if (strcmp(name
, "random") == 0)
2489 rng_index
= cp_add_fieldref("M", "RNG", "Ljava/util/Random;");
2490 method_index
= cp_add_methodref("java/util/Random", "nextInt", "()I");
2492 bytecode_append(code
, getstatic$
);
2493 bytecode_append_short_int(code
, rng_index
);
2495 bytecode_append(code
, invokevirtual$
);
2496 bytecode_append_short_int(code
, method_index
);
2499 bytecode_append(code
, iconst_m1$
);
2500 bytecode_append(code
, iconst_1$
);
2501 bytecode_append(code
, iushr$
);
2502 bytecode_append(code
, iand$
);
2504 bytecode_append(code
, swap$
);
2505 bytecode_append(code
, irem$
);
2510 if (strcmp(name
, "removecommand") == 0)
2512 bytecode_append(code
, getstatic$
);
2513 bytecode_append_short_int(code
, cp_add_fieldref("FW", "CD", "Ljavax/microedition/lcdui/Displayable;"));
2514 bytecode_append(code
, swap$
);
2515 bytecode_append(code
, invokevirtual$
);
2516 bytecode_append_short_int(code
, cp_add_methodref("javax/microedition/lcdui/Displayable", "removeCommand", "(Ljavax/microedition/lcdui/Command;)V"));
2521 if (strcmp(name
, "repaint") == 0)
2526 method_index
= cp_add_methodref("M", "repaint", "()V");
2527 field_index
= cp_add_fieldref("M", "T", "LM;");
2529 bytecode_append(code
, getstatic$
);
2530 bytecode_append_short_int(code
, field_index
);
2532 bytecode_append(code
, dup$
);
2534 bytecode_append(code
, invokevirtual$
);
2535 bytecode_append_short_int(code
, method_index
);
2537 method_index
= cp_add_methodref("M", "serviceRepaints", "()V");
2538 bytecode_append(code
, invokevirtual$
);
2539 bytecode_append_short_int(code
, method_index
);
2545 if (strcmp(name
, "setformtitle") == 0)
2548 bytecode_append(code
, getstatic$
);
2549 bytecode_append_short_int(code
, cp_add_fieldref("FW", "F", "Ljavax/microedition/lcdui/Form;"));
2551 /* set the form's title */
2552 bytecode_append(code
, swap$
);
2553 bytecode_append(code
, invokevirtual$
);
2554 bytecode_append_short_int(code
, cp_add_methodref("javax/microedition/lcdui/Form", "setTitle", "(Ljava/lang/String;)V"));
2559 if (strcmp(name
, "setclip") == 0)
2563 method_index
= cp_add_methodref("javax/microedition/lcdui/Graphics", "setClip", "(IIII)V");
2565 bytecode_append(code
, invokevirtual$
);
2566 bytecode_append_short_int(code
, method_index
);
2571 if (strcmp("smsstartsend", name
) == 0)
2574 bytecode_append(code
, invokestatic$
);
2575 bytecode_append_short_int(code
, cp_add_methodref("SM", "send", "(Ljava/lang/String;Ljava/lang/String;)I"));
2579 if (strcmp("smsissending", name
) == 0)
2582 bytecode_append(code
, invokestatic$
);
2583 bytecode_append_short_int(code
, cp_add_methodref("SM", "IS", "()I"));
2587 if (strcmp("smswassuccessfull", name
) == 0)
2590 bytecode_append(code
, invokestatic$
);
2591 bytecode_append_short_int(code
, cp_add_methodref("SM", "GS", "()I"));
2595 if (strcmp("startplayer", name
) == 0)
2598 bytecode_append(code
, invokestatic$
);
2599 bytecode_append_short_int(code
, cp_add_methodref("P", "a", "()I"));
2603 if (strcmp("stopplayer", name
) == 0)
2606 bytecode_append(code
, invokestatic$
);
2607 bytecode_append_short_int(code
, cp_add_methodref("P", "b", "()V"));
2611 if (strcmp("setplayercount", name
) == 0)
2614 bytecode_append(code
, invokestatic$
);
2615 bytecode_append_short_int(code
, cp_add_methodref("P", "a", "(I)I"));
2619 if (strcmp(name
, "setchar") == 0)
2623 bytecode_append(code
, invokestatic$
);
2624 bytecode_append_short_int(code
, cp_add_methodref("S", "gc", "(Ljava/lang/String;II)Ljava/lang/String;"));
2628 if (strcmp(name
, "sqr") == 0)
2630 bytecode_append(code
, dup$
);
2631 bytecode_append(code
, imul$
);
2636 if (strcmp(name
, "setticker") == 0)
2638 bytecode_append(code
, new$
);
2639 bytecode_append_short_int(code
, cp_add_class("javax/microedition/lcdui/Ticker"));
2640 bytecode_append(code
, dup_x1$
);
2641 bytecode_append(code
, swap$
);
2642 bytecode_append(code
, invokespecial$
);
2643 bytecode_append_short_int(code
, cp_add_methodref("javax/microedition/lcdui/Ticker", "<init>", "(Ljava/lang/String;)V"));
2645 bytecode_append(code
, getstatic$
);
2646 bytecode_append_short_int(code
, cp_add_fieldref("FW", "F", "Ljavax/microedition/lcdui/Form;"));
2648 bytecode_append(code
, swap$
);
2650 bytecode_append(code
, invokevirtual$
);
2651 bytecode_append_short_int(code
, cp_add_methodref("javax/microedition/lcdui/Form", "setTicker", "(Ljavax/microedition/lcdui/Ticker;)V"));
2655 if (strcmp(name
, "stringtointeger") == 0)
2658 bytecode_append(code
, invokestatic$
);
2659 bytecode_append_short_int(code
, cp_add_methodref("S", "parseInt", "(Ljava/lang/String;)I"));
2663 if (strcmp(name
, "stringtoreal") == 0)
2666 //usesRegisteredFeature = 1;
2669 bytecode_append(code
, invokestatic$
);
2670 bytecode_append_short_int(code
, cp_add_methodref("F", "fI", "(Ljava/lang/String;I)I"));
2674 bytecode_append(code
, invokespecial$
);
2675 bytecode_append_short_int(code
, cp_add_methodref("Real", "<init>", "(Ljava/lang/String;I)V"));
2682 if (strcmp(name
, "sqrt") == 0)
2687 bytecode_append(code
, invokestatic$
);
2688 bytecode_append_short_int(code
, cp_add_methodref("F", "S", "(I)I"));
2692 bytecode_append(code
, new$
);
2693 bytecode_append_short_int(code
, cp_add_class("Real"));
2694 bytecode_append(code
, dup_x1$
);
2695 bytecode_append(code
, swap$
);
2696 bytecode_append(code
, invokespecial$
);
2697 bytecode_append_short_int(code
, cp_add_methodref("Real", "<init>", "(LReal;)V"));
2698 bytecode_append(code
, dup$
);
2699 bytecode_append(code
, invokevirtual$
);
2700 bytecode_append_short_int(code
, cp_add_methodref("Real", "sqrt", "()V"));
2706 if (strcmp(name
, "sin") == 0)
2711 bytecode_append(code
, invokestatic$
);
2712 bytecode_append_short_int(code
, cp_add_methodref("F", "s", "(I)I"));
2716 bytecode_append(code
, new$
);
2717 bytecode_append_short_int(code
, cp_add_class("Real"));
2718 bytecode_append(code
, dup_x1$
);
2719 bytecode_append(code
, swap$
);
2720 bytecode_append(code
, invokespecial$
);
2721 bytecode_append_short_int(code
, cp_add_methodref("Real", "<init>", "(LReal;)V"));
2722 bytecode_append(code
, dup$
);
2723 bytecode_append(code
, invokevirtual$
);
2724 bytecode_append_short_int(code
, cp_add_methodref("Real", "sin", "()V"));
2730 if (strcmp(name
, "setcolor") == 0)
2734 method_index
= cp_add_methodref("javax/microedition/lcdui/Graphics", "setColor", "(III)V");
2736 bytecode_append(code
, invokevirtual$
);
2737 bytecode_append_short_int(code
, method_index
);
2744 if (strcmp(name
, "setfont") == 0)
2746 int method_index
= cp_add_methodref("javax/microedition/lcdui/Font", "getFont", "(III)Ljavax/microedition/lcdui/Font;");
2748 bytecode_append(code
, invokestatic$
);
2749 bytecode_append_short_int(code
, method_index
);
2751 method_index
= cp_add_methodref("javax/microedition/lcdui/Graphics", "setFont", "(Ljavax/microedition/lcdui/Font;)V");
2752 bytecode_append(code
, invokevirtual$
);
2753 bytecode_append_short_int(code
, method_index
);
2759 if (strcmp(name
, "setdefaultfont") == 0)
2761 int method_index
= cp_add_methodref("javax/microedition/lcdui/Font", "getDefaultFont", "()Ljavax/microedition/lcdui/Font;");
2763 bytecode_append(code
, invokestatic$
);
2764 bytecode_append_short_int(code
, method_index
);
2766 method_index
= cp_add_methodref("javax/microedition/lcdui/Graphics", "setFont", "(Ljavax/microedition/lcdui/Font;)V");
2767 bytecode_append(code
, invokevirtual$
);
2768 bytecode_append_short_int(code
, method_index
);
2773 if (strcmp(name
, "sethttpmethod") == 0)
2776 bytecode_append(code
, invokevirtual$
);
2777 bytecode_append_short_int(code
, cp_add_methodref("H", "c", "(Ljava/lang/String;)V"));
2781 if (strcmp(name
, "sendhttpmessage") == 0)
2784 bytecode_append(code
, invokevirtual$
);
2785 bytecode_append_short_int(code
, cp_add_methodref("H", "o", "()I"));
2789 if (strcmp(name
, "showform") == 0)
2793 Display.getDisplay(FW.fw).setCurrent(FW.F);
2795 bytecode_append(code
, getstatic$
);
2796 bytecode_append_short_int(code
, cp_add_fieldref("FW", "fw", "LFW;"));
2798 bytecode_append(code
, invokestatic$
);
2799 bytecode_append_short_int(code
, cp_add_methodref("javax/microedition/lcdui/Display", "getDisplay", "(Ljavax/microedition/midlet/MIDlet;)Ljavax/microedition/lcdui/Display;"));
2801 bytecode_append(code
, getstatic$
);
2802 bytecode_append_short_int(code
, cp_add_fieldref("FW", "F", "Ljavax/microedition/lcdui/Form;"));
2804 bytecode_append(code
, invokevirtual$
);
2805 bytecode_append_short_int(code
, cp_add_methodref("javax/microedition/lcdui/Display", "setCurrent", "(Ljavax/microedition/lcdui/Displayable;)V"));
2810 bytecode_append(code
, getstatic$
);
2811 bytecode_append_short_int(code
, cp_add_fieldref("FW", "F", "Ljavax/microedition/lcdui/Form;"));
2813 bytecode_append(code
, putstatic$
);
2814 bytecode_append_short_int(code
, cp_add_fieldref("FW", "CD", "Ljavax/microedition/lcdui/Displayable;"));
2819 if (strcmp(name
, "showcanvas") == 0)
2822 Display.getDisplay(FW.fw).setCurrent(M.T);
2824 bytecode_append(code
, getstatic$
);
2825 bytecode_append_short_int(code
, cp_add_fieldref("FW", "fw", "LFW;"));
2827 bytecode_append(code
, invokestatic$
);
2828 bytecode_append_short_int(code
, cp_add_methodref("javax/microedition/lcdui/Display", "getDisplay", "(Ljavax/microedition/midlet/MIDlet;)Ljavax/microedition/lcdui/Display;"));
2830 bytecode_append(code
, getstatic$
);
2831 bytecode_append_short_int(code
, cp_add_fieldref("M", "T", "LM;"));
2833 bytecode_append(code
, invokevirtual$
);
2834 bytecode_append_short_int(code
, cp_add_methodref("javax/microedition/lcdui/Display", "setCurrent", "(Ljavax/microedition/lcdui/Displayable;)V"));
2839 bytecode_append(code
, getstatic$
);
2840 bytecode_append_short_int(code
, cp_add_fieldref("M", "T", "LM;"));
2842 bytecode_append(code
, putstatic$
);
2843 bytecode_append_short_int(code
, cp_add_fieldref("FW", "CD", "Ljavax/microedition/lcdui/Displayable;"));
2849 if (strcmp(name
, "showtextbox") == 0)
2851 bytecode_append(code
, invokespecial$
);
2852 bytecode_append_short_int(code
, cp_add_methodref("javax/microedition/lcdui/TextBox", "<init>", "(Ljava/lang/String;Ljava/lang/String;II)V"));
2854 bytecode_append(code
, putstatic$
);
2855 bytecode_append_short_int(code
, cp_add_fieldref("FW", "TB", "Ljavax/microedition/lcdui/TextBox;"));
2858 Display.getDisplay(FW.fw).setCurrent(FW.TB);
2860 bytecode_append(code
, getstatic$
);
2861 bytecode_append_short_int(code
, cp_add_fieldref("FW", "fw", "LFW;"));
2863 bytecode_append(code
, invokestatic$
);
2864 bytecode_append_short_int(code
, cp_add_methodref("javax/microedition/lcdui/Display", "getDisplay", "(Ljavax/microedition/midlet/MIDlet;)Ljavax/microedition/lcdui/Display;"));
2866 bytecode_append(code
, getstatic$
);
2867 bytecode_append_short_int(code
, cp_add_fieldref("FW", "TB", "Ljavax/microedition/lcdui/TextBox;"));
2869 bytecode_append(code
, invokevirtual$
);
2870 bytecode_append_short_int(code
, cp_add_methodref("javax/microedition/lcdui/Display", "setCurrent", "(Ljavax/microedition/lcdui/Displayable;)V"));
2875 bytecode_append(code
, getstatic$
);
2876 bytecode_append_short_int(code
, cp_add_fieldref("FW", "TB", "Ljavax/microedition/lcdui/TextBox;"));
2878 bytecode_append(code
, putstatic$
);
2879 bytecode_append_short_int(code
, cp_add_fieldref("FW", "CD", "Ljavax/microedition/lcdui/Displayable;"));
2883 FW.TB.setCommandListener(FW.fw);
2885 bytecode_append(code
, getstatic$
);
2886 bytecode_append_short_int(code
, cp_add_fieldref("FW", "TB", "Ljavax/microedition/lcdui/TextBox;"));
2888 bytecode_append(code
, getstatic$
);
2889 bytecode_append_short_int(code
, cp_add_fieldref("FW", "fw", "LFW;"));
2891 bytecode_append(code
, invokevirtual$
);
2892 bytecode_append_short_int(code
, cp_add_methodref("javax/microedition/lcdui/Displayable", "setCommandListener", "(Ljavax/microedition/lcdui/CommandListener;)V"));
2897 if (strcmp(name
, "showmenu") == 0)
2899 bytecode_append(code
, invokespecial$
);
2900 bytecode_append_short_int(code
, cp_add_methodref("javax/microedition/lcdui/List", "<init>", "(Ljava/lang/String;I)V"));
2902 bytecode_append(code
, putstatic$
);
2903 bytecode_append_short_int(code
, cp_add_fieldref("FW", "L", "Ljavax/microedition/lcdui/List;"));
2906 Display.getDisplay(FW.fw).setCurrent(FW.L);
2908 bytecode_append(code
, getstatic$
);
2909 bytecode_append_short_int(code
, cp_add_fieldref("FW", "fw", "LFW;"));
2911 bytecode_append(code
, invokestatic$
);
2912 bytecode_append_short_int(code
, cp_add_methodref("javax/microedition/lcdui/Display", "getDisplay", "(Ljavax/microedition/midlet/MIDlet;)Ljavax/microedition/lcdui/Display;"));
2914 bytecode_append(code
, getstatic$
);
2915 bytecode_append_short_int(code
, cp_add_fieldref("FW", "L", "Ljavax/microedition/lcdui/List;"));
2917 bytecode_append(code
, invokevirtual$
);
2918 bytecode_append_short_int(code
, cp_add_methodref("javax/microedition/lcdui/Display", "setCurrent", "(Ljavax/microedition/lcdui/Displayable;)V"));
2923 bytecode_append(code
, getstatic$
);
2924 bytecode_append_short_int(code
, cp_add_fieldref("FW", "L", "Ljavax/microedition/lcdui/List;"));
2926 bytecode_append(code
, putstatic$
);
2927 bytecode_append_short_int(code
, cp_add_fieldref("FW", "CD", "Ljavax/microedition/lcdui/Displayable;"));
2931 FW.L.setCommandListener(FW.fw);
2933 bytecode_append(code
, getstatic$
);
2934 bytecode_append_short_int(code
, cp_add_fieldref("FW", "L", "Ljavax/microedition/lcdui/List;"));
2936 bytecode_append(code
, getstatic$
);
2937 bytecode_append_short_int(code
, cp_add_fieldref("FW", "fw", "LFW;"));
2939 bytecode_append(code
, invokevirtual$
);
2940 bytecode_append_short_int(code
, cp_add_methodref("javax/microedition/lcdui/Displayable", "setCommandListener", "(Ljavax/microedition/lcdui/CommandListener;)V"));
2947 if (strcmp(name
, "showalert") == 0)
2949 bytecode_append(code
, invokespecial$
);
2950 bytecode_append_short_int(code
, cp_add_methodref("javax/microedition/lcdui/Alert", "<init>", "(Ljava/lang/String;Ljava/lang/String;Ljavax/microedition/lcdui/Image;Ljavax/microedition/lcdui/AlertType;)V"));
2952 bytecode_append(code
, putstatic$
);
2953 bytecode_append_short_int(code
, cp_add_fieldref("FW", "A", "Ljavax/microedition/lcdui/Alert;"));
2956 Display.getDisplay(FW.fw).setCurrent(FW.A);
2958 bytecode_append(code
, getstatic$
);
2959 bytecode_append_short_int(code
, cp_add_fieldref("FW", "fw", "LFW;"));
2961 bytecode_append(code
, invokestatic$
);
2962 bytecode_append_short_int(code
, cp_add_methodref("javax/microedition/lcdui/Display", "getDisplay", "(Ljavax/microedition/midlet/MIDlet;)Ljavax/microedition/lcdui/Display;"));
2964 bytecode_append(code
, getstatic$
);
2965 bytecode_append_short_int(code
, cp_add_fieldref("FW", "A", "Ljavax/microedition/lcdui/Alert;"));
2967 bytecode_append(code
, invokevirtual$
);
2968 bytecode_append_short_int(code
, cp_add_methodref("javax/microedition/lcdui/Display", "setCurrent", "(Ljavax/microedition/lcdui/Displayable;)V"));
2973 bytecode_append(code
, getstatic$
);
2974 bytecode_append_short_int(code
, cp_add_fieldref("FW", "A", "Ljavax/microedition/lcdui/Alert;"));
2976 bytecode_append(code
, putstatic$
);
2977 bytecode_append_short_int(code
, cp_add_fieldref("FW", "CD", "Ljavax/microedition/lcdui/Displayable;"));
2980 FW.A.setCommandListener(FW.fw);
2982 bytecode_append(code
, getstatic$
);
2983 bytecode_append_short_int(code
, cp_add_fieldref("FW", "A", "Ljavax/microedition/lcdui/Alert;"));
2985 bytecode_append(code
, getstatic$
);
2986 bytecode_append_short_int(code
, cp_add_fieldref("FW", "fw", "LFW;"));
2988 bytecode_append(code
, invokevirtual$
);
2989 bytecode_append_short_int(code
, cp_add_methodref("javax/microedition/lcdui/Alert", "setCommandListener", "(Ljavax/microedition/lcdui/CommandListener;)V"));
2996 if (strcmp(name
, "trunc") == 0)
3001 bytecode_append(code
, invokestatic$
);
3002 bytecode_append_short_int(code
, cp_add_methodref("F", "tI", "(I)I"));
3006 bytecode_append(code
, new$
);
3007 bytecode_append_short_int(code
, cp_add_class("Real"));
3008 bytecode_append(code
, dup_x1$
);
3009 bytecode_append(code
, swap$
);
3010 bytecode_append(code
, invokespecial$
);
3011 bytecode_append_short_int(code
, cp_add_methodref("Real", "<init>", "(LReal;)V"));
3012 bytecode_append(code
, dup$
);
3013 bytecode_append(code
, invokevirtual$
);
3014 bytecode_append_short_int(code
, cp_add_methodref("Real", "trunc", "()V"));
3015 bytecode_append(code
, invokevirtual$
);
3016 bytecode_append_short_int(code
, cp_add_methodref("Real", "toInteger", "()I"));
3023 if (strcmp(name
, "tan") == 0)
3028 bytecode_append(code
, invokestatic$
);
3029 bytecode_append_short_int(code
, cp_add_methodref("F", "tan", "(I)I"));
3033 bytecode_append(code
, new$
);
3034 bytecode_append_short_int(code
, cp_add_class("Real"));
3035 bytecode_append(code
, dup_x1$
);
3036 bytecode_append(code
, swap$
);
3037 bytecode_append(code
, invokespecial$
);
3038 bytecode_append_short_int(code
, cp_add_methodref("Real", "<init>", "(LReal;)V"));
3039 bytecode_append(code
, dup$
);
3040 bytecode_append(code
, invokevirtual$
);
3041 bytecode_append_short_int(code
, cp_add_methodref("Real", "tan", "()V"));
3049 if (strcmp(name
, "todegrees") == 0)
3054 bytecode_append(code
, invokestatic$
);
3055 bytecode_append_short_int(code
, cp_add_methodref("F", "tD", "(I)I"));
3059 bytecode_append(code
, new$
);
3060 bytecode_append_short_int(code
, cp_add_class("Real"));
3061 bytecode_append(code
, dup_x1$
);
3062 bytecode_append(code
, swap$
);
3063 bytecode_append(code
, invokespecial$
);
3064 bytecode_append_short_int(code
, cp_add_methodref("Real", "<init>", "(LReal;)V"));
3066 bytecode_append(code
, dup$
);
3067 bytecode_append(code
, dup$
);
3069 bytecode_append(code
, sipush$
);
3070 bytecode_append_short_int(code
, 180);
3072 bytecode_append(code
, invokevirtual$
);
3073 bytecode_append_short_int(code
, cp_add_methodref("Real", "mul", "(I)V"));
3075 bytecode_append(code
, getstatic$
);
3076 bytecode_append_short_int(code
, cp_add_fieldref("Real", "PI", "LReal;"));
3078 bytecode_append(code
, invokevirtual$
);
3079 bytecode_append_short_int(code
, cp_add_methodref("Real", "div", "(LReal;)V"));
3085 if (strcmp(name
, "toradians") == 0)
3090 bytecode_append(code
, invokestatic$
);
3091 bytecode_append_short_int(code
, cp_add_methodref("F", "tR", "(I)I"));
3095 bytecode_append(code
, new$
);
3096 bytecode_append_short_int(code
, cp_add_class("Real"));
3097 bytecode_append(code
, dup_x1$
);
3098 bytecode_append(code
, swap$
);
3099 bytecode_append(code
, invokespecial$
);
3100 bytecode_append_short_int(code
, cp_add_methodref("Real", "<init>", "(LReal;)V"));
3102 bytecode_append(code
, dup$
);
3103 bytecode_append(code
, dup$
);
3105 bytecode_append(code
, sipush$
);
3106 bytecode_append_short_int(code
, 180);
3108 bytecode_append(code
, invokevirtual$
);
3109 bytecode_append_short_int(code
, cp_add_methodref("Real", "div", "(I)V"));
3111 bytecode_append(code
, getstatic$
);
3112 bytecode_append_short_int(code
, cp_add_fieldref("Real", "PI", "LReal;"));
3114 bytecode_append(code
, invokevirtual$
);
3115 bytecode_append_short_int(code
, cp_add_methodref("Real", "mul", "(LReal;)V"));
3121 if (strcmp(name
, "upcase") == 0)
3127 class_index
= cp_add_class("java/lang/String");
3128 init_index
= cp_add_methodref("java/lang/String", "<init>", "(Ljava/lang/String;)V");
3129 method_index
= cp_add_methodref("java/lang/String", "toUpperCase", "()Ljava/lang/String;");
3131 bytecode_append(code
, new$
);
3132 bytecode_append_short_int(code
, class_index
);
3133 bytecode_append(code
, dup_x1$
);
3134 bytecode_append(code
, swap$
);
3135 bytecode_append(code
, invokespecial$
);
3136 bytecode_append_short_int(code
, init_index
);
3138 bytecode_append(code
, invokevirtual$
);
3139 bytecode_append_short_int(code
, method_index
);
3144 if (strcmp(name
, "vibrate") == 0)
3146 bytecode_append(code
, invokevirtual$
);
3147 bytecode_append_short_int(code
, cp_add_methodref("javax/microedition/lcdui/Display", "vibrate", "(I)Z"));
3149 bytecode_append(code
, pop$
);
3168 Adds a function with 0 or 1 parameter
3170 void add_special_function(block
*item
, enum en_type_class parameter_en
, enum en_type_class return_type_en
, char *name
)
3176 params
= type_list_create();
3177 param
= type_create();
3178 return_type
= type_create();
3179 param
->type_class
= parameter_en
;
3180 return_type
->type_class
= return_type_en
;
3181 if (parameter_en
!= void_type
)
3182 type_list_append(params
, param
);
3183 type_destroy(param
);
3184 if (return_type_en
== void_type
)
3185 add_std_procedure(item
, name
, params
);
3187 add_std_function(item
, name
, params
, return_type
);
3191 Adds a function with 2 parameters
3193 void add_special_function2(block
*item
, enum en_type_class parameter_en1
, enum en_type_class parameter_en2
, enum en_type_class return_type_en
, char *name
)
3199 params
= type_list_create();
3200 param
= type_create();
3201 return_type
= type_create();
3202 param
->type_class
= parameter_en1
;
3203 return_type
->type_class
= return_type_en
;
3204 type_list_append(params
, param
);
3205 param
->type_class
= parameter_en2
;
3206 type_list_append(params
, param
);
3207 type_destroy(param
);
3209 if (return_type_en
== void_type
)
3210 add_std_procedure(item
, name
, params
);
3212 add_std_function(item
, name
, params
, return_type
);
3216 Adds a function with 3 parameters
3218 void add_special_function3(block
*item
, enum en_type_class parameter_en1
, enum en_type_class parameter_en2
, enum en_type_class parameter_en3
, enum en_type_class return_type_en
, char *name
)
3224 params
= type_list_create();
3225 param
= type_create();
3226 return_type
= type_create();
3227 param
->type_class
= parameter_en1
;
3228 return_type
->type_class
= return_type_en
;
3229 type_list_append(params
, param
);
3230 param
->type_class
= parameter_en2
;
3231 type_list_append(params
, param
);
3232 param
->type_class
= parameter_en3
;
3233 type_list_append(params
, param
);
3234 type_destroy(param
);
3236 if (return_type_en
== void_type
)
3237 add_std_procedure(item
, name
, params
);
3239 add_std_function(item
, name
, params
, return_type
);
3243 Adds a function with 4 parameters
3245 void add_special_function4(block
*item
, enum en_type_class parameter_en1
, enum en_type_class parameter_en2
, enum en_type_class parameter_en3
, enum en_type_class parameter_en4
, enum en_type_class return_type_en
, char *name
)
3251 params
= type_list_create();
3252 param
= type_create();
3253 return_type
= type_create();
3254 param
->type_class
= parameter_en1
;
3255 return_type
->type_class
= return_type_en
;
3256 type_list_append(params
, param
);
3257 param
->type_class
= parameter_en2
;
3258 type_list_append(params
, param
);
3259 param
->type_class
= parameter_en3
;
3260 type_list_append(params
, param
);
3261 param
->type_class
= parameter_en4
;
3262 type_list_append(params
, param
);
3263 type_destroy(param
);
3265 if (return_type_en
== void_type
)
3266 add_std_procedure(item
, name
, params
);
3268 add_std_function(item
, name
, params
, return_type
);
3272 Adds a function with 5 parameters
3274 void add_special_function5(block
*item
, enum en_type_class parameter_en1
, enum en_type_class parameter_en2
, enum en_type_class parameter_en3
, enum en_type_class parameter_en4
, enum en_type_class parameter_en5
, enum en_type_class return_type_en
, char *name
)
3280 params
= type_list_create();
3281 param
= type_create();
3282 return_type
= type_create();
3283 param
->type_class
= parameter_en1
;
3284 return_type
->type_class
= return_type_en
;
3285 type_list_append(params
, param
);
3286 param
->type_class
= parameter_en2
;
3287 type_list_append(params
, param
);
3288 param
->type_class
= parameter_en3
;
3289 type_list_append(params
, param
);
3290 param
->type_class
= parameter_en4
;
3291 type_list_append(params
, param
);
3292 param
->type_class
= parameter_en5
;
3293 type_list_append(params
, param
);
3294 type_destroy(param
);
3296 if (return_type_en
== void_type
)
3297 add_std_procedure(item
, name
, params
);
3299 add_std_function(item
, name
, params
, return_type
);
3303 Adds a function with 6 parameters
3305 void add_special_function6(block
*item
, enum en_type_class parameter_en1
, enum en_type_class parameter_en2
, enum en_type_class parameter_en3
, enum en_type_class parameter_en4
, enum en_type_class parameter_en5
, enum en_type_class parameter_en6
, enum en_type_class return_type_en
, char *name
)
3311 params
= type_list_create();
3312 param
= type_create();
3313 return_type
= type_create();
3314 param
->type_class
= parameter_en1
;
3315 return_type
->type_class
= return_type_en
;
3316 type_list_append(params
, param
);
3317 param
->type_class
= parameter_en2
;
3318 type_list_append(params
, param
);
3319 param
->type_class
= parameter_en3
;
3320 type_list_append(params
, param
);
3321 param
->type_class
= parameter_en4
;
3322 type_list_append(params
, param
);
3323 param
->type_class
= parameter_en5
;
3324 type_list_append(params
, param
);
3325 param
->type_class
= parameter_en6
;
3326 type_list_append(params
, param
);
3327 type_destroy(param
);
3329 if (return_type_en
== void_type
)
3330 add_std_procedure(item
, name
, params
);
3332 add_std_function(item
, name
, params
, return_type
);