diff options
author | Alex Lam S.L <alexlamsl@gmail.com> | 2021-01-24 01:51:18 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-24 09:51:18 +0800 |
commit | 8bfd891c09edfb54d1b93010487ee68ad64a457c (patch) | |
tree | 947c02f460b927b4a0843e3f0955a5636621a067 /lib/ast.js | |
parent | ef9f7ca3e7c7f71df440645f782b3a7da4646d9b (diff) | |
download | tracifyjs-8bfd891c09edfb54d1b93010487ee68ad64a457c.tar.gz tracifyjs-8bfd891c09edfb54d1b93010487ee68ad64a457c.zip |
support BigInt literals (#4583)
Diffstat (limited to 'lib/ast.js')
-rw-r--r-- | lib/ast.js | 17 |
1 files changed, 15 insertions, 2 deletions
@@ -249,7 +249,7 @@ var AST_BlockScope = DEFNODE("BlockScope", "enclosed functions make_def parent_s enclosed: "[SymbolDef*/S] a list of all symbol definitions that are accessed from this scope or any subscopes", functions: "[Object/S] like `variables`, but only lists function declarations", parent_scope: "[AST_Scope?/S] link to the parent scope", - variables: "[Object/S] a map of name -> SymbolDef for all variables/functions defined in this scope", + variables: "[Object/S] a map of name ---> SymbolDef for all variables/functions defined in this scope", }, clone: function(deep) { var node = this._clone(deep); @@ -472,7 +472,7 @@ var AST_Scope = DEFNODE("Scope", "uses_eval uses_with", { var AST_Toplevel = DEFNODE("Toplevel", "globals", { $documentation: "The toplevel scope", $propdoc: { - globals: "[Object/S] a map of name -> SymbolDef for all undeclared names", + globals: "[Object/S] a map of name ---> SymbolDef for all undeclared names", }, wrap: function(name) { var body = this.body; @@ -1440,6 +1440,19 @@ var AST_Number = DEFNODE("Number", "value", { }, _validate: function() { if (typeof this.value != "number") throw new Error("value must be number"); + if (!isFinite(this.value)) throw new Error("value must be finite"); + if (this.value < 0) throw new Error("value cannot be negative"); + }, +}, AST_Constant); + +var AST_BigInt = DEFNODE("BigInt", "value", { + $documentation: "A BigInt literal", + $propdoc: { + value: "[string] the numeric representation", + }, + _validate: function() { + if (typeof this.value != "string") throw new Error("value must be string"); + if (this.value[0] == "-") throw new Error("value cannot be negative"); }, }, AST_Constant); |