Explorar el Código

Merge pull request #292 from mkroehnert/keywords

adapt list of reserved JavaScript keywords (fix #277)
Manfred Kröhnert hace 12 años
padre
commit
9a7f1d5bcc
Se han modificado 2 ficheros con 19 adiciones y 9 borrados
  1. 6 4
      bin/amberc.js
  2. 13 5
      js/boot.js

+ 6 - 4
bin/amberc.js

@@ -104,7 +104,7 @@ var createDefaults = function(amber_dir, finished_callback){
 		'closure': false,
 		'closure_parts': false,
 		'closure_full': false,
-		'closure_options': '',
+		'closure_options': ' --language_in=ECMASCRIPT5 ',
 		'suffix': '',
 		'loadsuffix': '',
 		'suffix_used': '',
@@ -330,9 +330,11 @@ AmberC.prototype.check_for_closure_compiler = function(callback) {
 					defaults.closure = false;
 					defaults.closure_parts = false;
 					defaults.closure_full = false;
-					callback();
-					return;
+				} else {
+					console.warn('Closure compiler found at: ' + self.closure_jar);
 				}
+				callback();
+				return;
 			});
 		});
 	} else {
@@ -679,7 +681,7 @@ AmberC.prototype.compose_js_files = function() {
 	program_files.forEach(function(file) {
 		if(path.existsSync(file)) {
 			console.log('Adding : ' + file);
-			console.log(fileStream.write(fs.readFileSync(file)));
+			fileStream.write(fs.readFileSync(file));
 		} else {
 			fileStream.end();
 			throw(new Error('Can not find file ' + file));

+ 13 - 5
js/boot.js

@@ -97,11 +97,19 @@ function Smalltalk(){
 	/* List of all reserved words in JavaScript. They may not be used as variables
 	   in Smalltalk. */
 
-	st.reservedWords = ['break', 'case', 'catch', 'char', 'class', 'continue', 'debugger', 
-		'default', 'delete', 'do', 'else', 'finally', 'for', 'function', 
-		'if', 'in', 'instanceof', 'new', 'private', 'protected', 
-		'public', 'return', 'static', 'switch', 'this', 'throw',
-		'try', 'typeof', 'var', 'void', 'while', 'with', 'yield'];
+	// list of reserved JavaScript keywords as of
+	//   http://es5.github.com/#x7.6.1.1
+	// and
+	//   http://people.mozilla.org/~jorendorff/es6-draft.html#sec-7.6.1
+	st.reservedWords = ['break', 'case', 'catch', 'continue', 'debugger',
+		'default', 'delete', 'do', 'else', 'finally', 'for', 'function',
+		'if', 'in', 'instanceof', 'new', 'return', 'switch', 'this', 'throw',
+		'try', 'typeof', 'var', 'void', 'while', 'with',
+		// ES5: future use: http://es5.github.com/#x7.6.1.2
+		'class', 'const', 'enum', 'export', 'extends', 'import', 'super',
+		// ES5: future use in strict mode
+		'implements', 'interface', 'let', 'package', 'private', 'protected',
+		'public', 'static', 'yield'];
 
 	/* The symbol table ensures symbol unicity */