support BigInt literals (#4583)
This commit is contained in:
17
lib/ast.js
17
lib/ast.js
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user