* Patch from Mattias Gaertner:

* added more global JS identifiers to reserved word list

git-svn-id: trunk@35653 -
This commit is contained in:
michael 2017-03-24 12:11:04 +00:00
parent f12c8a8adc
commit 872ed2af11
2 changed files with 58 additions and 6 deletions

View File

@ -171,6 +171,7 @@ Works:
- use 0o for octal literals - use 0o for octal literals
ToDos: ToDos:
- exports - to protect an identifier from optimization
- jsvalue: add base type jsvalue, useful for TList and external classes - jsvalue: add base type jsvalue, useful for TList and external classes
- constant for undefined - constant for undefined
- fail check: assign proc type a class method - fail check: assign proc type a class method
@ -181,6 +182,7 @@ ToDos:
- option to add preserved word - option to add preserved word
- documentation - documentation
- use in TObject - use in TObject
- asm: pas() - useful for overloads and protect an identifier from optimization
Not in Version 1.0: Not in Version 1.0:
- write, writeln - write, writeln
@ -313,15 +315,48 @@ const
DefaultVarNameRTL = 'rtl'; DefaultVarNameRTL = 'rtl';
DefaultVarNameWith = '$with'; DefaultVarNameWith = '$with';
JSReservedWords: array[0..61] of string = ( JSReservedWords: array[0..106] of string = (
// keep sorted, first uppercase, then lowercase ! // keep sorted, first uppercase, then lowercase !
'Array', 'Array',
'ArrayBuffer',
'Boolean',
'DataView',
'Date',
'Error',
'EvalError',
'Float32Array',
'Float64Array',
'Generator',
'GeneratorFunction',
'Infinity', 'Infinity',
'Int16Array',
'Int32Array',
'Int8Array',
'InternalError',
'JSON',
'Map',
'Math', 'Math',
'NaN', 'NaN',
'Number', 'Number',
'Object', 'Object',
'Promise',
'Proxy',
'RangeError',
'ReferenceError',
'Reflect',
'RegExp',
'Set',
'String', 'String',
'Symbol',
'SyntaxError',
'TypeError',
'URIError',
'Uint16Array',
'Uint32Array',
'Uint8Array',
'Uint8ClampedArray',
'WeakMap',
'WeakSet',
'__extends', '__extends',
'_super', '_super',
'anonymous', 'anonymous',
@ -337,12 +372,18 @@ const
'class', 'class',
'constructor', 'constructor',
'continue', 'continue',
'decodeURI',
'decodeURIComponent',
'default', 'default',
'delete', 'delete',
'do', 'do',
'each', 'each',
'else', 'else',
'encodeURI',
'encodeURIComponent',
'enum', 'enum',
'escape',
'eval',
'export', 'export',
'extends', 'extends',
'false', 'false',
@ -355,11 +396,15 @@ const
'in', 'in',
'instanceof', 'instanceof',
'interface', 'interface',
'isFinite',
'isNaN',
'isPrototypeOf', 'isPrototypeOf',
'let', 'let',
'new', 'new',
'null', 'null',
'package', 'package',
'parseFloat',
'parseInt',
'private', 'private',
'protected', 'protected',
'prototype', 'prototype',
@ -373,6 +418,8 @@ const
'true', 'true',
'try', 'try',
'undefined', 'undefined',
'unescape',
'uneval',
'var', 'var',
'while', 'while',
'with', 'with',

View File

@ -1423,7 +1423,7 @@ begin
'this.vC = -this.vA;', 'this.vC = -this.vA;',
'this.vA = this.vA - this.vB;', 'this.vA = this.vA - this.vB;',
'this.vB = this.vA;', 'this.vB = this.vA;',
'if (this.vA < this.vB) this.vC = this.vA else this.vC = this.vB;' 'if (this.vA < this.vB){ this.vC = this.vA } else this.vC = this.vB;'
])); ]));
end; end;
@ -3683,8 +3683,9 @@ begin
'try {', 'try {',
' this.vI = 4;', ' this.vI = 4;',
'} catch ('+DefaultVarNameExceptObject+') {', '} catch ('+DefaultVarNameExceptObject+') {',
' if (this.EInvalidCast.isPrototypeOf('+DefaultVarNameExceptObject+')) throw '+DefaultVarNameExceptObject, ' if (this.EInvalidCast.isPrototypeOf('+DefaultVarNameExceptObject+')){',
' else if (this.Exception.isPrototypeOf('+DefaultVarNameExceptObject+')) {', ' throw '+DefaultVarNameExceptObject,
' } else if (this.Exception.isPrototypeOf('+DefaultVarNameExceptObject+')) {',
' var E = '+DefaultVarNameExceptObject+';', ' var E = '+DefaultVarNameExceptObject+';',
' if (E.Msg == "") throw E;', ' if (E.Msg == "") throw E;',
' } else {', ' } else {',
@ -3718,7 +3719,7 @@ begin
]), ]),
LinesToStr([ // this.$main LinesToStr([ // this.$main
'var $tmp1 = this.vI;', 'var $tmp1 = this.vI;',
'if ($tmp1 == 1) {} else if ($tmp1 == 2) this.vI = 3 else {', 'if ($tmp1 == 1) {} else if ($tmp1 == 2){ this.vI = 3 }else {',
' this.vI = 4;', ' this.vI = 4;',
'};' '};'
])); ]));
@ -3818,7 +3819,11 @@ begin
]), ]),
LinesToStr([ // this.$main LinesToStr([ // this.$main
'var $tmp1 = this.vI;', 'var $tmp1 = this.vI;',
'if (($tmp1 >= 1) && ($tmp1 <= 3)) this.vI = 14 else if (($tmp1 == 4) || ($tmp1 == 5)) this.vI = 16 else if ((($tmp1 >= 6) && ($tmp1 <= 7)) || (($tmp1 >= 9) && ($tmp1 <= 10))) ;' 'if (($tmp1 >= 1) && ($tmp1 <= 3)){',
' this.vI = 14',
'} else if (($tmp1 == 4) || ($tmp1 == 5)){',
' this.vI = 16',
'} else if ((($tmp1 >= 6) && ($tmp1 <= 7)) || (($tmp1 >= 9) && ($tmp1 <= 10))) ;'
])); ]));
end; end;