RAPL

Check-in [3015a81095]
Login

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

Overview
Comment:fixes and removed unused or duplicate code
Timelines: family | ancestors | trunk
Files: files | file ages | folders
SHA1:3015a81095458915bb0f8809289fa84e2e39f52d
User & Date: arnulf 2012-04-13 20:55:17
Context
2012-04-13
20:55
fixes and removed unused or duplicate code Leaf check-in: 3015a81095 user: arnulf tags: trunk
07:28
fixes check-in: d367592391 user: arnulf tags: trunk
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to rapl_parse.js.

792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
....
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
      }
      parse.feedchar();
    }
    parse.parse_info.end = parse.parse_info.index - 1;
    return parse.OK;
  },

  /* ==================== parseParen ===================================== */
  parseParen: function () {
    var parse = this;
    var level = 1;
    parse.feedcharstart();
    while (true) {
      if (parse.parse_info.len > 1 && parse.parse_info.cur == "\\") {
        parse.feedSequence();
      } else {
	if ((parse.parse_info.len == 0) || (parse.parse_info.cur == ")")) {
          level--;
          if (level == 0 || parse.parse_info.len == 0) {
            parse.parse_info.end = parse.parse_info.index - 1;
            if (parse.parse_info.len > 0) {
	      parse.feedchar();
              parse.parse_info.token = parse.TOKEN_LP;
	    }
if (parse.debug) {
print("  parseParen!"+parse.getText()+"!"+parse.parse_info.text.charAt(parse.parse_info.index)+"!"+parse.parse_info.cur+"!");
}
            return parse.OK;
          }
        } else {
	  if (parse.parse_info.cur == "(") {
	    level++;
	  }
	}
      }
      parse.feedchar();
    }
    return parse.OK; // unreached
  },

  /* ==================== parseSubstStr ================================== */
  parseSubstStr: function() {
    var parse = this;

    parse.parse_info.start = parse.parse_info.index;
    parse.parse_info.line = parse.parse_info.line_no;
    while (parse.parse_info.len && parse.parse_info.cur != '$' && parse.parse_info.cur != '[') {
................................................................................
  getText: function () {
    var parse = this;
//print("getText!"+parse.getTokenString(parse.parse_info.token)+"!");
//print("getText text!"+parse.parse_info.text.substring(parse.parse_info.start,parse.parse_info.end+1)+"!type!"+parse.getTokenString(parse.parse_info.token)+"!");
      return parse.parse_info.text.substring(parse.parse_info.start, parse.parse_info.end + 1);
  },

  /* ==================== feedSequence ===================================== */
  feedSequence: function () {
    var parse = this;
    if (parse.parse_info.cur != "\\") {
      throw "Invalid escape sequence";
    }
    var cur = parse.steal(1);
    var specials = new Object();
    specials.a = "\a";
    specials.b = "\b";
    specials.f = "\f";
    specials.n = "\n";
    specials.r = "\r";
    specials.t = "\t";
    specials.v = "\v";
    switch (cur) {
    case 'u':
      var hex = parse.steal(4);
      if (hex != parse.isHexSeq.exec(hex)) {
        throw "Invalid unicode escape sequence: "+hex;
      }
      cur = String.fromCharCode(parseInt(hex,16));
      break;
    case 'x':
      var hex = parse.steal(2);
      if (hex != parse.isHexSeq.exec(hex)) {
        throw "Invalid unicode escape sequence: "+hex;
      }
      cur = String.fromCharCode(parseInt(hex,16));
      break;
    case "a":
    case "b":
    case "f":
    case "n":
    case "r":
    case "t":
    case "v":
      cur = specials[cur];
      break;
    case "\n":
//print("FEED escaped LF1!"+parse.parse_info.text.substring(parse.index)+"!"+parse.parse_info.text+"!");
      var tail = parse.parse_info.text.substring(parse.index+1);
      var head = parse.parse_info.text.substring(0,parse.index-1);
      parse.parse_info.parse_info.text = head+" "+tail;
      parse.parse_info.len--;
      parse.parse_info.cur = parse.parse_info.text.charAt(parse.parse_info.index);
//print("FEED escaped LF2!"+parse.parse_info.cur+"!"+parse.parse_info.text.substring(parse.parse_info.index)+"!"+parse.parse_info.text+"!");
      return;
    default:
      if ("0123456789".indexOf(cur) >= 0) {
        cur = cur + parse.steal(2);
        if (cur != parse.isOctalSeq.exec(cur)) {
          throw "Invalid octal escape sequence: "+cur;
	}
        cur = String.fromCharCode(parseInt(cur, 8));
      }
      break;
    }
    var head = parse.parse_info.text.substring(0, parse.parse_info.index);
    var tail = parse.parse_info.text.substring(parse.parse_info.index + 1);
    parse.parse_info.text = head+cur+tail;
    parse.parse_info.cur = parse.parse_info.text.charAt(parse.parse_info.index);
  },

  /* ==================== steal ===================================== */
  steal: function (n) {
    var parse = this;
    var tail = parse.parse_info.text.substring(parse.parse_info.index+1);
    var word = tail.substr(0, n);
    parse.parse_info.text = parse.parse_info.text.substring(0, parse.parse_info.index) + tail.substring(n-1);
    parse.parse_info.len = parse.parse_info.len - n;
    return word;
  },

  /* ==================== feedcharstart ===================================== */
  feedcharstart: function () {
    var parse = this;
    parse.feedchar();
    parse.parse_info.start = parse.parse_info.index;
  },








<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







 







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







792
793
794
795
796
797
798

































799
800
801
802
803
804
805
....
1071
1072
1073
1074
1075
1076
1077










































































1078
1079
1080
1081
1082
1083
1084
      }
      parse.feedchar();
    }
    parse.parse_info.end = parse.parse_info.index - 1;
    return parse.OK;
  },


































  /* ==================== parseSubstStr ================================== */
  parseSubstStr: function() {
    var parse = this;

    parse.parse_info.start = parse.parse_info.index;
    parse.parse_info.line = parse.parse_info.line_no;
    while (parse.parse_info.len && parse.parse_info.cur != '$' && parse.parse_info.cur != '[') {
................................................................................
  getText: function () {
    var parse = this;
//print("getText!"+parse.getTokenString(parse.parse_info.token)+"!");
//print("getText text!"+parse.parse_info.text.substring(parse.parse_info.start,parse.parse_info.end+1)+"!type!"+parse.getTokenString(parse.parse_info.token)+"!");
      return parse.parse_info.text.substring(parse.parse_info.start, parse.parse_info.end + 1);
  },











































































  /* ==================== feedcharstart ===================================== */
  feedcharstart: function () {
    var parse = this;
    parse.feedchar();
    parse.parse_info.start = parse.parse_info.index;
  },

Changes to rapl_pkg_corecmd.js.

1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
    var var_value_ptr;
    var i;
    var result;
    var var_name_ptr;
    var tail_ptr;

    if (args.length < 2) {
      interp.wrongNumArgs(interp, 1, args, "variable ?value variable value ...?");
      return interp.ERROR;
    }
    for (i = 1 ; i < args.length ; i += 2) {
      /*
       * Look up each variable in the current namespace context, creating it
       * if necessary.
       */
      var_name_ptr = args[i];
      var_name = var_name_ptr.getString();
      var_ptr = interp.variable_obj_type.objLookupVarEx(var_name_ptr, null,
        (interp.NAMESPACE_ONLY | interp.FUNCTION_FLAGS_LEAVE_ERR_MSG), "define",
        /*createPart1*/ 1, /*createPart2*/ 0, array_ptr);
      if (array_ptr[0] != null) {
        /*
         * Variable cannot be an element in an array. If arrayPtr is
         * non-NULL, it is, so throw up an error and return.
         */
        interp.objVarErrMsg(var_name_ptr, null, "define", is_array_element, -1);







|










|







1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
    var var_value_ptr;
    var i;
    var result;
    var var_name_ptr;
    var tail_ptr;

    if (args.length < 2) {
      interp.wrongNumArgs(1, args, "variable ?value variable value ...?");
      return interp.ERROR;
    }
    for (i = 1 ; i < args.length ; i += 2) {
      /*
       * Look up each variable in the current namespace context, creating it
       * if necessary.
       */
      var_name_ptr = args[i];
      var_name = var_name_ptr.getString();
      var_ptr = interp.variable_obj_type.objLookupVarEx(var_name_ptr, null,
        (interp.NAMESPACE_LOOKUP_NAMESPACE_ONLY | interp.FUNCTION_FLAGS_LEAVE_ERR_MSG), "define",
        /*createPart1*/ 1, /*createPart2*/ 0, array_ptr);
      if (array_ptr[0] != null) {
        /*
         * Variable cannot be an element in an array. If arrayPtr is
         * non-NULL, it is, so throw up an error and return.
         */
        interp.objVarErrMsg(var_name_ptr, null, "define", is_array_element, -1);

Changes to rapl_variable_obj_type.js.

1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
....
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
....
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
1896
1897
1898
1899
1900
1901
1902
1903
    while (local_var_name_handling && !done_part1 && !done_parsing) {
      if (obj_type == varbl.interp.local_var_name_obj_type) {
        var local_index;

	local_var_name_handling = false;
        local_index = part1_ptr.ptrAndLongRep.value();
        if (var_framePtr.hasLocalVars()
	  && !(flags & (varbl.FUNCTION_FLAGS_GLOBAL_ONLY | varbl.FUNCTION_FLAGS_NAMESPACE_ONLY))
	  && (local_index < var_frame_ptr.num_compiled_locals)) {
          /*
           * Use the cached index if the names coincide.
           */
          var name_ptr = part1_ptr.ptrAndLongRep.ptr();
          check_name_ptr = localName(varbl.interp.var_frame_ptr, local_index);
          if ((!name_ptr && (check_name_ptr == part1_ptr)) || (name_ptr && (check_name_ptr == name_ptr))) {
................................................................................
	      if (flags & varbl.FUNCTION_FLAGS_LEAVE_ERR_MSG) {
	        varbl.interp.objVarErrMsg(part1_ptr, part2_ptr, msg, no_such_var, -1);
	        varbl.setErrorCode(["TCL", "VALUE", "VARNAME"]);
	      }
	      return null;
            }
            part2 = part1_ptr.twoPtrValue.ptr2();
            new_part2 = part2
            if (new_part2) {
              part2_Ptr = varbl.interp.default_obj.string_obj_type.newStringObj(new_Part2, -1, "VARIABLE_OBJ_TYPE_14");
              part2_ptr.incrRefCount("I_VARIABLE_OBJ_TYPE_16");
            }
            part1_ptr = part1_ptr.twoPtrValue.ptr1();
            obj_type = part1_ptr.obj_type;
            if (obj_type == varbl.interp.local_var_name_obj_type) {
              local_var_name_type_handling = true;
            }
          }
          if (!local_var_name_type_handling) {
            parsed = 1;
          }
        }
      }
    }
    if (!done_part1 && !done_parsing) {
      part1 = part1_ptr.getString();
................................................................................
    res_ptr = varbl.objLookupVarEx(part1_ptr, part2_ptr, flags, msg, create_part1, create_part2, array_ptr);
    if (part2_ptr) {
      part2_ptr.decrRefCount("D_VARIABLE_OBJ_TYPE_16");
    }
    return res_ptr;
  },

  /* ==================== unsetVariable ================================== */
  /* Unset a variable.
   * Note: On success unset invalidates all the variable objects created
   * in the current call frame incrementing. 
   */
  unsetVariable: function(name_obj_ptr, flags) {
    var varbl = this;
    var intp = varbl.interp;
    var obj = intp.default_obj;
    var name;
    var var_ptr;
    var retval;

    retval = varbl.setFromAny(name_obj_ptr);
    if (retval == varbl.TOKEN_VAR_ARRAY_NAME) {
      /* [dict] syntax sugar. */
      return JimDictSugarSet(interp, name_obj_ptr, null);
    } else {
      if (retval == varbl.OK) {
        var_ptr = name_obj_ptr.varValue.varPtr();
        /* If it's a link call UnsetVariable recursively */
        if (var_ptr.link_frame_ptr) {
          var savedCallFrame;

          saved_call_frame = intp.frame_ptr;
          intp.frame_ptr = var_ptr.link_frame_ptr;
          retval = varbl.unsetVariable(var_ptr.obj_ptr, varbl.FUNCTION_FLAGS_NONE);
          intp.frame_ptr = saved_call_frame;
        } else {
          var frame_ptr = intp.frame_ptr;

          name = name_obj_ptr.getString();
          if (name.charAt(0) == ':' && name.charAt(1) == ':') {
            frame_ptr = intp.eval_statement.top_frame_ptr;
            name += 2;
          }
          retval = Jim_DeleteHashEntry(frame_ptr.vars, name);
          if (retval == varbl.OK) {
            /* Change the call_frame id, invalidating var lookup caching */
            JimChangeCallFrameId(frame_ptr);
          }
        }
      }
    }
    if (retval != varbl.OK && (flags & varbl.FUNCTION_FLAGS_LEAVE_ERR_MSG)) {
      varbl.setResultFormatted("can't unset \""+name_obj_ptr.getString()+"\": no such variable");
    }
    return retval;
  },

  /* ==================== handleVariableTrace ===================================== */
  handleVariableTrace: function(name_obj_ptr, part, op, op_str, my_var_ptr) {
    var varbl = this;
    var rc = varbl.OK;
    var save_no_trace;

    if (typeof name_obj_ptr.varValue == "undefined") {







|







 







|

|





|


|







 







<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<
<







1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
....
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
....
1840
1841
1842
1843
1844
1845
1846


















































1847
1848
1849
1850
1851
1852
1853
    while (local_var_name_handling && !done_part1 && !done_parsing) {
      if (obj_type == varbl.interp.local_var_name_obj_type) {
        var local_index;

	local_var_name_handling = false;
        local_index = part1_ptr.ptrAndLongRep.value();
        if (var_framePtr.hasLocalVars()
	  && !(flags & (varbl.NAMESPACE_LOOKUP_GLOBAL_ONLY | varbl.NAMESPACE_LOOKUP_NAMESPACE_ONLY))
	  && (local_index < var_frame_ptr.num_compiled_locals)) {
          /*
           * Use the cached index if the names coincide.
           */
          var name_ptr = part1_ptr.ptrAndLongRep.ptr();
          check_name_ptr = localName(varbl.interp.var_frame_ptr, local_index);
          if ((!name_ptr && (check_name_ptr == part1_ptr)) || (name_ptr && (check_name_ptr == name_ptr))) {
................................................................................
	      if (flags & varbl.FUNCTION_FLAGS_LEAVE_ERR_MSG) {
	        varbl.interp.objVarErrMsg(part1_ptr, part2_ptr, msg, no_such_var, -1);
	        varbl.setErrorCode(["TCL", "VALUE", "VARNAME"]);
	      }
	      return null;
            }
            part2 = part1_ptr.twoPtrValue.ptr2();
            new_part2 = part2;
            if (new_part2) {
              part2_ptr = varbl.interp.string_obj_type.newStringObj(new_part2, -1, "VARIABLE_OBJ_TYPE_14");
              part2_ptr.incrRefCount("I_VARIABLE_OBJ_TYPE_16");
            }
            part1_ptr = part1_ptr.twoPtrValue.ptr1();
            obj_type = part1_ptr.obj_type;
            if (obj_type == varbl.interp.local_var_name_obj_type) {
              local_var_name_handling = true;
            }
          }
          if (!local_var_name_handling) {
            parsed = 1;
          }
        }
      }
    }
    if (!done_part1 && !done_parsing) {
      part1 = part1_ptr.getString();
................................................................................
    res_ptr = varbl.objLookupVarEx(part1_ptr, part2_ptr, flags, msg, create_part1, create_part2, array_ptr);
    if (part2_ptr) {
      part2_ptr.decrRefCount("D_VARIABLE_OBJ_TYPE_16");
    }
    return res_ptr;
  },



















































  /* ==================== handleVariableTrace ===================================== */
  handleVariableTrace: function(name_obj_ptr, part, op, op_str, my_var_ptr) {
    var varbl = this;
    var rc = varbl.OK;
    var save_no_trace;

    if (typeof name_obj_ptr.varValue == "undefined") {