mirror of
https://github.com/voltrevo/ValueScript.git
synced 2026-04-18 03:00:27 -04:00
Add object shorthand
This commit is contained in:
@@ -380,7 +380,9 @@ impl CaptureFinder {
|
||||
use swc_ecma_ast::Prop::*;
|
||||
|
||||
match &**p {
|
||||
Shorthand(_) => std::panic!("Not implemented: Shorthand prop"),
|
||||
Shorthand(ident) => {
|
||||
self.ref_(scope, ident.sym.to_string());
|
||||
},
|
||||
KeyValue(kv) => {
|
||||
match &kv.key {
|
||||
swc_ecma_ast::PropName::Ident(_) => {},
|
||||
|
||||
@@ -467,7 +467,14 @@ impl<'a> ExpressionCompiler<'a> {
|
||||
std::panic!("Not implemented: spread expression");
|
||||
},
|
||||
swc_ecma_ast::PropOrSpread::Prop(prop) => match &**prop {
|
||||
swc_ecma_ast::Prop::Shorthand(_) => std::panic!("Not implemented: Shorthand prop"),
|
||||
swc_ecma_ast::Prop::Shorthand(ident) => {
|
||||
value_assembly += &std::format!("\"{}\"", ident.sym.to_string());
|
||||
value_assembly += ": ";
|
||||
|
||||
let mut compiled_value = self.identifier(ident, None);
|
||||
sub_nested_registers.append(&mut compiled_value.nested_registers);
|
||||
value_assembly += &compiled_value.value_assembly;
|
||||
},
|
||||
swc_ecma_ast::Prop::KeyValue(kv) => {
|
||||
let key_assembly = match &kv.key {
|
||||
swc_ecma_ast::PropName::Ident(ident) =>
|
||||
|
||||
Reference in New Issue
Block a user