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

View File

@ -1423,7 +1423,7 @@ begin
'this.vC = -this.vA;',
'this.vA = this.vA - this.vB;',
'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;
@ -3683,8 +3683,9 @@ begin
'try {',
' this.vI = 4;',
'} catch ('+DefaultVarNameExceptObject+') {',
' if (this.EInvalidCast.isPrototypeOf('+DefaultVarNameExceptObject+')) throw '+DefaultVarNameExceptObject,
' else if (this.Exception.isPrototypeOf('+DefaultVarNameExceptObject+')) {',
' if (this.EInvalidCast.isPrototypeOf('+DefaultVarNameExceptObject+')){',
' throw '+DefaultVarNameExceptObject,
' } else if (this.Exception.isPrototypeOf('+DefaultVarNameExceptObject+')) {',
' var E = '+DefaultVarNameExceptObject+';',
' if (E.Msg == "") throw E;',
' } else {',
@ -3718,7 +3719,7 @@ begin
]),
LinesToStr([ // this.$main
'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;',
'};'
]));
@ -3818,7 +3819,11 @@ begin
]),
LinesToStr([ // this.$main
'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;