From ee82dae3186b7a4fc4d339fc97d5792b2b5e2648 Mon Sep 17 00:00:00 2001 From: Misko Hevery Date: Thu, 8 Jul 2010 10:40:54 -0700 Subject: added class as a constant keyword to generated code --- src/Scope.js | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'src/Scope.js') diff --git a/src/Scope.js b/src/Scope.js index b45efbce..35da77fe 100644 --- a/src/Scope.js +++ b/src/Scope.js @@ -46,7 +46,14 @@ function setter(instance, path, value){ /////////////////////////////////// var getterFnCache = {}; -var JS_KEYWORDS = ["this", "throw", "for", "foreach", "var", "const"]; +var JS_KEYWORDS = {}; +foreach( + ["break", "const", "continue", "class", "delete", + "do", "while", "for", "function", "if", + "instanceof", "new", "return", "switch", + "this", "throw", "try", "catch", "with"], + function(key){ JS_KEYWORDS[key] = true;} +); function getterFn(path){ var fn = getterFnCache[path]; if (fn) return fn; @@ -54,7 +61,7 @@ function getterFn(path){ var code = 'function (self){\n'; code += ' var last, fn, type;\n'; foreach(path.split('.'), function(key) { - key = (includes(JS_KEYWORDS, key)) ? '["' + key + '"]' : '.' + key; + key = (JS_KEYWORDS[key]) ? '["' + key + '"]' : '.' + key; code += ' if(!self) return self;\n'; code += ' last = self;\n'; code += ' self = self' + key + ';\n'; -- cgit v1.2.3