Permalink
Browse files

scope now supports all assignment and upate operators

  • Loading branch information...
1 parent 8ccecfc commit a311b79336356e17342a2b5328ef8834a39773d5 @toolness toolness committed Nov 2, 2012
Showing with 2 additions and 14 deletions.
  1. +2 −14 slowmo/scope.js
View
@@ -26,13 +26,7 @@ define(function() {
assign: function(name, operator, value, range) {
if (name in this.vars) {
var oldValue = this.vars[name];
- switch (operator) {
- case "=":
- this.vars[name] = value; break;
-
- default:
- throw new Error("unimplemented operator: " + operator);
- }
+ eval("this.vars[name] " + operator + " value");
this.log("assign", name, operator, value, oldValue, range);
return this.vars[name];
}
@@ -41,13 +35,7 @@ define(function() {
update: function(name, operator, prefix, range) {
if (name in this.vars) {
var oldValue = this.vars[name];
- switch (operator) {
- case "++":
- this.vars[name]++; break;
-
- default:
- throw new Error("unimplemented operator: " + operator);
- }
+ eval("this.vars[name]" + operator);
this.log("update", name, operator, prefix, oldValue, range);
return prefix ? this.vars[name] : oldValue;
}

0 comments on commit a311b79

Please sign in to comment.