number_builtin

This commit is contained in:
Andrew Morris
2023-03-17 01:00:10 +11:00
parent 751bf7a30d
commit 791e69dcca
11 changed files with 302 additions and 2 deletions

View File

@@ -330,6 +330,7 @@ impl Assembler {
"Math" => 0,
"Debug" => 1,
"String" => 2,
"Number" => 3,
_ => panic!("Unknown builtin: {}", builtin.name),
};

View File

@@ -747,7 +747,10 @@ impl<'a> AssemblyParser<'a> {
}
fn assemble_builtin(&mut self) -> Builtin {
match self.parse_one_of(&["$Math", "$Debug", "$String"]).as_str() {
match self
.parse_one_of(&["$Math", "$Debug", "$String", "$Number"])
.as_str()
{
"$Math" => Builtin {
name: "Math".to_string(),
},
@@ -757,6 +760,9 @@ impl<'a> AssemblyParser<'a> {
"$String" => Builtin {
name: "String".to_string(),
},
"$Number" => Builtin {
name: "Number".to_string(),
},
_ => panic!("Shouldn't happen"),
}
}

View File

@@ -101,6 +101,12 @@ pub fn init_std_scope() -> Scope {
name: "String".to_string(),
}),
),
(
"Number".to_string(),
MappedName::Builtin(Builtin {
name: "Number".to_string(),
}),
),
]),
parent: None,
})),

View File

@@ -57,7 +57,7 @@ impl ScopeAnalysis {
let mut sa = ScopeAnalysis::default();
let scope = init_std_scope();
for builtin_name in vec!["Debug", "Math", "String"] {
for builtin_name in vec!["Debug", "Math", "String", "Number"] {
let builtin = Builtin {
name: builtin_name.to_string(),
};
@@ -1635,6 +1635,12 @@ fn init_std_scope() -> XScope {
name: "String".to_string(),
}),
),
(
swc_atoms::JsWord::from("Number"),
NameId::Builtin(Builtin {
name: "Number".to_string(),
}),
),
]),
parent: None,
}))