RAPL

Check-in [91a6cbc019]
Login

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

Overview
Comment:fix for ensemble command call to not change argv, because otherwise we have problems in eval_statement, when freeing argv after the call
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:91a6cbc019b6a2fd077d77047926734736272af1
User & Date: arnulf 2012-03-04 21:19:04
Context
2012-03-04
21:20
init the options within the constructor otherwise we have problems in allocating Rapl Objects as the interp does not yet exist!! check-in: 55b325702b user: arnulf tags: trunk
21:19
fix for ensemble command call to not change argv, because otherwise we have problems in eval_statement, when freeing argv after the call check-in: 91a6cbc019 user: arnulf tags: trunk
2012-02-22
20:52
fixes check-in: ae8f36d6a3 user: arnulf tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to rapl_base.js.

93
94
95
96
97
98
99

100
101
102
103
104
105
106
....
1005
1006
1007
1008
1009
1010
1011


1012
1013
1014
1015
1016

1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029




1030
1031
1032
1033
1034
1035
1036
1037
1038
....
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
....
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
....
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
....
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
....
1383
1384
1385
1386
1387
1388
1389

1390
1391
1392
1393
1394
1395
1396
1397
1398
....
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
  Base.pkg_string_oid = 0;
  Base.pkg_package_oid = 0;
  Base.pkg_info_oid = 0;
  Base.pkg_itcl_oid = 0;
  Base.pkg_tcltest_oid = 0;
  Base.pkg_trace_oid = 0;
  Base.pkg_array_oid = 0;


  Base.my_name = "RaplBase";
  Base.NAME = "base";

  Base.prototype = {
    FUNCTION_FLAGS_NONE: 0,             /* no flags set */
    FUNCTION_FLAGS_LEAVE_ERR_MSG: 1,    /* set an error message in the interpreter. */
................................................................................
    /* ==================== ensembleCommand ===================================== */
    /** Manage subcommands */
    ensembleCommand: function (interp, argv, cmd) {
      var sub;
      var main;
      var result;
      var ens;



      ens = cmd.ensemble;
      while (argv.length > 1) {
        sub  = argv[1].toString();
        main = argv.shift().toString()+" "+sub;

        argv[0] = main;
        if (ens == null || ens[sub] == null) {
          throw "Not an ensemble command 2: "+main;
        }
        result = ens[sub];
        if (result.ensemble == null) {
          if (typeof result.u.native_fcn.cmd_proc != "undefined") {
	    /* found the final command, stop in front of possible arguments */ 
            break;
          }
        }
        ens = result.ensemble;
      }




//print("ensembleCommand 1!"+ens+"!"+result.name+"!"+argv+"!"+argv.length+"!");
      var res = result.call(interp, argv);
//print("ensembleCommand res!"+result.name+"!"+res+"!");
//print("RES!"+typeof res+"!"+(res instanceof TclObject)+"!"+res.value_type+"!"+res.object_oid+"!"+typeof res.value+"!");
      return res
    },

    /* ==================== infoSubcommands ===================================== */
    /** Get subcommands of the current ensemble command. */
................................................................................

      if (args.length < 4 || args.length % 2 != 0) {
        interp.wrongNumArgs(1, args, "varList list ?varList list ...? script");
        return interp.ERROR;
      }
      if (do_map) {
        map_res = interp.list_obj_type.newListObj(null, 0);
        map_res.incrRefCount();
      }
      empty_str = interp.string_obj_type.newEmptyStringObj();
      empty_str.incrRefCount();
      script = args[args.length - 1];    /* Last argument is a script */
      nbr_of_lists = (args.length - 1 - 1) / 2;    /* args.length - 'foreach' - script */
      lists_idx = new Array();
      lists_end = new Array();
      /* Initialize iterators and remember max nbr elements each list */
      for (i = 0; i < nbr_of_lists * 2; i++) {
        lists_idx[i] = 0;
................................................................................
              /* List index operations below can't fail */
              interp.list_obj_type.listIndex(args[vr + 1], var_idx, var_name, interp.FUNCTION_FLAGS_NONE);
	      var_name = var_name[0];
              if (lists_idx[i] < lists_end[lst]) {
                interp.list_obj_type.listIndex(args[lst + 1], lists_idx[i], elem, interp.FUNCTION_FLAGS_NONE);
	        elem = elem[0];
                /* Avoid shimmering */
                elem.incrRefCount();
                result = interp.variable_obj_type.setVariable(var_name, elem);
                elem.decrRefCount();
                if (result == interp.OK) {
                  ++lists_idx[i];  /* Remember next iterator of current list */
                  ++var_idx;       /* Next variable */
                  continue;
                }
              } else {
                if (interp.variable_obj_type.setVariable(var_name, empty_str) == interp.OK) {
................................................................................
        if (do_map) {
          interp.setResult(map_res);
        } else {
          interp.setEmptyResult();
        }
      }
      if (do_map) {
        map_res.decrRefCount();
      }
      empty_str.decrRefCount();
//      list_idx.free();
//      lists_end.free();
      return result;
    },

    /* ==================== source ===================================== */
    source: function (interp, url) {
................................................................................
//      }
        if (xhr_object == null) {
          if(typeof interp.win.XMLHttpRequest != "undefined") { // Firefox
            xhr_object = new XMLHttpRequest();
          } else { // XMLHttpRequest not supported by the browser
            if (typeof readFile == "function") {
	      responseText = readFile(url);
              var result = interp.eval_statement.evalObj(interp.string_obj_type.newStringObj(responseText), -1);
              return result
            } else {
              print("Your browser does not support XMLHTTP requests. " +
                    "Sorry that we cannot deliver this page.");
              return;
            }
          }
................................................................................
        if (typeof read == "function") {
          read_fcn = read;
	}
        if (read_fcn != null) {
//print("source rhino2!"+url+"!"+interp.current_namespace.full_name+"!");
          result = "";
          responseText = read_fcn(url);

//print("responseText!"+responseText+"!");
          script = interp.string_obj_type.newStringObj("::set dir "+interp.current_dir+"\n"+responseText, -1);
//print("SOURCE!"+script.len+"!"+url+"!"+script.toDebugString()+"!");
          try {
            result = interp.eval_statement.evalObj(script);
          } catch(e) {
print("SOURCE1!e!"+e+"!"+script.getString()+"!");
          }
//print("SOURCE END1!"+result+"!");
................................................................................
          return result;
        }
      }
//console.log("SOURCE!"+url+"!"+interp.xhr_object+"!");
      interp.xhr_object.open("GET", url, false);
      interp.xhr_object.send();
      responseText = "::set dir "+interp.current_dir+"\n"+interp.xhr_object.responseText.toString();
      my_obj_ptr = interp.string_obj_type.newStringObj(responseText, -1);
      my_obj_ptr.incrRefCount();
      result = interp.eval_statement.evalObj(my_obj_ptr);
//print("SOURCE END2!"+result+"!"+my_obj_ptr.getString().substring(0, 80)+"!");
      my_obj_ptr.decrRefCount();
      return result;
    },

    /* ==================== showProps ============================== */
    showProps: function(val) {
      print("props!");
      for (var z in val) {







>







 







>
>


|
|
|
>
|












>
>
>
>
|
|







 







|


|







 







|

|







 







|

|







 







|







 







>

|







 







|
|


|







93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
....
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
....
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
....
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
....
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
....
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
....
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
....
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
  Base.pkg_string_oid = 0;
  Base.pkg_package_oid = 0;
  Base.pkg_info_oid = 0;
  Base.pkg_itcl_oid = 0;
  Base.pkg_tcltest_oid = 0;
  Base.pkg_trace_oid = 0;
  Base.pkg_array_oid = 0;
  Base.free_objs = 0;

  Base.my_name = "RaplBase";
  Base.NAME = "base";

  Base.prototype = {
    FUNCTION_FLAGS_NONE: 0,             /* no flags set */
    FUNCTION_FLAGS_LEAVE_ERR_MSG: 1,    /* set an error message in the interpreter. */
................................................................................
    /* ==================== ensembleCommand ===================================== */
    /** Manage subcommands */
    ensembleCommand: function (interp, argv, cmd) {
      var sub;
      var main;
      var result;
      var ens;
      var idx = 0;
      var my_argv = new Array();

      ens = cmd.ensemble;
      while (idx < argv.length - 1) {
        sub  = argv[idx + 1].getString();
        main = argv[idx].getString()+" "+sub;
	idx ++;
        my_argv[0] = main;
        if (ens == null || ens[sub] == null) {
          throw "Not an ensemble command 2: "+main;
        }
        result = ens[sub];
        if (result.ensemble == null) {
          if (typeof result.u.native_fcn.cmd_proc != "undefined") {
	    /* found the final command, stop in front of possible arguments */ 
            break;
          }
        }
        ens = result.ensemble;
      }
      idx ++;
      for (; idx < argv.length; idx++) {
        my_argv.push(argv[idx]);
      }
//print("ensembleCommand 1!"+ens+"!"+result.name+"!"+my_argv+"!"+my_argv.length+"!");
      var res = result.call(interp, my_argv);
//print("ensembleCommand res!"+result.name+"!"+res+"!");
//print("RES!"+typeof res+"!"+(res instanceof TclObject)+"!"+res.value_type+"!"+res.object_oid+"!"+typeof res.value+"!");
      return res
    },

    /* ==================== infoSubcommands ===================================== */
    /** Get subcommands of the current ensemble command. */
................................................................................

      if (args.length < 4 || args.length % 2 != 0) {
        interp.wrongNumArgs(1, args, "varList list ?varList list ...? script");
        return interp.ERROR;
      }
      if (do_map) {
        map_res = interp.list_obj_type.newListObj(null, 0);
        map_res.incrRefCount("I_BASE_1");
      }
      empty_str = interp.string_obj_type.newEmptyStringObj();
      empty_str.incrRefCount("I_BASE_2");
      script = args[args.length - 1];    /* Last argument is a script */
      nbr_of_lists = (args.length - 1 - 1) / 2;    /* args.length - 'foreach' - script */
      lists_idx = new Array();
      lists_end = new Array();
      /* Initialize iterators and remember max nbr elements each list */
      for (i = 0; i < nbr_of_lists * 2; i++) {
        lists_idx[i] = 0;
................................................................................
              /* List index operations below can't fail */
              interp.list_obj_type.listIndex(args[vr + 1], var_idx, var_name, interp.FUNCTION_FLAGS_NONE);
	      var_name = var_name[0];
              if (lists_idx[i] < lists_end[lst]) {
                interp.list_obj_type.listIndex(args[lst + 1], lists_idx[i], elem, interp.FUNCTION_FLAGS_NONE);
	        elem = elem[0];
                /* Avoid shimmering */
                elem.incrRefCount("I_BASE_3");
                result = interp.variable_obj_type.setVariable(var_name, elem);
                elem.decrRefCount("D_BASE_1");
                if (result == interp.OK) {
                  ++lists_idx[i];  /* Remember next iterator of current list */
                  ++var_idx;       /* Next variable */
                  continue;
                }
              } else {
                if (interp.variable_obj_type.setVariable(var_name, empty_str) == interp.OK) {
................................................................................
        if (do_map) {
          interp.setResult(map_res);
        } else {
          interp.setEmptyResult();
        }
      }
      if (do_map) {
        map_res.decrRefCount("D_BASE_2");
      }
      empty_str.decrRefCount("D_BASE_3");
//      list_idx.free();
//      lists_end.free();
      return result;
    },

    /* ==================== source ===================================== */
    source: function (interp, url) {
................................................................................
//      }
        if (xhr_object == null) {
          if(typeof interp.win.XMLHttpRequest != "undefined") { // Firefox
            xhr_object = new XMLHttpRequest();
          } else { // XMLHttpRequest not supported by the browser
            if (typeof readFile == "function") {
	      responseText = readFile(url);
              var result = interp.eval_statement.evalObj(interp.string_obj_type.newStringObj(responseText, -1, "BASE_1"));
              return result
            } else {
              print("Your browser does not support XMLHTTP requests. " +
                    "Sorry that we cannot deliver this page.");
              return;
            }
          }
................................................................................
        if (typeof read == "function") {
          read_fcn = read;
	}
        if (read_fcn != null) {
//print("source rhino2!"+url+"!"+interp.current_namespace.full_name+"!");
          result = "";
          responseText = read_fcn(url);
//print("source!"+url+"!"+responseText+"!");
//print("responseText!"+responseText+"!");
          script = interp.string_obj_type.newStringObj("::set dir "+interp.current_dir+"\n"+responseText, -1, "BASE_2");
//print("SOURCE!"+script.len+"!"+url+"!"+script.toDebugString()+"!");
          try {
            result = interp.eval_statement.evalObj(script);
          } catch(e) {
print("SOURCE1!e!"+e+"!"+script.getString()+"!");
          }
//print("SOURCE END1!"+result+"!");
................................................................................
          return result;
        }
      }
//console.log("SOURCE!"+url+"!"+interp.xhr_object+"!");
      interp.xhr_object.open("GET", url, false);
      interp.xhr_object.send();
      responseText = "::set dir "+interp.current_dir+"\n"+interp.xhr_object.responseText.toString();
      my_obj_ptr = interp.string_obj_type.newStringObj(responseText, -1, "BASE_3");
      my_obj_ptr.incrRefCount("I_BASE_4");
      result = interp.eval_statement.evalObj(my_obj_ptr);
//print("SOURCE END2!"+result+"!"+my_obj_ptr.getString().substring(0, 80)+"!");
      my_obj_ptr.decrRefCount("D_BASE_4");
      return result;
    },

    /* ==================== showProps ============================== */
    showProps: function(val) {
      print("props!");
      for (var z in val) {