RAPL

Diff
Login

Diff

Differences From Artifact [41ac670b41]:

To Artifact [62bee9d300]:


188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
    if(interp.code == this.BREAK || interp.code == this.CONTINUE)
      interp.code = this.OK;
    return "";
  });

  /* ==================== command foreach ===================================== */
  interp.registerCommand("::foreach", function (interp, args) {
    args.shift();
    this.requireExactArgc(args, 3, "foreach", "");
    var var_list = args.shift()
    var_list = var_list.toList();
    var list = args.shift();
    list = list.toList();
    var body = args.shift();
    var res  = "";
    interp.eval_statement.inLoop = true;
    interp.eval_statement.code = this.OK;
    var i = 0;
    while (i < list.length) {
       for (var j = 0; j < var_list.length; j++) {
           var var_name = var_list[j];
	   var var_value = "";
	   if (i < list.length) {
	       var_value = list[i];
	       i++;
	   }
           interp.setVar(var_name,interp.statement_parser.objectify(var_value));
       }
       res = interp.eval_statement.eval(body);
       if(interp.eval_statement.code == this.BREAK) {
         break;
       }
       if(interp.eval_statement.code == this.RETURN) {
         break;
       }
       if(interp.eval_statement.code == this.CONTINUE) {
         continue;
       }
    }
    interp.eval_statement.inLoop = false;
    if(interp.eval_statement.code == this.BREAK || interp.eval_statement.code == this.CONTINUE) {
      interp.eval_statement.code = this.OK;
    }
    return res;
  });

  /* ==================== command format ===================================== */
  interp.registerCommand("::format", function (interp, args) {
    this.requireMinArgc(args, 2, "format", "");
    throw "format not yet implemented";
  });







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







188
189
190
191
192
193
194




































195
196
197
198
199
200
201
202
    if(interp.code == this.BREAK || interp.code == this.CONTINUE)
      interp.code = this.OK;
    return "";
  });

  /* ==================== command foreach ===================================== */
  interp.registerCommand("::foreach", function (interp, args) {




































    return interp.foreachMapHelper(interp, args, 0);
  });

  /* ==================== command format ===================================== */
  interp.registerCommand("::format", function (interp, args) {
    this.requireMinArgc(args, 2, "format", "");
    throw "format not yet implemented";
  });
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592




593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615

616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
    this.requireExactArgc(args, 3, "rename", "");
    interp.renameCommand(args[1], args[2]);
  });

  /* ==================== command return ===================================== */
  interp.registerCommand("::return", function (interp, args) {
//print("return!"+args+"!");
    /* strip of the command name at the beginning */
    args.shift();
    this.requireMinArgc(args, 0, "return", "");
    var errorcode = null;
    var errorinfo = null;
    var level = null;
    var options = null;
    var allowed_codes = new Object();




    allowed_codes["ok"] = 0;
    allowed_codes["error"] = 1;
    allowed_codes["return"] = 2;
    allowed_codes["break"] = 3;
    allowed_codes["continue"] = 4;
    allowed_codes["0"] = 0;
    allowed_codes["1"] = 1;
    allowed_codes["2"] = 2;
    allowed_codes["3"] = 3;
    allowed_codes["4"] = 4;
    var allowed_options = new Object();
    allowed_options["-code"] = 1;
    allowed_options["-errorcode"] = 1;
    allowed_options["-errorinfo"] = 1;
    allowed_options["-level"] = 1;
    allowed_options["-options"] = 1;
    interp.eval_statement.code = this.RETURN;
    var r = "";
    if (args.length == 1) {
      /* seems to be a return value only */
      r = args.shift();
    }
    var options = this.GetOptions(allowed_options, "::return", args);

    for (i = 0; i < this.numOptionFields; i++) {
      args.shift();
    }
    if (args.length > 1) {
      throw "usage: return ?option value ...? ?result?"
    }
    if (args.length > 0) {
      r = args.shift();
    }
    if (typeof options["-errorcode"] != "undefined") {
        errorcode = options["-errorcode"] ;
	throw "return -errorcode not yet implemented"
    }
    if (typeof options["-code"] != "undefined") {
        code = options["-code"];
        if (typeof allowed_codes[code] == "undefined") {
          throw "bad code \""+code+"\" for -code option in return"
        }
	interp.eval_statement.code = allowed_codes[code];
	if (interp.code == this.ERROR) {
	  this.SetErrorCode(interp, r);
          throw r;
	}
    }
    if (typeof options["-errorinfo"] != "undefined") {
        errorinfo = options["-errorinfo"] ;
	throw "return -errorinfo not yet implemented"
    }
    if (typeof options["-level"] != "undefined") {
        level = options["-level"];
	throw "return -level not yet implemented"
    }
    if (typeof options["-options"] != "undefined") {
        options = options["-options"];
	throw "return -options not yet implemented"
    }
    return r;
  });

  /* ==================== command scan ===================================== */
  interp.registerCommand("::scan", function (interp, args) {
    this.requireMinArgc(args, 2, "scan", "");







<
<
<





>
>
>
>










<





|





|
>
|









|
|


|
|
|
|
|
|
|
|
|


|
|


|
|


|
|







542
543
544
545
546
547
548



549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567

568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
    this.requireExactArgc(args, 3, "rename", "");
    interp.renameCommand(args[1], args[2]);
  });

  /* ==================== command return ===================================== */
  interp.registerCommand("::return", function (interp, args) {
//print("return!"+args+"!");



    var errorcode = null;
    var errorinfo = null;
    var level = null;
    var options = null;
    var allowed_codes = new Object();
    var allowed_options = new Object();
    var num_option_fields = new Array();
    var num_options = new Array();

    allowed_codes["ok"] = 0;
    allowed_codes["error"] = 1;
    allowed_codes["return"] = 2;
    allowed_codes["break"] = 3;
    allowed_codes["continue"] = 4;
    allowed_codes["0"] = 0;
    allowed_codes["1"] = 1;
    allowed_codes["2"] = 2;
    allowed_codes["3"] = 3;
    allowed_codes["4"] = 4;

    allowed_options["-code"] = 1;
    allowed_options["-errorcode"] = 1;
    allowed_options["-errorinfo"] = 1;
    allowed_options["-level"] = 1;
    allowed_options["-options"] = 1;
    interp.eval_statement.code = interp.RETURN;
    var r = "";
    if (args.length == 1) {
      /* seems to be a return value only */
      r = args.shift();
    }
    var options = interp.getOptions(allowed_options, "::return", args, num_option_fields, num_options);
    num_option_fields = num_option_fields[0];
    for (i = 0; i < num_option_fields; i++) {
      args.shift();
    }
    if (args.length > 1) {
      throw "usage: return ?option value ...? ?result?"
    }
    if (args.length > 0) {
      r = args.shift();
    }
    if (typeof options["-errorcode"] != "undefined") {
      errorcode = options["-errorcode"] ;
      throw "return -errorcode not yet implemented"
    }
    if (typeof options["-code"] != "undefined") {
      code = options["-code"];
      if (typeof allowed_codes[code] == "undefined") {
        throw "bad code \""+code+"\" for -code option in return"
      }
      interp.eval_statement.code = allowed_codes[code];
      if (interp.code == interp.ERROR) {
        interp.setErrorCode(r);
        throw r;
      }
    }
    if (typeof options["-errorinfo"] != "undefined") {
      errorinfo = options["-errorinfo"] ;
      throw "return -errorinfo not yet implemented"
    }
    if (typeof options["-level"] != "undefined") {
      level = options["-level"];
      throw "return -level not yet implemented"
    }
    if (typeof options["-options"] != "undefined") {
      options = options["-options"];
      throw "return -options not yet implemented"
    }
    return r;
  });

  /* ==================== command scan ===================================== */
  interp.registerCommand("::scan", function (interp, args) {
    this.requireMinArgc(args, 2, "scan", "");