| ︙ | | |
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
|
137
138
139
140
141
142
143
144
145
146
147
148
149
150
|
-
|
default:
stmt.panic(1, "default token type ("+token.token+") "+stmt.getTokenString(token.token)+" reached in substOneToken().");
obj_ptr = null;
break;
}
if (obj_ptr) {
result_ptr[0] = obj_ptr;
//print("SUBST2!"+obj_ptr.toString()+"!");
return stmt.OK;
}
print("SUBST3 ERROR!");
return stmt.ERROR;
},
|
| ︙ | | |
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
|
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
|
+
-
+
+
+
-
+
-
+
+
+
|
var script;
var token;
var retcode = stmt.OK;
var sargv = null;
var line_no = 0;
var had_comment = false;
stmt.eval_level++;
//print("EVALOBJ!"+script_obj_ptr.toDebugString()+"!");
//print("EVALOBJ level!"+stmt.eval_level+"!"+script_obj_ptr.toString()+"!");
//print("EVALOBJ level!"+stmt.eval_level+"!"+script_obj_ptr.mySelf()+"!");
stmt.interp.error_flag = 0;
/* If the object is of type "list", with no string rep we can call
* a specialized version of evalObj() */
if (script_obj_ptr.isListObj() && script_obj_ptr.bytes == null) {
stmt.eval_level--;
return stmt.evalObjList(script_obj_ptr, stmt.interp.empty_obj, 1);
return stmt.evalObjList(script_obj_ptr, stmt.interp.empty_obj, 1);
}
script_obj_ptr.incrRefCount(); /* Make sure it's shared. */
script = script_obj_ptr.interp.script_obj_type.getScript(script_obj_ptr);
if (script == null) {
stmt.eval_level--;
stmt.interp.setResultString("error in parsing script: \""+script_obj_ptr+"\"");
return stmt.ERROR;
}
/* Reset the interpreter result. This is useful to
* return the empty result in the case of empty program. */
script_obj_ptr.interp.setEmptyResult();
/* Check for one of the following common scripts used by for, while
*
* {}
* incr a
*/
if (script.len == 0) {
stmt.eval_level--;
script_obj_ptr.decrRefCount();
return stmt.OK;
}
if (script.len == 3
&& script.script_object.tokens[1].obj_ptr.obj_type.type_name == "command"
&& script.script_object.tokens[1].obj_ptr.cmdValue.cmdPtr().is_proc == false
&& script.script_object.tokens[1].obj_ptr.cmdValue.cmdPtr().u.native_fcn.cmd_proc == script.interp.incrCoreCommand
&& script.script_object.tokens[2].obj_ptr.obj_typ.type_name == "variable") {
var obj_ptr = stmt.interp.getVariable(script.script_object.tokens[2].obj_ptr, stmt.TOKENNONE);
if (obj_ptr && !obj_ptr.isShared() && obj_ptrobj_type.name == "int") {
// JimWideValue(obj_ptr)++;
obj_ptr.invalidateStringRep();
script_obj_ptr.decrRefCount();
stmt.eval_level--;
stmt.interp.setResult(obj_ptr);
return stmt.OK;
}
}
/* Now we have to make sure the internal repr will not be
* freed on shimmering.
*
|
| ︙ | | |
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
|
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
|
-
+
|
i++;
/* Populate the arguments objects.
* If an error occurs, retcode will be set and
* 'j' will be set to the number of args expanded
*/
had_comment = false;
for (j = 0; j < argc; j++) {
//print("J!"+j+"!"+argc+"!");
//print("J!"+j+"!"+argc+"!"+argv+"!");
var word_tokens = 1;
var expand = 0;
var word_obj_ptr = null;
//print("J!"+j+"!"+script.getTokenString(token[i].token)+"!"+token[i].obj_ptr.toDebugString()+"!");
if (token[i].token == stmt.TOKEN_WORD) {
//script.dumpToken(i);
|
| ︙ | | |
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
|
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
|
+
-
+
+
-
+
+
|
if (retcode == stmt.OK) {
retcode = stmt.ERROR;
}
break;
}
word_obj_ptr.incrRefCount();
if (!expand) {
if (!had_comment) {
argv[j] = word_obj_ptr;
argv.push(word_obj_ptr);
}
} else {
/* Need to expand word_obj_ptr into multiple args from argv[j] ... */
var len = stmt.interp.list_obj_type.listLength(word_obj_ptr);
var newargc = argc + len - 1;
var k;
//print("EXPAND!"+argc+"!"+len+"!"+newargc+"!"+word_obj_ptr.toDebugString()+"!");
/* Now copy in the expanded version */
for (k = 0; k < len; k++) {
argv[j++] = word_obj_ptr.listValue.elem()[k];
argv.push(word_obj_ptr.listValue.elem()[k]);
j++;
word_obj_ptr.listValue.elem()[k].incrRefCount();
}
/* The original object reference is no longer needed,
* after the expansion it is no longer present on
* the argument vector, but the single elements are
* in its place.
*/
|
| ︙ | | |
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
|
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
|
+
-
+
+
|
}
// /* Finished with the command, so decrement ref counts of each argument */
j = argv.length - 1;
for (; j > 0; j--) {
argv[j].decrRefCount();
}
argv = new Array();
}
/* Possibly add to the error stack trace */
stmt.addErrorToStack(retcode, script.script_object.file_name_obj, line_no);
/* Note that we don't have to decrement in_use, because the
* following code transfers our use of the reference again to
* the script object. */
script_obj_ptr.freeIntRep();
script_obj_ptr.obj_type = stmt.interp.script_obj_type;
script_obj_ptr.setIntRepPtr(script);
script_obj_ptr.decrRefCount();
//print("EVALOBJ end level!"+stmt.eval_level+"!"+retcode+"!");
stmt.eval_level--;
return retcode;
},
/* ==================== _evalObjVector ===================================== */
/* Eval the object vector 'objv' composed of 'objc' elements.
* Every element is used as single argument.
* evalObj() will call this function every time its object
|
| ︙ | | |