From 2ec7bb9607190bbe0f3f3765e17b00ff8650adb5 Mon Sep 17 00:00:00 2001 From: Yoav Steinberg Date: Sun, 28 Jan 2024 11:05:22 +0200 Subject: [PATCH 01/78] wip --- libs/wingc/src/lifting.rs | 56 ++++++++++++++++------- libs/wingc/src/lsp/completions.rs | 6 +-- libs/wingc/src/lsp/signature.rs | 4 +- libs/wingc/src/lsp/symbol_locator.rs | 8 ++-- libs/wingc/src/type_check.rs | 7 +-- libs/wingc/src/type_check_assert.rs | 4 +- libs/wingc/src/valid_json_visitor.rs | 4 +- libs/wingc/src/visit.rs | 68 ++++++++++++++-------------- libs/wingc/src/visit_context.rs | 27 ++++++++--- 9 files changed, 110 insertions(+), 74 deletions(-) diff --git a/libs/wingc/src/lifting.rs b/libs/wingc/src/lifting.rs index 1c34a260cbf..0d574d4eb49 100644 --- a/libs/wingc/src/lifting.rs +++ b/libs/wingc/src/lifting.rs @@ -179,36 +179,58 @@ impl<'a> Visit<'a> for LiftVisitor<'a> { self.ctx.pop_type_annotation(); } - fn visit_expr(&mut self, node: &'a Expr) { + fn visit_expr(&mut self, node: &'a Expr, is_callee: bool) { CompilationContext::set(CompilationPhase::Lifting, &node.span); - self.with_expr(node.id, |v| { + self.with_expr(&node, is_callee, |v| { let expr_phase = self.jsify.types.get_expr_phase(&node).unwrap(); let expr_type = v.jsify.types.get_expr_type(&node); // Skip expressions of an unresoved type (type errors) if expr_type.is_unresolved() { - visit::visit_expr(v, node); + visit::visit_expr(v, node, is_callee); return; } // this whole thing only applies to inflight code if v.ctx.current_phase() == Phase::Preflight { - visit::visit_expr(v, node); + visit::visit_expr(v, node, is_callee); return; } // Inflight expressions that evaluate to a preflight type are currently unsupported because // we can't determine exactly which preflight object is being accessed and therefore can't // qualify the original lift expression. - if expr_phase == Phase::Inflight && expr_type.is_preflight_class() && v.ctx.current_property().is_some() { - report_diagnostic(Diagnostic { - message: format!( - "Expression of type \"{expr_type}\" references an unknown preflight object, can't qualify its capabilities (see https://github.com/winglang/wing/issues/76 for details)" - ), - span: Some(node.span.clone()), - annotations: vec![], - hints: vec![], - }); + if expr_phase == Phase::Inflight { + // The more explicit case is when the inflight expression is a reference to a preflight class + if expr_type.is_preflight_class() && ( + // Normal access to a property which acan't be qualified + v.ctx.current_property().is_some() /*|| + // Calling an inflight closure is an implicit access to `handle`, which can't qualify this either + matches!(node.kind, ExprKind::Call { .. }) + */) { + report_diagnostic(Diagnostic { + message: format!( + "Expression of type \"{expr_type}\" references an unknown preflight object, can't qualify its capabilities (see https://github.com/winglang/wing/issues/76 for details)" + ), + span: Some(node.span.clone()), + annotations: vec![], + hints: vec![], + }); + } + + // There's also a case when the inflight expression is a call on an inflight closure that's defined as + // a preflght class (a class with an inflight `handle` method`). In that case we can't qualify which preflight + // object is being accessed. + if expr_type.is_closure_class() && is_callee { + report_diagnostic(Diagnostic { + message: format!( + "Expression of type \"{expr_type}\" references an unknown inflight closure, can't qualify its capabilities (see https://github.com/winglang/wing/issues/76 for details)" + ), + span: Some(node.span.clone()), + annotations: vec![], + hints: vec![], + }); + } } //--------------- @@ -219,9 +241,9 @@ impl<'a> Visit<'a> for LiftVisitor<'a> { let property = if let Some(property) = v.ctx.current_property() { Some(property) - } else if expr_type.is_closure() { - // this is the case where we are lifting a "closure class" (e.g. a class that has a "handle" - // method) the reason we might not have "property" set is because closure classes might be + } else if expr_type.is_closure_class() && is_callee { + // this is the case where we are lifting a "closure class" (a preflight class that has an inflight `handle` + // method is being called) the reason we might not have "property" set is because closure classes might be // syntheticaly generated by the compiler from closures. Some(Symbol::global(CLOSURE_CLASS_HANDLE_METHOD)) } else { @@ -241,7 +263,7 @@ impl<'a> Visit<'a> for LiftVisitor<'a> { return; } - visit::visit_expr(v, node); + visit::visit_expr(v, node, is_callee); }); } diff --git a/libs/wingc/src/lsp/completions.rs b/libs/wingc/src/lsp/completions.rs index 7009732c476..779f09dae4a 100644 --- a/libs/wingc/src/lsp/completions.rs +++ b/libs/wingc/src/lsp/completions.rs @@ -1145,7 +1145,7 @@ impl<'a> Visit<'a> for ScopeVisitor<'a> { } } - fn visit_expr(&mut self, node: &'a Expr) { + fn visit_expr(&mut self, node: &'a Expr, is_callee: bool) { let mut set_node = false; // if the span is exactly the same, we want to set the node @@ -1187,10 +1187,10 @@ impl<'a> Visit<'a> for ScopeVisitor<'a> { node.kind, ExprKind::JsonLiteral { .. } | ExprKind::JsonMapLiteral { .. } ) { - visit_expr(self, node); + visit_expr(self, node, is_callee); } } else { - visit_expr(self, node); + visit_expr(self, node, is_callee); } } diff --git a/libs/wingc/src/lsp/signature.rs b/libs/wingc/src/lsp/signature.rs index 2cdbe364052..41f325ba1a4 100644 --- a/libs/wingc/src/lsp/signature.rs +++ b/libs/wingc/src/lsp/signature.rs @@ -196,8 +196,8 @@ impl<'a> ScopeVisitor<'a> { } impl<'a> Visit<'a> for ScopeVisitor<'a> { - fn visit_expr(&mut self, node: &'a Expr) { - visit_expr(self, node); + fn visit_expr(&mut self, node: &'a Expr, is_callee: bool) { + visit_expr(self, node, is_callee); if self.call_expr.is_some() { return; diff --git a/libs/wingc/src/lsp/symbol_locator.rs b/libs/wingc/src/lsp/symbol_locator.rs index ab6d163da86..798fbf72d9c 100644 --- a/libs/wingc/src/lsp/symbol_locator.rs +++ b/libs/wingc/src/lsp/symbol_locator.rs @@ -289,12 +289,12 @@ impl<'a> Visit<'a> for SymbolLocator<'a> { self.ctx.pop_stmt(); } - fn visit_expr(&mut self, node: &'a Expr) { + fn visit_expr(&mut self, node: &'a Expr, is_callee: bool) { if self.is_found() { return; } - self.ctx.push_expr(node.id); + self.ctx.push_expr(&node, is_callee); match &node.kind { ExprKind::New(new_expr) => { @@ -391,7 +391,7 @@ impl<'a> Visit<'a> for SymbolLocator<'a> { _ => {} } - crate::visit::visit_expr(self, node); + crate::visit::visit_expr(self, node, is_callee); self.ctx.pop_expr(); } @@ -443,7 +443,7 @@ impl<'a> Visit<'a> for SymbolLocator<'a> { match node { Reference::Identifier(sym) => self.visit_symbol(sym), Reference::InstanceMember { object, property, .. } => { - self.visit_expr(object); + self.visit_expr(object, false); if property.span.contains_location(&self.location) { self.set_result(SymbolLocatorResult::ObjectPropertyReference { diff --git a/libs/wingc/src/type_check.rs b/libs/wingc/src/type_check.rs index 93635d90dff..d9480d89fab 100644 --- a/libs/wingc/src/type_check.rs +++ b/libs/wingc/src/type_check.rs @@ -1060,10 +1060,11 @@ impl TypeRef { /// Returns whether type represents a closure (either a function or a closure class). pub fn is_closure(&self) -> bool { - if self.as_function_sig().is_some() { - return true; - } + self.as_function_sig().is_some() || self.is_closure_class() + } + /// Returns whether type represents a preflight class representing and inflight closure. + pub fn is_closure_class(&self) -> bool { if let Some(ref class) = self.as_preflight_class() { return class.get_closure_method().is_some(); } diff --git a/libs/wingc/src/type_check_assert.rs b/libs/wingc/src/type_check_assert.rs index d29c06b5512..d1b171d29f1 100644 --- a/libs/wingc/src/type_check_assert.rs +++ b/libs/wingc/src/type_check_assert.rs @@ -24,7 +24,7 @@ impl<'a> TypeCheckAssert<'a> { } impl<'a> Visit<'_> for TypeCheckAssert<'a> { - fn visit_expr(&mut self, expr: &Expr) { + fn visit_expr(&mut self, expr: &Expr, is_callee: bool) { if let Some(t) = self.types.try_get_expr_type(expr.id) { assert!( self.tc_found_errors || !t.is_unresolved(), @@ -34,6 +34,6 @@ impl<'a> Visit<'_> for TypeCheckAssert<'a> { } else { panic!("Expr was not type checked: {:?}", expr) } - visit::visit_expr(self, expr); + visit::visit_expr(self, expr, is_callee); } } diff --git a/libs/wingc/src/valid_json_visitor.rs b/libs/wingc/src/valid_json_visitor.rs index 1a9b29557e3..ef74535c20f 100644 --- a/libs/wingc/src/valid_json_visitor.rs +++ b/libs/wingc/src/valid_json_visitor.rs @@ -25,7 +25,7 @@ impl<'a> ValidJsonVisitor<'a> { } impl<'a> Visit<'_> for ValidJsonVisitor<'a> { - fn visit_expr(&mut self, expr: &Expr) { + fn visit_expr(&mut self, expr: &Expr, is_callee: bool) { if let Some(t) = self.types.try_get_expr_type(expr.id) { // if the type is json with known values, then we may need to validate that the values are legal json values if let Type::Json(Some(JsonData { kind, expression_id })) = &*t { @@ -81,6 +81,6 @@ impl<'a> Visit<'_> for ValidJsonVisitor<'a> { } } - visit::visit_expr(self, expr); + visit::visit_expr(self, expr, is_callee); } } diff --git a/libs/wingc/src/visit.rs b/libs/wingc/src/visit.rs index fa127bd37cf..edd7c756be3 100644 --- a/libs/wingc/src/visit.rs +++ b/libs/wingc/src/visit.rs @@ -45,8 +45,8 @@ pub trait Visit<'ast> { fn visit_interface(&mut self, node: &'ast Interface) { visit_interface(self, node); } - fn visit_expr(&mut self, node: &'ast Expr) { - visit_expr(self, node); + fn visit_expr(&mut self, node: &'ast Expr, is_callee: bool) { + visit_expr(self, node, is_callee); } fn visit_new_expr(&mut self, node: &'ast New) { visit_new_expr(self, node); @@ -118,7 +118,7 @@ where if let Some(type_) = type_ { v.visit_type_annotation(type_); } - v.visit_expr(initial_value); + v.visit_expr(initial_value, false); } StmtKind::ForLoop { iterator, @@ -126,11 +126,11 @@ where statements, } => { v.visit_symbol(iterator); - v.visit_expr(iterable); + v.visit_expr(iterable, false); v.visit_scope(statements); } StmtKind::While { condition, statements } => { - v.visit_expr(condition); + v.visit_expr(condition, false); v.visit_scope(statements); } StmtKind::Break | StmtKind::Continue => {} @@ -143,17 +143,17 @@ where else_statements, }) => { v.visit_symbol(var_name); - v.visit_expr(value); + v.visit_expr(value, false); v.visit_scope(statements); for elif in elif_statements { match elif { Elifs::ElifBlock(elif_block) => { - v.visit_expr(&elif_block.condition); + v.visit_expr(&elif_block.condition, false); v.visit_scope(&elif_block.statements); } Elifs::ElifLetBlock(elif_let_block) => { v.visit_symbol(&elif_let_block.var_name); - v.visit_expr(&elif_let_block.value); + v.visit_expr(&elif_let_block.value, false); v.visit_scope(&elif_let_block.statements); } } @@ -168,10 +168,10 @@ where elif_statements, else_statements, } => { - v.visit_expr(condition); + v.visit_expr(condition, false); v.visit_scope(statements); for elif in elif_statements { - v.visit_expr(&elif.condition); + v.visit_expr(&elif.condition, false); v.visit_scope(&elif.statements); } if let Some(statements) = else_statements { @@ -179,7 +179,7 @@ where } } StmtKind::Expression(expr) => { - v.visit_expr(&expr); + v.visit_expr(&expr, false); } StmtKind::Assignment { kind: _, @@ -187,15 +187,15 @@ where value, } => { v.visit_reference(variable); - v.visit_expr(value); + v.visit_expr(value, false); } StmtKind::Return(expr) => { if let Some(expr) = expr { - v.visit_expr(expr); + v.visit_expr(expr, false); } } StmtKind::Throw(expr) => { - v.visit_expr(expr); + v.visit_expr(expr, false); } StmtKind::Scope(scope) => { v.visit_scope(scope); @@ -302,14 +302,14 @@ where v.visit_user_defined_type(&node.class); v.visit_args(&node.arg_list); if let Some(id) = &node.obj_id { - v.visit_expr(&id); + v.visit_expr(&id, false); } if let Some(scope) = &node.obj_scope { - v.visit_expr(&scope); + v.visit_expr(&scope, false); } } -pub fn visit_expr<'ast, V>(v: &mut V, node: &'ast Expr) +pub fn visit_expr<'ast, V>(v: &mut V, node: &'ast Expr, _is_callee: bool) where V: Visit<'ast> + ?Sized, { @@ -325,48 +325,48 @@ where inclusive: _, end, } => { - v.visit_expr(start); - v.visit_expr(end); + v.visit_expr(start, false); + v.visit_expr(end, false); } ExprKind::Reference(ref_) => { v.visit_reference(ref_); } ExprKind::Call { callee, arg_list } => { match callee { - CalleeKind::Expr(expr) => v.visit_expr(expr), + CalleeKind::Expr(expr) => v.visit_expr(expr, true), CalleeKind::SuperCall(method) => v.visit_symbol(method), } v.visit_args(arg_list); } ExprKind::Unary { op: _, exp } => { - v.visit_expr(exp); + v.visit_expr(exp, false); } ExprKind::Binary { op: _, left, right } => { - v.visit_expr(left); - v.visit_expr(right); + v.visit_expr(left, false); + v.visit_expr(right, false); } ExprKind::ArrayLiteral { type_, items } => { if let Some(type_) = type_ { v.visit_type_annotation(type_); } for item in items { - v.visit_expr(item); + v.visit_expr(item, false); } } ExprKind::JsonLiteral { element, .. } => { - v.visit_expr(element); + v.visit_expr(element, false); } ExprKind::StructLiteral { type_, fields } => { v.visit_type_annotation(type_); for (sym, val) in fields.iter() { v.visit_symbol(sym); - v.visit_expr(val); + v.visit_expr(val, false); } } ExprKind::JsonMapLiteral { fields } => { for (name, val) in fields.iter() { v.visit_symbol(name); - v.visit_expr(val); + v.visit_expr(val, false); } } ExprKind::MapLiteral { type_, fields } => { @@ -374,8 +374,8 @@ where v.visit_type_annotation(type_); } for (key, val) in fields.iter() { - v.visit_expr(key); - v.visit_expr(val); + v.visit_expr(key, false); + v.visit_expr(val, false); } } ExprKind::SetLiteral { type_, items } => { @@ -383,7 +383,7 @@ where v.visit_type_annotation(type_); } for item in items { - v.visit_expr(item); + v.visit_expr(item, false); } } ExprKind::FunctionClosure(def) => { @@ -404,7 +404,7 @@ where Literal::InterpolatedString(interpolated_str) => { for part in &interpolated_str.parts { if let InterpolatedStringPart::Expr(exp) = part { - v.visit_expr(exp); + v.visit_expr(exp, false); } } } @@ -428,7 +428,7 @@ where object, optional_accessor: _, } => { - v.visit_expr(object); + v.visit_expr(object, false); v.visit_symbol(property); } Reference::TypeMember { type_name, property } => { @@ -472,11 +472,11 @@ where V: Visit<'ast> + ?Sized, { for arg in &node.pos_args { - v.visit_expr(&arg); + v.visit_expr(&arg, false); } for arg in &node.named_args { v.visit_symbol(&arg.0); - v.visit_expr(&arg.1); + v.visit_expr(&arg.1, false); } } diff --git a/libs/wingc/src/visit_context.rs b/libs/wingc/src/visit_context.rs index d93eb4bc5e7..54ed6eca3a0 100644 --- a/libs/wingc/src/visit_context.rs +++ b/libs/wingc/src/visit_context.rs @@ -1,7 +1,7 @@ use itertools::Itertools; use crate::{ - ast::{Class, ExprId, FunctionSignature, Phase, Symbol, UserDefinedType}, + ast::{Class, Expr, ExprId, FunctionSignature, Phase, Symbol, UserDefinedType}, type_check::symbol_env::SymbolEnvRef, }; @@ -12,6 +12,12 @@ pub struct FunctionContext { pub is_static: bool, } +#[derive(Clone)] +pub struct VisitExprInfo { + pub expr: ExprId, + pub is_callee: bool, +} + #[derive(Clone)] pub struct VisitContext { phase: Vec, @@ -23,7 +29,7 @@ pub struct VisitContext { statement: Vec, in_json: Vec, in_type_annotation: Vec, - expression: Vec, + expression: Vec, } impl VisitContext { @@ -72,8 +78,11 @@ impl VisitContext { // -- - pub fn push_expr(&mut self, expr: ExprId) { - self.expression.push(expr); + pub fn push_expr(&mut self, expr: &Expr, is_callee: bool) { + self.expression.push(VisitExprInfo { + expr: expr.id, + is_callee, + }); } pub fn pop_expr(&mut self) { @@ -81,7 +90,11 @@ impl VisitContext { } pub fn current_expr(&self) -> Option { - self.expression.last().map(|id| *id) + self.expression.last().map(|id| id.expr) + } + + pub fn current_expr_is_callee(&self) -> bool { + self.expression.last().map(|id| id.is_callee).unwrap_or(false) } // -- @@ -218,8 +231,8 @@ impl VisitContext { pub trait VisitorWithContext { fn ctx(&mut self) -> &mut VisitContext; - fn with_expr(&mut self, expr: ExprId, f: impl FnOnce(&mut Self)) { - self.ctx().push_expr(expr); + fn with_expr(&mut self, expr: &Expr, is_callee: bool, f: impl FnOnce(&mut Self)) { + self.ctx().push_expr(expr, is_callee); f(self); self.ctx().pop_expr(); } From 8e9de7dfebf300df8351d130aaa47d142cf03a92 Mon Sep 17 00:00:00 2001 From: Yoav Steinberg Date: Sun, 28 Jan 2024 11:06:16 +0200 Subject: [PATCH 02/78] wip --- libs/wingc/src/visit_context.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/wingc/src/visit_context.rs b/libs/wingc/src/visit_context.rs index 54ed6eca3a0..55fac41ffa4 100644 --- a/libs/wingc/src/visit_context.rs +++ b/libs/wingc/src/visit_context.rs @@ -15,7 +15,7 @@ pub struct FunctionContext { #[derive(Clone)] pub struct VisitExprInfo { pub expr: ExprId, - pub is_callee: bool, + pub is_callee: bool, // TODO: chuck this, never used?? or use it in type_check } #[derive(Clone)] From 6b595d702e9ca7472e290ece48f78be7c3a68b35 Mon Sep 17 00:00:00 2001 From: "monada-bot[bot]" Date: Sun, 28 Jan 2024 09:21:14 +0000 Subject: [PATCH 03/78] chore: self mutation (build.diff) Signed-off-by: monada-bot[bot] --- libs/wingc/src/jsify/snapshots/closure_field.snap | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/wingc/src/jsify/snapshots/closure_field.snap b/libs/wingc/src/jsify/snapshots/closure_field.snap index 31d59d9e71d..d6d1ba1dcf1 100644 --- a/libs/wingc/src/jsify/snapshots/closure_field.snap +++ b/libs/wingc/src/jsify/snapshots/closure_field.snap @@ -178,7 +178,7 @@ class $Root extends $stdlib.std.Resource { [this.closure, []], ], "foo": [ - [this.closure, ["handle"]], + [this.closure, []], ], }); super.onLift(host, ops); From 10f06706ada23fc3ee735cd5369b26e346987d80 Mon Sep 17 00:00:00 2001 From: Yoav Steinberg Date: Sun, 28 Jan 2024 14:21:36 +0200 Subject: [PATCH 04/78] store whether expr is callee in AST instead of during visiting --- libs/wingc/src/ast.rs | 19 +++++++- libs/wingc/src/closure_transform.rs | 2 +- libs/wingc/src/fold.rs | 1 + libs/wingc/src/lifting.rs | 14 +++--- libs/wingc/src/lsp/completions.rs | 6 +-- libs/wingc/src/lsp/signature.rs | 4 +- libs/wingc/src/lsp/symbol_locator.rs | 8 ++-- libs/wingc/src/parser.rs | 6 ++- libs/wingc/src/type_check.rs | 31 ++----------- libs/wingc/src/type_check_assert.rs | 4 +- libs/wingc/src/valid_json_visitor.rs | 4 +- libs/wingc/src/visit.rs | 68 ++++++++++++++-------------- libs/wingc/src/visit_context.rs | 25 +++------- 13 files changed, 89 insertions(+), 103 deletions(-) diff --git a/libs/wingc/src/ast.rs b/libs/wingc/src/ast.rs index c39aa67c644..bf077b5df8d 100644 --- a/libs/wingc/src/ast.rs +++ b/libs/wingc/src/ast.rs @@ -648,12 +648,29 @@ pub struct Expr { pub kind: ExprKind, /// The span of the expression. pub span: WingSpan, + /// The expression is a callee in a call expression + pub is_callee: bool, } impl Expr { pub fn new(kind: ExprKind, span: WingSpan) -> Self { let id = EXPR_COUNTER.fetch_add(1, Ordering::SeqCst); - Self { id, kind, span } + Self { + id, + kind, + is_callee: false, + span, + } + } + + pub fn new_callee(kind: ExprKind, span: WingSpan) -> Self { + let id = EXPR_COUNTER.fetch_add(1, Ordering::SeqCst); + Self { + id, + kind, + is_callee: true, + span, + } } } diff --git a/libs/wingc/src/closure_transform.rs b/libs/wingc/src/closure_transform.rs index 5ed2e004965..0dc2bb3bc0d 100644 --- a/libs/wingc/src/closure_transform.rs +++ b/libs/wingc/src/closure_transform.rs @@ -189,7 +189,7 @@ impl Fold for ClosureTransformer { // ``` let std_display_of_this = Expr::new( ExprKind::Call { - callee: CalleeKind::Expr(Box::new(Expr::new( + callee: CalleeKind::Expr(Box::new(Expr::new_callee( ExprKind::Reference(Reference::Identifier(Symbol::new( "nodeof", WingSpan::for_file(file_id), diff --git a/libs/wingc/src/fold.rs b/libs/wingc/src/fold.rs index b8376bda7b5..8e878e92070 100644 --- a/libs/wingc/src/fold.rs +++ b/libs/wingc/src/fold.rs @@ -361,6 +361,7 @@ where id: node.id, kind, span: node.span, + is_callee: node.is_callee, } } diff --git a/libs/wingc/src/lifting.rs b/libs/wingc/src/lifting.rs index 0d574d4eb49..5d4f91c40ba 100644 --- a/libs/wingc/src/lifting.rs +++ b/libs/wingc/src/lifting.rs @@ -179,21 +179,21 @@ impl<'a> Visit<'a> for LiftVisitor<'a> { self.ctx.pop_type_annotation(); } - fn visit_expr(&mut self, node: &'a Expr, is_callee: bool) { + fn visit_expr(&mut self, node: &'a Expr) { CompilationContext::set(CompilationPhase::Lifting, &node.span); - self.with_expr(&node, is_callee, |v| { + self.with_expr(&node, |v| { let expr_phase = self.jsify.types.get_expr_phase(&node).unwrap(); let expr_type = v.jsify.types.get_expr_type(&node); // Skip expressions of an unresoved type (type errors) if expr_type.is_unresolved() { - visit::visit_expr(v, node, is_callee); + visit::visit_expr(v, node); return; } // this whole thing only applies to inflight code if v.ctx.current_phase() == Phase::Preflight { - visit::visit_expr(v, node, is_callee); + visit::visit_expr(v, node); return; } @@ -221,7 +221,7 @@ impl<'a> Visit<'a> for LiftVisitor<'a> { // There's also a case when the inflight expression is a call on an inflight closure that's defined as // a preflght class (a class with an inflight `handle` method`). In that case we can't qualify which preflight // object is being accessed. - if expr_type.is_closure_class() && is_callee { + if expr_type.is_closure_class() && node.is_callee { report_diagnostic(Diagnostic { message: format!( "Expression of type \"{expr_type}\" references an unknown inflight closure, can't qualify its capabilities (see https://github.com/winglang/wing/issues/76 for details)" @@ -241,7 +241,7 @@ impl<'a> Visit<'a> for LiftVisitor<'a> { let property = if let Some(property) = v.ctx.current_property() { Some(property) - } else if expr_type.is_closure_class() && is_callee { + } else if expr_type.is_closure_class() && node.is_callee { // this is the case where we are lifting a "closure class" (a preflight class that has an inflight `handle` // method is being called) the reason we might not have "property" set is because closure classes might be // syntheticaly generated by the compiler from closures. @@ -263,7 +263,7 @@ impl<'a> Visit<'a> for LiftVisitor<'a> { return; } - visit::visit_expr(v, node, is_callee); + visit::visit_expr(v, node); }); } diff --git a/libs/wingc/src/lsp/completions.rs b/libs/wingc/src/lsp/completions.rs index 779f09dae4a..7009732c476 100644 --- a/libs/wingc/src/lsp/completions.rs +++ b/libs/wingc/src/lsp/completions.rs @@ -1145,7 +1145,7 @@ impl<'a> Visit<'a> for ScopeVisitor<'a> { } } - fn visit_expr(&mut self, node: &'a Expr, is_callee: bool) { + fn visit_expr(&mut self, node: &'a Expr) { let mut set_node = false; // if the span is exactly the same, we want to set the node @@ -1187,10 +1187,10 @@ impl<'a> Visit<'a> for ScopeVisitor<'a> { node.kind, ExprKind::JsonLiteral { .. } | ExprKind::JsonMapLiteral { .. } ) { - visit_expr(self, node, is_callee); + visit_expr(self, node); } } else { - visit_expr(self, node, is_callee); + visit_expr(self, node); } } diff --git a/libs/wingc/src/lsp/signature.rs b/libs/wingc/src/lsp/signature.rs index 41f325ba1a4..2cdbe364052 100644 --- a/libs/wingc/src/lsp/signature.rs +++ b/libs/wingc/src/lsp/signature.rs @@ -196,8 +196,8 @@ impl<'a> ScopeVisitor<'a> { } impl<'a> Visit<'a> for ScopeVisitor<'a> { - fn visit_expr(&mut self, node: &'a Expr, is_callee: bool) { - visit_expr(self, node, is_callee); + fn visit_expr(&mut self, node: &'a Expr) { + visit_expr(self, node); if self.call_expr.is_some() { return; diff --git a/libs/wingc/src/lsp/symbol_locator.rs b/libs/wingc/src/lsp/symbol_locator.rs index 798fbf72d9c..c40e6f89f6d 100644 --- a/libs/wingc/src/lsp/symbol_locator.rs +++ b/libs/wingc/src/lsp/symbol_locator.rs @@ -289,12 +289,12 @@ impl<'a> Visit<'a> for SymbolLocator<'a> { self.ctx.pop_stmt(); } - fn visit_expr(&mut self, node: &'a Expr, is_callee: bool) { + fn visit_expr(&mut self, node: &'a Expr) { if self.is_found() { return; } - self.ctx.push_expr(&node, is_callee); + self.ctx.push_expr(&node); match &node.kind { ExprKind::New(new_expr) => { @@ -391,7 +391,7 @@ impl<'a> Visit<'a> for SymbolLocator<'a> { _ => {} } - crate::visit::visit_expr(self, node, is_callee); + crate::visit::visit_expr(self, node); self.ctx.pop_expr(); } @@ -443,7 +443,7 @@ impl<'a> Visit<'a> for SymbolLocator<'a> { match node { Reference::Identifier(sym) => self.visit_symbol(sym), Reference::InstanceMember { object, property, .. } => { - self.visit_expr(object, false); + self.visit_expr(object); if property.span.contains_location(&self.location) { self.set_result(SymbolLocatorResult::ObjectPropertyReference { diff --git a/libs/wingc/src/parser.rs b/libs/wingc/src/parser.rs index 4c29190fa19..b84bc752aeb 100644 --- a/libs/wingc/src/parser.rs +++ b/libs/wingc/src/parser.rs @@ -532,7 +532,7 @@ impl<'s> Parser<'s> { // represent duration literals as the AST equivalent of `duration.fromSeconds(value)` Ok(Expr::new( ExprKind::Call { - callee: CalleeKind::Expr(Box::new(Expr::new( + callee: CalleeKind::Expr(Box::new(Expr::new_callee( ExprKind::Reference(Reference::InstanceMember { object: Box::new(Expr::new( ExprKind::Reference(Reference::Identifier(Symbol { @@ -2163,7 +2163,9 @@ impl<'s> Parser<'s> { let callee = if caller_node.kind() == "super_call" { CalleeKind::SuperCall(self.node_symbol(&caller_node.child_by_field_name("method").unwrap())?) } else { - CalleeKind::Expr(Box::new(self.build_expression(&caller_node, phase)?)) + let mut callee_expr = self.build_expression(&caller_node, phase)?; + callee_expr.is_callee = true; + CalleeKind::Expr(Box::new(callee_expr)) }; Ok(Expr::new( ExprKind::Call { diff --git a/libs/wingc/src/type_check.rs b/libs/wingc/src/type_check.rs index d9480d89fab..fdc46ca9e1e 100644 --- a/libs/wingc/src/type_check.rs +++ b/libs/wingc/src/type_check.rs @@ -1740,10 +1740,6 @@ pub struct TypeChecker<'a> { is_in_mut_json: bool, - // Stack of extra information we need to keep track of while visiting nested - // expressions during type checking. - curr_expr_info: Vec, - ctx: VisitContext, } @@ -1774,7 +1770,6 @@ impl<'a> TypeChecker<'a> { jsii_imports, is_in_mut_json: false, ctx: VisitContext::new(), - curr_expr_info: vec![], } } @@ -2009,8 +2004,6 @@ impl<'a> TypeChecker<'a> { ) -> (TypeRef, Phase) { CompilationContext::set(CompilationPhase::TypeChecking, &exp.span); - self.curr_expr_info.push(expr_visit_info); - let (mut t, phase) = |exp: &Expr, env: &mut SymbolEnv| -> (TypeRef, Phase) { match &exp.kind { ExprKind::Literal(lit) => match lit { @@ -2130,7 +2123,11 @@ impl<'a> TypeChecker<'a> { (self.types.add_type(Type::Array(stype)), stype_phase) } ExprKind::Reference(_ref) => { - let (vi, phase) = self.resolve_reference(_ref, env, self.curr_expr_is_callee_with_inflight_args()); + let (vi, phase) = self.resolve_reference( + _ref, + env, + matches!(expr_visit_info, ExprVisitInfo::Callee { inflight_args: true }), + ); (vi.type_, phase) } ExprKind::New(new_expr) => { @@ -2735,8 +2732,6 @@ impl<'a> TypeChecker<'a> { self.types.assign_type_to_expr(exp, t, phase); - self.curr_expr_info.pop(); - // In case any type inferences were updated during this check, ensure all related inferences are updated self.update_known_inferences(&mut t, &exp.span); @@ -5709,22 +5704,6 @@ impl<'a> TypeChecker<'a> { (None, None) } } - - fn curr_expr_is_callee_with_inflight_args(&self) -> bool { - self - .curr_expr_info - .last() - .map(|e| { - matches!( - e, - ExprVisitInfo::Callee { - inflight_args: true, - .. - } - ) - }) - .unwrap_or(false) - } } impl VisitorWithContext for TypeChecker<'_> { diff --git a/libs/wingc/src/type_check_assert.rs b/libs/wingc/src/type_check_assert.rs index d1b171d29f1..d29c06b5512 100644 --- a/libs/wingc/src/type_check_assert.rs +++ b/libs/wingc/src/type_check_assert.rs @@ -24,7 +24,7 @@ impl<'a> TypeCheckAssert<'a> { } impl<'a> Visit<'_> for TypeCheckAssert<'a> { - fn visit_expr(&mut self, expr: &Expr, is_callee: bool) { + fn visit_expr(&mut self, expr: &Expr) { if let Some(t) = self.types.try_get_expr_type(expr.id) { assert!( self.tc_found_errors || !t.is_unresolved(), @@ -34,6 +34,6 @@ impl<'a> Visit<'_> for TypeCheckAssert<'a> { } else { panic!("Expr was not type checked: {:?}", expr) } - visit::visit_expr(self, expr, is_callee); + visit::visit_expr(self, expr); } } diff --git a/libs/wingc/src/valid_json_visitor.rs b/libs/wingc/src/valid_json_visitor.rs index ef74535c20f..1a9b29557e3 100644 --- a/libs/wingc/src/valid_json_visitor.rs +++ b/libs/wingc/src/valid_json_visitor.rs @@ -25,7 +25,7 @@ impl<'a> ValidJsonVisitor<'a> { } impl<'a> Visit<'_> for ValidJsonVisitor<'a> { - fn visit_expr(&mut self, expr: &Expr, is_callee: bool) { + fn visit_expr(&mut self, expr: &Expr) { if let Some(t) = self.types.try_get_expr_type(expr.id) { // if the type is json with known values, then we may need to validate that the values are legal json values if let Type::Json(Some(JsonData { kind, expression_id })) = &*t { @@ -81,6 +81,6 @@ impl<'a> Visit<'_> for ValidJsonVisitor<'a> { } } - visit::visit_expr(self, expr, is_callee); + visit::visit_expr(self, expr); } } diff --git a/libs/wingc/src/visit.rs b/libs/wingc/src/visit.rs index edd7c756be3..fa127bd37cf 100644 --- a/libs/wingc/src/visit.rs +++ b/libs/wingc/src/visit.rs @@ -45,8 +45,8 @@ pub trait Visit<'ast> { fn visit_interface(&mut self, node: &'ast Interface) { visit_interface(self, node); } - fn visit_expr(&mut self, node: &'ast Expr, is_callee: bool) { - visit_expr(self, node, is_callee); + fn visit_expr(&mut self, node: &'ast Expr) { + visit_expr(self, node); } fn visit_new_expr(&mut self, node: &'ast New) { visit_new_expr(self, node); @@ -118,7 +118,7 @@ where if let Some(type_) = type_ { v.visit_type_annotation(type_); } - v.visit_expr(initial_value, false); + v.visit_expr(initial_value); } StmtKind::ForLoop { iterator, @@ -126,11 +126,11 @@ where statements, } => { v.visit_symbol(iterator); - v.visit_expr(iterable, false); + v.visit_expr(iterable); v.visit_scope(statements); } StmtKind::While { condition, statements } => { - v.visit_expr(condition, false); + v.visit_expr(condition); v.visit_scope(statements); } StmtKind::Break | StmtKind::Continue => {} @@ -143,17 +143,17 @@ where else_statements, }) => { v.visit_symbol(var_name); - v.visit_expr(value, false); + v.visit_expr(value); v.visit_scope(statements); for elif in elif_statements { match elif { Elifs::ElifBlock(elif_block) => { - v.visit_expr(&elif_block.condition, false); + v.visit_expr(&elif_block.condition); v.visit_scope(&elif_block.statements); } Elifs::ElifLetBlock(elif_let_block) => { v.visit_symbol(&elif_let_block.var_name); - v.visit_expr(&elif_let_block.value, false); + v.visit_expr(&elif_let_block.value); v.visit_scope(&elif_let_block.statements); } } @@ -168,10 +168,10 @@ where elif_statements, else_statements, } => { - v.visit_expr(condition, false); + v.visit_expr(condition); v.visit_scope(statements); for elif in elif_statements { - v.visit_expr(&elif.condition, false); + v.visit_expr(&elif.condition); v.visit_scope(&elif.statements); } if let Some(statements) = else_statements { @@ -179,7 +179,7 @@ where } } StmtKind::Expression(expr) => { - v.visit_expr(&expr, false); + v.visit_expr(&expr); } StmtKind::Assignment { kind: _, @@ -187,15 +187,15 @@ where value, } => { v.visit_reference(variable); - v.visit_expr(value, false); + v.visit_expr(value); } StmtKind::Return(expr) => { if let Some(expr) = expr { - v.visit_expr(expr, false); + v.visit_expr(expr); } } StmtKind::Throw(expr) => { - v.visit_expr(expr, false); + v.visit_expr(expr); } StmtKind::Scope(scope) => { v.visit_scope(scope); @@ -302,14 +302,14 @@ where v.visit_user_defined_type(&node.class); v.visit_args(&node.arg_list); if let Some(id) = &node.obj_id { - v.visit_expr(&id, false); + v.visit_expr(&id); } if let Some(scope) = &node.obj_scope { - v.visit_expr(&scope, false); + v.visit_expr(&scope); } } -pub fn visit_expr<'ast, V>(v: &mut V, node: &'ast Expr, _is_callee: bool) +pub fn visit_expr<'ast, V>(v: &mut V, node: &'ast Expr) where V: Visit<'ast> + ?Sized, { @@ -325,48 +325,48 @@ where inclusive: _, end, } => { - v.visit_expr(start, false); - v.visit_expr(end, false); + v.visit_expr(start); + v.visit_expr(end); } ExprKind::Reference(ref_) => { v.visit_reference(ref_); } ExprKind::Call { callee, arg_list } => { match callee { - CalleeKind::Expr(expr) => v.visit_expr(expr, true), + CalleeKind::Expr(expr) => v.visit_expr(expr), CalleeKind::SuperCall(method) => v.visit_symbol(method), } v.visit_args(arg_list); } ExprKind::Unary { op: _, exp } => { - v.visit_expr(exp, false); + v.visit_expr(exp); } ExprKind::Binary { op: _, left, right } => { - v.visit_expr(left, false); - v.visit_expr(right, false); + v.visit_expr(left); + v.visit_expr(right); } ExprKind::ArrayLiteral { type_, items } => { if let Some(type_) = type_ { v.visit_type_annotation(type_); } for item in items { - v.visit_expr(item, false); + v.visit_expr(item); } } ExprKind::JsonLiteral { element, .. } => { - v.visit_expr(element, false); + v.visit_expr(element); } ExprKind::StructLiteral { type_, fields } => { v.visit_type_annotation(type_); for (sym, val) in fields.iter() { v.visit_symbol(sym); - v.visit_expr(val, false); + v.visit_expr(val); } } ExprKind::JsonMapLiteral { fields } => { for (name, val) in fields.iter() { v.visit_symbol(name); - v.visit_expr(val, false); + v.visit_expr(val); } } ExprKind::MapLiteral { type_, fields } => { @@ -374,8 +374,8 @@ where v.visit_type_annotation(type_); } for (key, val) in fields.iter() { - v.visit_expr(key, false); - v.visit_expr(val, false); + v.visit_expr(key); + v.visit_expr(val); } } ExprKind::SetLiteral { type_, items } => { @@ -383,7 +383,7 @@ where v.visit_type_annotation(type_); } for item in items { - v.visit_expr(item, false); + v.visit_expr(item); } } ExprKind::FunctionClosure(def) => { @@ -404,7 +404,7 @@ where Literal::InterpolatedString(interpolated_str) => { for part in &interpolated_str.parts { if let InterpolatedStringPart::Expr(exp) = part { - v.visit_expr(exp, false); + v.visit_expr(exp); } } } @@ -428,7 +428,7 @@ where object, optional_accessor: _, } => { - v.visit_expr(object, false); + v.visit_expr(object); v.visit_symbol(property); } Reference::TypeMember { type_name, property } => { @@ -472,11 +472,11 @@ where V: Visit<'ast> + ?Sized, { for arg in &node.pos_args { - v.visit_expr(&arg, false); + v.visit_expr(&arg); } for arg in &node.named_args { v.visit_symbol(&arg.0); - v.visit_expr(&arg.1, false); + v.visit_expr(&arg.1); } } diff --git a/libs/wingc/src/visit_context.rs b/libs/wingc/src/visit_context.rs index 55fac41ffa4..af0808545d7 100644 --- a/libs/wingc/src/visit_context.rs +++ b/libs/wingc/src/visit_context.rs @@ -12,12 +12,6 @@ pub struct FunctionContext { pub is_static: bool, } -#[derive(Clone)] -pub struct VisitExprInfo { - pub expr: ExprId, - pub is_callee: bool, // TODO: chuck this, never used?? or use it in type_check -} - #[derive(Clone)] pub struct VisitContext { phase: Vec, @@ -29,7 +23,7 @@ pub struct VisitContext { statement: Vec, in_json: Vec, in_type_annotation: Vec, - expression: Vec, + expression: Vec, } impl VisitContext { @@ -78,11 +72,8 @@ impl VisitContext { // -- - pub fn push_expr(&mut self, expr: &Expr, is_callee: bool) { - self.expression.push(VisitExprInfo { - expr: expr.id, - is_callee, - }); + pub fn push_expr(&mut self, expr: &Expr) { + self.expression.push(expr.id); } pub fn pop_expr(&mut self) { @@ -90,11 +81,7 @@ impl VisitContext { } pub fn current_expr(&self) -> Option { - self.expression.last().map(|id| id.expr) - } - - pub fn current_expr_is_callee(&self) -> bool { - self.expression.last().map(|id| id.is_callee).unwrap_or(false) + self.expression.last().map(|id| *id) } // -- @@ -231,8 +218,8 @@ impl VisitContext { pub trait VisitorWithContext { fn ctx(&mut self) -> &mut VisitContext; - fn with_expr(&mut self, expr: &Expr, is_callee: bool, f: impl FnOnce(&mut Self)) { - self.ctx().push_expr(expr, is_callee); + fn with_expr(&mut self, expr: &Expr, f: impl FnOnce(&mut Self)) { + self.ctx().push_expr(expr); f(self); self.ctx().pop_expr(); } From f5a6ac4244fb47daea00674b574a15d5580428ef Mon Sep 17 00:00:00 2001 From: Yoav Steinberg Date: Thu, 1 Feb 2024 19:35:15 +0200 Subject: [PATCH 05/78] wip: lift inflight classes (defined preflight) --- libs/wingc/src/jsify.rs | 13 ++- libs/wingc/src/lifting.rs | 104 ++++++++++++++------- libs/wingc/src/type_check.rs | 16 ++++ libs/wingc/src/type_check/jsii_importer.rs | 1 + libs/wingc/src/type_check/lifts.rs | 58 ++++++++++-- 5 files changed, 149 insertions(+), 43 deletions(-) diff --git a/libs/wingc/src/jsify.rs b/libs/wingc/src/jsify.rs index 98550f4f9f7..3b7b3bb6592 100644 --- a/libs/wingc/src/jsify.rs +++ b/libs/wingc/src/jsify.rs @@ -95,6 +95,7 @@ impl VisitorWithContext for JSifyContext<'_> { /// Preflight classes have two types of host binding methods: /// `Type` for binding static fields and methods to the host and /// `instance` for binding instance fields and methods to the host. +#[derive(PartialEq)] enum BindMethod { Type, Instance, @@ -1806,8 +1807,16 @@ impl<'a> JSifier<'a> { .as_ref() .expect(&format!("method \"{m}\" doesn't exist in {class_name}")) .kind; - let is_static = matches!(var_kind, VariableKind::StaticMember); - (*m == CLASS_INFLIGHT_INIT_NAME || !is_static) ^ (matches!(bind_method_kind, BindMethod::Type)) + // TODO: the following hints that instead of `onLiftType` and `onLift` we need to mark each lift as a + // field lift or a type lift. Then for each instance lifts we need to make sure to call their typeLiftToo. + if class.phase == Phase::Inflight { + // All lifts in inflight classes are "type" lifts since `this` has no preflight fields which need to be + // lifted based on the object's instance + bind_method_kind == BindMethod::Type + } else { + let is_static = matches!(var_kind, VariableKind::StaticMember); + (*m == CLASS_INFLIGHT_INIT_NAME || !is_static) ^ (matches!(bind_method_kind, BindMethod::Type)) + } }) .collect_vec(); diff --git a/libs/wingc/src/lifting.rs b/libs/wingc/src/lifting.rs index 5d4f91c40ba..7f404fe78f2 100644 --- a/libs/wingc/src/lifting.rs +++ b/libs/wingc/src/lifting.rs @@ -6,6 +6,7 @@ use crate::{ diagnostic::{report_diagnostic, Diagnostic}, jsify::{JSifier, JSifyContext}, type_check::{ + get_udt_definition_phase, lifts::{Liftable, Lifts}, resolve_user_defined_type, symbol_env::LookupResult, @@ -221,16 +222,16 @@ impl<'a> Visit<'a> for LiftVisitor<'a> { // There's also a case when the inflight expression is a call on an inflight closure that's defined as // a preflght class (a class with an inflight `handle` method`). In that case we can't qualify which preflight // object is being accessed. - if expr_type.is_closure_class() && node.is_callee { - report_diagnostic(Diagnostic { - message: format!( - "Expression of type \"{expr_type}\" references an unknown inflight closure, can't qualify its capabilities (see https://github.com/winglang/wing/issues/76 for details)" - ), - span: Some(node.span.clone()), - annotations: vec![], - hints: vec![], - }); - } + // if expr_type.is_closure_class() && node.is_callee { + // report_diagnostic(Diagnostic { + // message: format!( + // "Expression of type \"{expr_type}\" references an unknown inflight closure, can't qualify its capabilities (see https://github.com/winglang/wing/issues/76 for details)" + // ), + // span: Some(node.span.clone()), + // annotations: vec![], + // hints: vec![], + // }); + // } } //--------------- @@ -257,11 +258,47 @@ impl<'a> Visit<'a> for LiftVisitor<'a> { let mut lifts = v.lifts_stack.pop().unwrap(); let is_field = code.contains("this."); // TODO: starts_with? - lifts.lift(v.ctx.current_method().map(|(m,_)|m), property, &code, is_field); + lifts.lift(v.ctx.current_method().map(|(m,_)|m).expect("a method"), property, &code, is_field, None); lifts.capture(&Liftable::Expr(node.id), &code, is_field); v.lifts_stack.push(lifts); return; } + // else if expr_phase == Phase::Inflight && expr_type.is_closure() { + // // We assume any reference to a closure means it might be called and therefore we need to lift it if it's + // // a method of a class defined preflight. + + // if let Some(sig) = expr_type.as_deep_function_sig() { + // if let Some(class_type) = sig.this_type { + // if let Some(class) = class_type.as_class() { + // if class.defined_in_phase == Phase::Preflight && class.phase == Phase::Inflight { + // println!("A reference to a method {:?} of an inflight class {class_type}!", v.ctx.current_property()); + + // } + // } + // } + // } + // } + else if expr_phase == Phase::Inflight { + // If this is a reference to an inflight class defined preflight then we need to lift it and qualify it with the + // current property + if let Some(class) = expr_type.as_class() { + //let tmp_udt = UserDefinedType::for_name(&class.name); + //let class_defined_in = get_udt_definition_phase(&tmp_udt, v.ctx.current_env().expect("an env")).expect("a phase"); + if class.phase == Phase::Inflight && class.defined_in_phase == Phase::Preflight { + if let Some(property) = v.ctx.current_property() { + let m = v.ctx.current_method().map(|(m,_)|m).expect("a method"); + //println!("Access to {property} of preflight defined inflight class {expr_type}, should qualify method {m}!"); + let mut lifts = v.lifts_stack.pop().unwrap(); + // Get convert the expression to its type + // let code = v.jsify_expr_to_type(&code); + //lifts.lift(v.ctx.current_method().map(|(m,_)|m), Some(property), &code, false, Some(expr_type)); + lifts.qualify_lifted_type(m, property, expr_type); + v.lifts_stack.push(lifts); + return; + } + } + } + } visit::visit_expr(v, node); }); @@ -282,14 +319,11 @@ impl<'a> Visit<'a> for LiftVisitor<'a> { } // Get the type of the udt - let udt_type = resolve_user_defined_type( - node, - self.ctx.current_env().expect("an env"), - self.ctx.current_stmt_idx(), - ) - .unwrap_or(self.jsify.types.error()); - - // Since our target languages is isn't statically typed, we don't need to capture interfaces + let env = self.ctx.current_env().expect("an env"); + let udt_type = + resolve_user_defined_type(node, env, self.ctx.current_stmt_idx()).unwrap_or(self.jsify.types.error()); + + // Since our target language is isn't statically typed, we don't need to capture interfaces if udt_type.as_interface().is_some() { visit::visit_user_defined_type(self, node); return; @@ -297,27 +331,33 @@ impl<'a> Visit<'a> for LiftVisitor<'a> { //--------------- // LIFT - if udt_type.is_preflight_class() { + if get_udt_definition_phase(node, env).expect("a phase") == Phase::Preflight { // jsify the expression so we can get the preflight code let code = self.jsify_udt(&node); let property = self.ctx.current_property(); // check that we can qualify the lift (e.g. determine which property is being accessed) - if property.is_none() { - report_diagnostic(Diagnostic { - message: format!( - "Cannot qualify access to a lifted type \"{udt_type}\" (see https://github.com/winglang/wing/issues/76 for more details)"), - span: Some(node.span.clone()), - annotations: vec![], - hints: vec![], - }); - - return; - } + // if property.is_none() { + // report_diagnostic(Diagnostic { + // message: format!( + // "Cannot qualify access to a lifted type \"{udt_type}\" (see https://github.com/winglang/wing/issues/76 for more details)"), + // span: Some(node.span.clone()), + // annotations: vec![], + // hints: vec![], + // }); + + // return; + // } let mut lifts = self.lifts_stack.pop().unwrap(); - lifts.lift(self.ctx.current_method().map(|(m, _)| m), property, &code, false); + lifts.lift( + self.ctx.current_method().map(|(m, _)| m).expect("a method"), + property, + &code, + false, + Some(udt_type), + ); self.lifts_stack.push(lifts); } diff --git a/libs/wingc/src/type_check.rs b/libs/wingc/src/type_check.rs index fdc46ca9e1e..6dfbdd49f95 100644 --- a/libs/wingc/src/type_check.rs +++ b/libs/wingc/src/type_check.rs @@ -327,6 +327,7 @@ pub struct Class { pub phase: Phase, pub docs: Docs, pub lifts: Option, + pub defined_in_phase: Phase, // TODO: naming: maybe this should just be `phase` while `phase` should be `defauld_member_phase`? // Preflight classes are CDK Constructs which means they have a scope and id as their first arguments // this is natively supported by wing using the `as` `in` keywords. However theoretically it is possible @@ -3877,6 +3878,7 @@ impl<'a> TypeChecker<'a> { implements: impl_interfaces.clone(), is_abstract: false, phase: ast_class.phase, + defined_in_phase: env.phase, type_parameters: None, // TODO no way to have generic args in wing yet docs: Docs::default(), std_construct_args: ast_class.phase == Phase::Preflight, @@ -4949,6 +4951,7 @@ impl<'a> TypeChecker<'a> { is_abstract: original_type_class.is_abstract, type_parameters: Some(type_params), phase: original_type_class.phase, + defined_in_phase: env.phase, docs: original_type_class.docs.clone(), std_construct_args: original_type_class.std_construct_args, lifts: None, @@ -5960,6 +5963,19 @@ pub fn resolve_user_defined_type_ref<'a>( } } +pub fn get_udt_definition_phase(user_defined_type: &UserDefinedType, env: &SymbolEnv) -> Option { + let mut nested_name = vec![&user_defined_type.root]; + nested_name.extend(user_defined_type.fields.iter().collect_vec()); + + let lookup_result = env.lookup_nested(&nested_name, None); + + if let LookupResult::Found(_, lookup_info) = lookup_result { + Some(lookup_info.env.phase) + } else { + None + } +} + pub fn is_udt_struct_type(udt: &UserDefinedType, env: &SymbolEnv) -> bool { if let Ok(type_) = resolve_user_defined_type(udt, env, 0) { type_.as_struct().is_some() diff --git a/libs/wingc/src/type_check/jsii_importer.rs b/libs/wingc/src/type_check/jsii_importer.rs index 12e46cf5d9c..63de990bb10 100644 --- a/libs/wingc/src/type_check/jsii_importer.rs +++ b/libs/wingc/src/type_check/jsii_importer.rs @@ -702,6 +702,7 @@ impl<'a> JsiiImporter<'a> { is_abstract: jsii_class.abstract_.unwrap_or(false), type_parameters: type_params, phase: class_phase, + defined_in_phase: Phase::Preflight, docs: Docs::from(&jsii_class.docs), std_construct_args: false, // Temporary value, will be updated once we parse the initializer args lifts: None, diff --git a/libs/wingc/src/type_check/lifts.rs b/libs/wingc/src/type_check/lifts.rs index fbb2dc311fe..c3c7dd8b533 100644 --- a/libs/wingc/src/type_check/lifts.rs +++ b/libs/wingc/src/type_check/lifts.rs @@ -2,13 +2,13 @@ use std::collections::{BTreeMap, BTreeSet, HashMap}; use crate::ast::{Symbol, UserDefinedType}; -use super::{ExprId, CLASS_INFLIGHT_INIT_NAME}; +use super::{ExprId, Subtype, TypeRef, CLASS_INFLIGHT_INIT_NAME}; /// A repository of lifts and captures at the class level. #[derive(Debug)] pub struct Lifts { // TODO: make all these private and add accessors+helper logic - /// All the lifts. Map from method to a map from inflight code to lift qualifications. + /// All the lifts. Map from method to a map from preflight code to lift qualifications. pub lifts_qualifications: BTreeMap>, /// All the captures. The key is token the value is the preflight code. @@ -31,6 +31,8 @@ pub enum Liftable { pub struct LiftQualification { /// The operations that qualify the lift (the property names) pub ops: BTreeSet, + /// For type (not object) lifts, the type these qualify + pub type_: Option, } /// A record that describes a lift from a class. @@ -57,24 +59,62 @@ impl Lifts { } /// Adds a lift for an expression. - pub fn lift(&mut self, method: Option, property: Option, code: &str, is_field: bool) { - let method = method.map(|m| m.name).unwrap_or(Default::default()); - - self.add_lift(method, code, property.as_ref().map(|s| s.name.clone())); + pub fn lift(&mut self, method: Symbol, property: Option, code: &str, is_field: bool, type_: Option) { + self.add_lift( + method.name.clone(), + code, + property.as_ref().map(|s| s.name.clone()), + type_, + ); // add a lift to the inflight initializer or capture it if its not a field if is_field { - self.add_lift(CLASS_INFLIGHT_INIT_NAME.to_string(), code, None); + self.add_lift(CLASS_INFLIGHT_INIT_NAME.to_string(), code, None, type_); } } - fn add_lift(&mut self, method: String, code: &str, property: Option) { + pub fn qualify_lifted_type(&mut self, method: Symbol, property: Symbol, type_: TypeRef) { + let Some(method_lifts) = self.lifts_qualifications.get_mut(&method.name) else { + panic!("Can't qualify unlifted type \"{type_}\" with \"{property}\": method \"{method}\" has no lifts."); + }; + + // Make sure this type actually exists in the lifts + // TODO: change this to a lookup instead of a linear search over `code` + let lift_qualification = method_lifts + .values_mut() + .find(|lift| lift.type_.is_some() && lift.type_.unwrap().is_same_type_as(&type_)) + .unwrap_or_else(|| panic!("Can't qualify unlifted type \"{type_}\" with \"{property}\"")); + + // Add the property to the lift qualification + lift_qualification.ops.insert(property.name.clone()); + } + + fn add_lift(&mut self, method: String, code: &str, property: Option, type_: Option) { let lift = self .lifts_qualifications .entry(method) .or_default() .entry(code.to_string()) - .or_insert(LiftQualification { ops: BTreeSet::new() }); + .or_insert(LiftQualification { + ops: BTreeSet::new(), + type_, + }); + + // Make sure the type for the given lift is consistent + match (&lift.type_, &type_) { + (Some(t1), Some(t2)) => { + assert!( + t1.is_same_type_as(t2), + "Lift type mismatch for code \"{code}\": type \"{t1}\" != \"{t2}\"" + ); + } + (Some(t), None) | (None, Some(t)) => { + panic!("Lift type mismatch for code \"{code}\": type \"{t}\" != None"); + } + _ => { + // do nothing + } + } if let Some(op) = &property { lift.ops.insert(op.clone()); From 97d10f58d25a46de377f5f000dfb263fe5828069 Mon Sep 17 00:00:00 2001 From: Yoav Steinberg Date: Sat, 3 Feb 2024 19:26:02 +0200 Subject: [PATCH 06/78] deduce class phase in type system based on class definitions (inflight closures transformation now produces an inflight class) --- libs/wingc/src/docs.rs | 2 +- libs/wingc/src/jsify.rs | 2 +- libs/wingc/src/lifting.rs | 2 +- libs/wingc/src/type_check.rs | 128 ++++++++++++--------- libs/wingc/src/type_check/jsii_importer.rs | 7 +- 5 files changed, 77 insertions(+), 64 deletions(-) diff --git a/libs/wingc/src/docs.rs b/libs/wingc/src/docs.rs index c57b6da02c4..db2d33238f1 100644 --- a/libs/wingc/src/docs.rs +++ b/libs/wingc/src/docs.rs @@ -387,7 +387,7 @@ fn render_class(c: &Class) -> String { } render_docs(&mut markdown, &c.docs); - if matches!(c.phase, Phase::Preflight | Phase::Independent) { + if matches!(c.phase(), Phase::Preflight | Phase::Independent) { if let Some(initializer) = c.get_method(&Symbol::global(CLASS_INIT_NAME)) { let function_sig = initializer.type_.as_function_sig().unwrap(); if function_sig.parameters.len() > 0 { diff --git a/libs/wingc/src/jsify.rs b/libs/wingc/src/jsify.rs index 3b7b3bb6592..9e60562dbe5 100644 --- a/libs/wingc/src/jsify.rs +++ b/libs/wingc/src/jsify.rs @@ -1902,7 +1902,7 @@ fn parent_class_phase(ctx: &JSifyContext<'_>) -> Phase { .expect("a parent class") .as_class() .expect("a class") - .phase; + .phase(); parent_class_phase } diff --git a/libs/wingc/src/lifting.rs b/libs/wingc/src/lifting.rs index 7f404fe78f2..9f281509581 100644 --- a/libs/wingc/src/lifting.rs +++ b/libs/wingc/src/lifting.rs @@ -284,7 +284,7 @@ impl<'a> Visit<'a> for LiftVisitor<'a> { if let Some(class) = expr_type.as_class() { //let tmp_udt = UserDefinedType::for_name(&class.name); //let class_defined_in = get_udt_definition_phase(&tmp_udt, v.ctx.current_env().expect("an env")).expect("a phase"); - if class.phase == Phase::Inflight && class.defined_in_phase == Phase::Preflight { + if class.phase() == Phase::Inflight && class.defined_in_phase == Phase::Preflight { if let Some(property) = v.ctx.current_property() { let m = v.ctx.current_method().map(|(m,_)|m).expect("a method"); //println!("Access to {property} of preflight defined inflight class {expr_type}, should qualify method {m}!"); diff --git a/libs/wingc/src/type_check.rs b/libs/wingc/src/type_check.rs index 6dfbdd49f95..1d1a2788441 100644 --- a/libs/wingc/src/type_check.rs +++ b/libs/wingc/src/type_check.rs @@ -324,7 +324,6 @@ pub struct Class { pub fqn: Option, pub is_abstract: bool, pub type_parameters: Option>, - pub phase: Phase, pub docs: Docs, pub lifts: Option, pub defined_in_phase: Phase, // TODO: naming: maybe this should just be `phase` while `phase` should be `defauld_member_phase`? @@ -345,8 +344,8 @@ impl Class { pub fn get_closure_method(&self) -> Option { self .methods(true) - .find(|(name, type_)| name == CLOSURE_CLASS_HANDLE_METHOD && type_.is_inflight_function()) - .map(|(_, t)| t) + .find(|(name, v)| name == CLOSURE_CLASS_HANDLE_METHOD && v.type_.is_inflight_function()) + .map(|(_, v)| v.type_) } } @@ -391,25 +390,23 @@ impl Display for Interface { } type ClassLikeIterator<'a> = - FilterMap, fn(::Item) -> Option<(String, TypeRef)>>; + FilterMap, fn(::Item) -> Option<(String, VariableInfo)>>; pub trait ClassLike: Display { fn get_env(&self) -> &SymbolEnv; fn methods(&self, with_ancestry: bool) -> ClassLikeIterator<'_> { - self.get_env().iter(with_ancestry).filter_map(|(s, t, ..)| { - t.as_variable() - .unwrap() - .type_ - .as_function_sig() - .map(|_| (s.clone(), t.as_variable().unwrap().type_)) + self.get_env().iter(with_ancestry).filter_map(|(s, sym_kind, ..)| { + let v = sym_kind.as_variable().unwrap(); + v.type_.as_function_sig().map(|_| (s.clone(), v.clone())) }) } fn fields(&self, with_ancestry: bool) -> ClassLikeIterator<'_> { - self.get_env().iter(with_ancestry).filter_map(|(s, t, ..)| { - if t.as_variable().unwrap().type_.as_function_sig().is_none() { - Some((s, t.as_variable().unwrap().type_)) + self.get_env().iter(with_ancestry).filter_map(|(s, sym_kind, ..)| { + let v = sym_kind.as_variable().unwrap(); + if v.type_.as_function_sig().is_none() { + Some((s, v.clone())) } else { None } @@ -445,6 +442,32 @@ pub trait ClassLike: Display { None } } + + fn phase(&self) -> Phase { + // A class is considered a "preflight class" if it has any preflight fields. + // Having a preflight state means that different instances of the class + // might access different preflight data. Such instances need to be lifted + // into inflight individually. Non preflight class instances don't need to be + // lifted and can therefore be instantiated inflight. + if self + .fields(true) + .any(|(_, vi)| vi.kind == VariableKind::InstanceMember && vi.phase == Phase::Preflight) + { + return Phase::Preflight; + } + + // If all memebers are phase independent, then this class is phase independent + if self + .get_env() + .iter(true) + .all(|(_, v, _)| v.as_variable().unwrap().phase == Phase::Independent) + { + return Phase::Independent; + } + + // Otherwise, this is an inflight class + Phase::Inflight + } } impl ClassLike for Interface { @@ -659,16 +682,14 @@ impl Subtype for Type { // method type (aka "closure classes"). // First, check if there is exactly one inflight method in the interface - let mut inflight_methods = iface - .methods(true) - .filter(|(_name, type_)| type_.is_inflight_function()); + let mut inflight_methods = iface.methods(true).filter(|(_name, v)| v.type_.is_inflight_function()); let handler_method = inflight_methods.next(); if handler_method.is_none() || inflight_methods.next().is_some() { return false; } // Next, check that the method's name is "handle" - let (handler_method_name, handler_method_type) = handler_method.unwrap(); + let (handler_method_name, handler_method_var) = handler_method.unwrap(); if handler_method_name != CLOSURE_CLASS_HANDLE_METHOD { return false; } @@ -681,7 +702,7 @@ impl Subtype for Type { }; // Finally check if they're subtypes - res_handle_type.is_subtype_of(&handler_method_type) + res_handle_type.is_subtype_of(&handler_method_var.type_) } (Self::Class(res), Self::Function(_)) => { // To support flexible inflight closures, we say that any @@ -929,7 +950,7 @@ unsafe impl Send for TypeRef {} impl TypeRef { pub fn as_preflight_class(&self) -> Option<&Class> { if let Type::Class(ref class) = **self { - if class.phase == Phase::Preflight { + if class.phase() == Phase::Preflight { return Some(class); } } @@ -1053,7 +1074,7 @@ impl TypeRef { pub fn is_preflight_class(&self) -> bool { if let Type::Class(ref class) = **self { - return class.phase == Phase::Preflight; + return class.phase() == Phase::Preflight; } return false; @@ -1064,10 +1085,10 @@ impl TypeRef { self.as_function_sig().is_some() || self.is_closure_class() } - /// Returns whether type represents a preflight class representing and inflight closure. + /// Returns whether type represents a class representing an inflight closure. pub fn is_closure_class(&self) -> bool { - if let Some(ref class) = self.as_preflight_class() { - return class.get_closure_method().is_some(); + if let Some(ref class) = self.as_class() { + return class.get_closure_method().is_some() && class.defined_in_phase == Phase::Preflight; } false } @@ -1171,7 +1192,7 @@ impl TypeRef { Type::Function(sig) => sig.phase == Phase::Inflight, // only preflight classes can be captured - Type::Class(c) => c.phase == Phase::Preflight, + Type::Class(c) => c.phase() == Phase::Preflight, } } @@ -1214,7 +1235,7 @@ impl TypeRef { Type::Map(v) => v.is_json_legal_value(), Type::Optional(v) => v.is_json_legal_value(), Type::Struct(ref s) => { - for (_, t) in s.fields(true) { + for t in s.fields(true).map(|(_, v)| v.type_) { if !t.is_json_legal_value() { return false; } @@ -1251,8 +1272,8 @@ impl TypeRef { match &**self { Type::Struct(s) => { // check all its fields are json compatible - for (_, field) in s.fields(true) { - if !field.has_json_representation() { + for t in s.fields(true).map(|(_, v)| v.type_) { + if !t.has_json_representation() { return false; } } @@ -2155,7 +2176,7 @@ impl<'a> TypeChecker<'a> { // error if we are trying to instantiate a preflight in a static method // without an explicit scope (there is no "this" to use as the scope) - if class.phase == Phase::Preflight && obj_scope.is_none() { + if class.phase() == Phase::Preflight && obj_scope.is_none() { // check if there is a "this" symbol in the current environment let has_this = env.lookup(&"this".into(), Some(self.ctx.current_stmt_idx())).is_some(); @@ -2176,14 +2197,16 @@ impl<'a> TypeChecker<'a> { } } - if class.phase == Phase::Independent || env.phase == class.phase { + if class.phase() == Phase::Independent || env.phase == class.phase() { (&class.env, &class.name) } else { self.spanned_error( exp, format!( "Cannot create {} class \"{}\" in {} phase", - class.phase, class.name, env.phase + class.phase(), + class.name, + env.phase ), ); return (self.types.error(), Phase::Independent); @@ -2339,21 +2362,9 @@ impl<'a> TypeChecker<'a> { // Make sure this is a function signature type let func_sig = if let Some(func_sig) = func_type.as_function_sig() { func_sig.clone() - } else if let Some(class) = func_type.as_preflight_class() { - // return the signature of the "handle" method - let lookup_res = class.get_method(&CLOSURE_CLASS_HANDLE_METHOD.into()); - let handle_type = if let Some(method) = lookup_res { - method.type_ - } else { - self.spanned_error(callee, "Expected a function or method"); - return self.resolved_error(); - }; - if let Some(sig_type) = handle_type.as_function_sig() { - sig_type.clone() - } else { - self.spanned_error(callee, "Expected a function or method"); - return self.resolved_error(); - } + } else if func_type.is_closure_class() { + let handle_type = func_type.as_class().unwrap().get_closure_method().unwrap(); + handle_type.as_function_sig().unwrap().clone() } else { self.spanned_error( callee, @@ -2608,7 +2619,8 @@ impl<'a> TypeChecker<'a> { .expect(&format!("Expected \"{}\" to be a struct type", struct_type)); // Verify that all expected fields are present and are the right type - for (name, field_type) in st.fields(true) { + for (name, v) in st.fields(true) { + let field_type = v.type_; match fields.get(name.as_str()) { Some(field_exp) => { let t = field_types.get(name.as_str()).unwrap(); @@ -3877,7 +3889,6 @@ impl<'a> TypeChecker<'a> { parent: parent_class, implements: impl_interfaces.clone(), is_abstract: false, - phase: ast_class.phase, defined_in_phase: env.phase, type_parameters: None, // TODO no way to have generic args in wing yet docs: Docs::default(), @@ -4016,7 +4027,8 @@ impl<'a> TypeChecker<'a> { }; // Check all methods are implemented - for (method_name, method_type) in interface_type.methods(true) { + for (method_name, v) in interface_type.methods(true) { + let method_type = v.type_; if let Some(symbol) = &mut class_type .as_class_mut() .unwrap() @@ -4561,9 +4573,9 @@ impl<'a> TypeChecker<'a> { return; }; - // If the parent class is phase independent than its init name is just "init" regadless of + // If the parent class is phase independent then its init name is just "init" regadless of // whether we're inflight or not. - let parent_init_name = if parent_class.as_class().unwrap().phase == Phase::Independent { + let parent_init_name = if parent_class.as_class().unwrap().phase() == Phase::Independent { CLASS_INIT_NAME } else { init_name @@ -4573,13 +4585,13 @@ impl<'a> TypeChecker<'a> { .as_class() .unwrap() .methods(false) - .filter(|(name, _type)| name == parent_init_name) - .collect_vec()[0] + .find(|(name, ..)| name == parent_init_name) + .unwrap() .1; self.type_check_arg_list_against_function_sig( &arg_list, - parent_initializer.as_function_sig().unwrap(), + parent_initializer.type_.as_function_sig().unwrap(), super_constructor_call, arg_list_types, ); @@ -4950,7 +4962,6 @@ impl<'a> TypeChecker<'a> { implements: original_type_class.implements.clone(), is_abstract: original_type_class.is_abstract, type_parameters: Some(type_params), - phase: original_type_class.phase, defined_in_phase: env.phase, docs: original_type_class.docs.clone(), std_construct_args: original_type_class.std_construct_args, @@ -5396,7 +5407,7 @@ impl<'a> TypeChecker<'a> { if property.name == FROM_JSON || property.name == TRY_FROM_JSON { // we need to validate that only structs with all valid json fields can have a fromJson method for (name, field) in s.fields(true) { - if !field.has_json_representation() { + if !field.type_.has_json_representation() { self.spanned_error_with_var( property, format!( @@ -5690,14 +5701,17 @@ impl<'a> TypeChecker<'a> { if let Some(parent_class) = parent_type.as_class() { // Parent class must be either the same phase as the child or, if the child is an inflight class, the parent can be an independent class - if (parent_class.phase == phase) || (phase == Phase::Inflight && parent_class.phase == Phase::Independent) { + if (parent_class.phase() == phase) || (phase == Phase::Inflight && parent_class.phase() == Phase::Independent) { (Some(parent_type), Some(parent_class.env.get_ref())) } else { self.spanned_error( parent, format!( "Class \"{}\" is an {} class and cannot extend {} class \"{}\"", - name, phase, parent_class.phase, parent_class.name + name, + phase, + parent_class.phase(), + parent_class.name ), ); (None, None) diff --git a/libs/wingc/src/type_check/jsii_importer.rs b/libs/wingc/src/type_check/jsii_importer.rs index 63de990bb10..c7cc121ab01 100644 --- a/libs/wingc/src/type_check/jsii_importer.rs +++ b/libs/wingc/src/type_check/jsii_importer.rs @@ -7,8 +7,8 @@ use crate::{ type_check::{ self, symbol_env::{StatementIdx, SymbolEnvKind}, - Class, FunctionParameter, FunctionSignature, Interface, ResolveSource, Struct, SymbolKind, Type, TypeRef, Types, - CLASS_INIT_NAME, + Class, ClassLike, FunctionParameter, FunctionSignature, Interface, ResolveSource, Struct, SymbolKind, Type, + TypeRef, Types, CLASS_INIT_NAME, }, CONSTRUCT_BASE_CLASS, WINGSDK_ASSEMBLY_NAME, WINGSDK_DURATION, WINGSDK_JSON, WINGSDK_MUT_JSON, WINGSDK_RESOURCE, }; @@ -655,7 +655,7 @@ impl<'a> JsiiImporter<'a> { "Base class {} of {} is not a class", base_class_type, type_name )); - class_phase = base_class.phase; + class_phase = base_class.phase(); Some(base_class.env.get_ref()) } else { None @@ -701,7 +701,6 @@ impl<'a> JsiiImporter<'a> { implements: vec![], is_abstract: jsii_class.abstract_.unwrap_or(false), type_parameters: type_params, - phase: class_phase, defined_in_phase: Phase::Preflight, docs: Docs::from(&jsii_class.docs), std_construct_args: false, // Temporary value, will be updated once we parse the initializer args From 4e82c45c909e8ce8d3fd1cc316586064619f2326 Mon Sep 17 00:00:00 2001 From: Yoav Steinberg Date: Mon, 12 Feb 2024 14:41:08 +0200 Subject: [PATCH 07/78] better handling of lifting host agnostic types --- libs/wingc/src/type_check.rs | 2 +- libs/wingsdk/src/core/lifting.ts | 26 ++++++++++++++++++++++---- 2 files changed, 23 insertions(+), 5 deletions(-) diff --git a/libs/wingc/src/type_check.rs b/libs/wingc/src/type_check.rs index 1d1a2788441..6812f02cde7 100644 --- a/libs/wingc/src/type_check.rs +++ b/libs/wingc/src/type_check.rs @@ -5432,7 +5432,7 @@ impl<'a> TypeChecker<'a> { format!("Class \"{c}\" contains a member \"{property}\" but it is not static"), ); } - // If the property is phase independent then but it's a method call with inflight + // If the property is phase independent but it's a method call with inflight // args then treat it as an inflight property let phase = if v.phase == Phase::Independent && callee_with_inflight_args { Phase::Inflight diff --git a/libs/wingsdk/src/core/lifting.ts b/libs/wingsdk/src/core/lifting.ts index a76e51772e3..f2d6b376ecf 100644 --- a/libs/wingsdk/src/core/lifting.ts +++ b/libs/wingsdk/src/core/lifting.ts @@ -162,10 +162,13 @@ export function onLiftObject( break; case "function": - // If the object is actually a resource type, call the type's _registerTypeOnLift() static method - if (isLiftableType(obj)) { + // If the object is actually a resource type, call the type's onLiftType() static method + if (isHostedLiftableType(obj)) { obj.onLiftType(host, ops); return; + } else if (isLiftableType(obj)) { + // If this is a liftable type that is host agnostic, we don't need to do anything. + return; } break; } @@ -229,14 +232,18 @@ export function onLiftMatrix( } } +function isHostedLiftableType(t: any): t is IHostedLiftableType { + return isLiftableType(t) && typeof (t as any).onLiftType === "function"; +} + function isLiftableType(t: any): t is ILiftableType { - return t !== undefined && typeof t.onLiftType === "function"; + return t !== undefined && typeof t._toInflightType === "function"; } /** * Represents a type with static methods that may have other things to lift. */ -export interface ILiftableType { +export interface IHostedLiftableType extends ILiftableType { /** * A hook called by the Wing compiler once for each inflight host that needs to * use this type inflight. The list of requested inflight methods @@ -247,3 +254,14 @@ export interface ILiftableType { */ onLiftType(host: IInflightHost, ops: string[]): void; } + +/** + * Represents a type that can be lifted to an inflight type. + */ +export interface ILiftableType { + /** + * A hook called by the Wing compiler to lift this type to an inflight type. + * @internal + */ + _toInflightType(): string; +} From 5f7ddb6249ee1e70df6eb6b62fe8474c288b3b1d Mon Sep 17 00:00:00 2001 From: Yoav Steinberg Date: Mon, 12 Feb 2024 16:50:48 +0200 Subject: [PATCH 08/78] correctly handle `onLift` of synthetic resource type generated by `toLifeableModuleType` --- libs/wingsdk/src/core/lifting.ts | 26 ++++++++++++++++++++------ 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/libs/wingsdk/src/core/lifting.ts b/libs/wingsdk/src/core/lifting.ts index f2d6b376ecf..c960d89dd25 100644 --- a/libs/wingsdk/src/core/lifting.ts +++ b/libs/wingsdk/src/core/lifting.ts @@ -153,6 +153,11 @@ export function onLiftObject( return; } + // This might actually be a synthetic resource type generated by `toLifeableModuleType` + if (onLiftTypeObject(host, obj, ops)) { + return; + } + // structs are just plain objects if (obj.constructor.name === "Object") { Object.values(obj).forEach((item) => onLiftObject(item, host, ops)); @@ -162,12 +167,8 @@ export function onLiftObject( break; case "function": - // If the object is actually a resource type, call the type's onLiftType() static method - if (isHostedLiftableType(obj)) { - obj.onLiftType(host, ops); - return; - } else if (isLiftableType(obj)) { - // If this is a liftable type that is host agnostic, we don't need to do anything. + // Try to treat this as a resource type + if (onLiftTypeObject(host, obj, ops)) { return; } break; @@ -178,6 +179,19 @@ export function onLiftObject( ); } +function onLiftTypeObject(host: IInflightHost, type_obj: any, ops: string[]): boolean { + // If the object is actually a resource type, call the type's onLiftType() static method + if (isHostedLiftableType(type_obj)) { + type_obj.onLiftType(host, ops); + return true; + } else if (isLiftableType(type_obj)) { + // If this is a liftable type that is host agnostic, we don't need to do anything. + return true; + } + return false; +} + + /** * Binds a collection of preflight objects to an inflight host, as part of the lifting process. * From 39428172fa0967b4e02cb4089b9cf0404049e1e5 Mon Sep 17 00:00:00 2001 From: Yoav Steinberg Date: Mon, 12 Feb 2024 17:57:57 +0200 Subject: [PATCH 09/78] treat class phase based on code modifier (chuck auto-phase idea for now) --- libs/wingc/src/docs.rs | 2 +- libs/wingc/src/jsify.rs | 2 +- libs/wingc/src/lifting.rs | 2 +- libs/wingc/src/type_check.rs | 78 +++++++++++----------- libs/wingc/src/type_check/jsii_importer.rs | 7 +- 5 files changed, 45 insertions(+), 46 deletions(-) diff --git a/libs/wingc/src/docs.rs b/libs/wingc/src/docs.rs index db2d33238f1..c57b6da02c4 100644 --- a/libs/wingc/src/docs.rs +++ b/libs/wingc/src/docs.rs @@ -387,7 +387,7 @@ fn render_class(c: &Class) -> String { } render_docs(&mut markdown, &c.docs); - if matches!(c.phase(), Phase::Preflight | Phase::Independent) { + if matches!(c.phase, Phase::Preflight | Phase::Independent) { if let Some(initializer) = c.get_method(&Symbol::global(CLASS_INIT_NAME)) { let function_sig = initializer.type_.as_function_sig().unwrap(); if function_sig.parameters.len() > 0 { diff --git a/libs/wingc/src/jsify.rs b/libs/wingc/src/jsify.rs index 9e60562dbe5..3b7b3bb6592 100644 --- a/libs/wingc/src/jsify.rs +++ b/libs/wingc/src/jsify.rs @@ -1902,7 +1902,7 @@ fn parent_class_phase(ctx: &JSifyContext<'_>) -> Phase { .expect("a parent class") .as_class() .expect("a class") - .phase(); + .phase; parent_class_phase } diff --git a/libs/wingc/src/lifting.rs b/libs/wingc/src/lifting.rs index 9f281509581..7f404fe78f2 100644 --- a/libs/wingc/src/lifting.rs +++ b/libs/wingc/src/lifting.rs @@ -284,7 +284,7 @@ impl<'a> Visit<'a> for LiftVisitor<'a> { if let Some(class) = expr_type.as_class() { //let tmp_udt = UserDefinedType::for_name(&class.name); //let class_defined_in = get_udt_definition_phase(&tmp_udt, v.ctx.current_env().expect("an env")).expect("a phase"); - if class.phase() == Phase::Inflight && class.defined_in_phase == Phase::Preflight { + if class.phase == Phase::Inflight && class.defined_in_phase == Phase::Preflight { if let Some(property) = v.ctx.current_property() { let m = v.ctx.current_method().map(|(m,_)|m).expect("a method"); //println!("Access to {property} of preflight defined inflight class {expr_type}, should qualify method {m}!"); diff --git a/libs/wingc/src/type_check.rs b/libs/wingc/src/type_check.rs index 6812f02cde7..0bad3713c5e 100644 --- a/libs/wingc/src/type_check.rs +++ b/libs/wingc/src/type_check.rs @@ -324,9 +324,10 @@ pub struct Class { pub fqn: Option, pub is_abstract: bool, pub type_parameters: Option>, + pub phase: Phase, pub docs: Docs, pub lifts: Option, - pub defined_in_phase: Phase, // TODO: naming: maybe this should just be `phase` while `phase` should be `defauld_member_phase`? + pub defined_in_phase: Phase, // TODO: naming: maybe this should just be `phase` while `phase` should be `default_member_phase`? // Preflight classes are CDK Constructs which means they have a scope and id as their first arguments // this is natively supported by wing using the `as` `in` keywords. However theoretically it is possible @@ -443,31 +444,31 @@ pub trait ClassLike: Display { } } - fn phase(&self) -> Phase { - // A class is considered a "preflight class" if it has any preflight fields. - // Having a preflight state means that different instances of the class - // might access different preflight data. Such instances need to be lifted - // into inflight individually. Non preflight class instances don't need to be - // lifted and can therefore be instantiated inflight. - if self - .fields(true) - .any(|(_, vi)| vi.kind == VariableKind::InstanceMember && vi.phase == Phase::Preflight) - { - return Phase::Preflight; - } - - // If all memebers are phase independent, then this class is phase independent - if self - .get_env() - .iter(true) - .all(|(_, v, _)| v.as_variable().unwrap().phase == Phase::Independent) - { - return Phase::Independent; - } - - // Otherwise, this is an inflight class - Phase::Inflight - } + // fn phase(&self) -> Phase { + // // A class is considered a "preflight class" if it has any preflight fields. + // // Having a preflight state means that different instances of the class + // // might access different preflight data. Such instances need to be lifted + // // into inflight individually. Non preflight class instances don't need to be + // // lifted and can therefore be instantiated inflight. + // if self + // .fields(true) + // .any(|(_, vi)| vi.kind == VariableKind::InstanceMember && vi.phase == Phase::Preflight) + // { + // return Phase::Preflight; + // } + + // // If all memebers are phase independent, then this class is phase independent + // if self + // .get_env() + // .iter(true) + // .all(|(_, v, _)| v.as_variable().unwrap().phase == Phase::Independent) + // { + // return Phase::Independent; + // } + + // // Otherwise, this is an inflight class + // Phase::Inflight + // } } impl ClassLike for Interface { @@ -950,7 +951,7 @@ unsafe impl Send for TypeRef {} impl TypeRef { pub fn as_preflight_class(&self) -> Option<&Class> { if let Type::Class(ref class) = **self { - if class.phase() == Phase::Preflight { + if class.phase == Phase::Preflight { return Some(class); } } @@ -1074,7 +1075,7 @@ impl TypeRef { pub fn is_preflight_class(&self) -> bool { if let Type::Class(ref class) = **self { - return class.phase() == Phase::Preflight; + return class.phase == Phase::Preflight; } return false; @@ -1192,7 +1193,7 @@ impl TypeRef { Type::Function(sig) => sig.phase == Phase::Inflight, // only preflight classes can be captured - Type::Class(c) => c.phase() == Phase::Preflight, + Type::Class(c) => c.phase == Phase::Preflight, } } @@ -2176,7 +2177,7 @@ impl<'a> TypeChecker<'a> { // error if we are trying to instantiate a preflight in a static method // without an explicit scope (there is no "this" to use as the scope) - if class.phase() == Phase::Preflight && obj_scope.is_none() { + if class.phase == Phase::Preflight && obj_scope.is_none() { // check if there is a "this" symbol in the current environment let has_this = env.lookup(&"this".into(), Some(self.ctx.current_stmt_idx())).is_some(); @@ -2197,16 +2198,14 @@ impl<'a> TypeChecker<'a> { } } - if class.phase() == Phase::Independent || env.phase == class.phase() { + if class.phase == Phase::Independent || env.phase == class.phase { (&class.env, &class.name) } else { self.spanned_error( exp, format!( "Cannot create {} class \"{}\" in {} phase", - class.phase(), - class.name, - env.phase + class.phase, class.name, env.phase ), ); return (self.types.error(), Phase::Independent); @@ -3889,6 +3888,7 @@ impl<'a> TypeChecker<'a> { parent: parent_class, implements: impl_interfaces.clone(), is_abstract: false, + phase: ast_class.phase, defined_in_phase: env.phase, type_parameters: None, // TODO no way to have generic args in wing yet docs: Docs::default(), @@ -4575,7 +4575,7 @@ impl<'a> TypeChecker<'a> { // If the parent class is phase independent then its init name is just "init" regadless of // whether we're inflight or not. - let parent_init_name = if parent_class.as_class().unwrap().phase() == Phase::Independent { + let parent_init_name = if parent_class.as_class().unwrap().phase == Phase::Independent { CLASS_INIT_NAME } else { init_name @@ -4962,6 +4962,7 @@ impl<'a> TypeChecker<'a> { implements: original_type_class.implements.clone(), is_abstract: original_type_class.is_abstract, type_parameters: Some(type_params), + phase: original_type_class.phase, defined_in_phase: env.phase, docs: original_type_class.docs.clone(), std_construct_args: original_type_class.std_construct_args, @@ -5701,17 +5702,14 @@ impl<'a> TypeChecker<'a> { if let Some(parent_class) = parent_type.as_class() { // Parent class must be either the same phase as the child or, if the child is an inflight class, the parent can be an independent class - if (parent_class.phase() == phase) || (phase == Phase::Inflight && parent_class.phase() == Phase::Independent) { + if (parent_class.phase == phase) || (phase == Phase::Inflight && parent_class.phase == Phase::Independent) { (Some(parent_type), Some(parent_class.env.get_ref())) } else { self.spanned_error( parent, format!( "Class \"{}\" is an {} class and cannot extend {} class \"{}\"", - name, - phase, - parent_class.phase(), - parent_class.name + name, phase, parent_class.phase, parent_class.name ), ); (None, None) diff --git a/libs/wingc/src/type_check/jsii_importer.rs b/libs/wingc/src/type_check/jsii_importer.rs index c7cc121ab01..63de990bb10 100644 --- a/libs/wingc/src/type_check/jsii_importer.rs +++ b/libs/wingc/src/type_check/jsii_importer.rs @@ -7,8 +7,8 @@ use crate::{ type_check::{ self, symbol_env::{StatementIdx, SymbolEnvKind}, - Class, ClassLike, FunctionParameter, FunctionSignature, Interface, ResolveSource, Struct, SymbolKind, Type, - TypeRef, Types, CLASS_INIT_NAME, + Class, FunctionParameter, FunctionSignature, Interface, ResolveSource, Struct, SymbolKind, Type, TypeRef, Types, + CLASS_INIT_NAME, }, CONSTRUCT_BASE_CLASS, WINGSDK_ASSEMBLY_NAME, WINGSDK_DURATION, WINGSDK_JSON, WINGSDK_MUT_JSON, WINGSDK_RESOURCE, }; @@ -655,7 +655,7 @@ impl<'a> JsiiImporter<'a> { "Base class {} of {} is not a class", base_class_type, type_name )); - class_phase = base_class.phase(); + class_phase = base_class.phase; Some(base_class.env.get_ref()) } else { None @@ -701,6 +701,7 @@ impl<'a> JsiiImporter<'a> { implements: vec![], is_abstract: jsii_class.abstract_.unwrap_or(false), type_parameters: type_params, + phase: class_phase, defined_in_phase: Phase::Preflight, docs: Docs::from(&jsii_class.docs), std_construct_args: false, // Temporary value, will be updated once we parse the initializer args From 9df10621e6eee97d41a0bf726a208ab94752b09a Mon Sep 17 00:00:00 2001 From: Yoav Steinberg Date: Mon, 12 Feb 2024 19:45:59 +0200 Subject: [PATCH 10/78] back to lifting all preflight expressions referencing inflight closures Because the type system can't distinguish between a closure class (which needs to be lifted) and a regular function type... Also lift on reference and not all call, by assuming a ref to a closure will actually call it later on, we can correctly lift (and setup permissions) for closures stored in collections (for example). This is a special exception to our qualification rules, since closures only have a single method (`handle`) so we can implicitly qualify it. --- libs/wingc/src/lifting.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/wingc/src/lifting.rs b/libs/wingc/src/lifting.rs index 7f404fe78f2..ec4660acf67 100644 --- a/libs/wingc/src/lifting.rs +++ b/libs/wingc/src/lifting.rs @@ -242,7 +242,7 @@ impl<'a> Visit<'a> for LiftVisitor<'a> { let property = if let Some(property) = v.ctx.current_property() { Some(property) - } else if expr_type.is_closure_class() && node.is_callee { + } else if expr_type.is_closure() { // this is the case where we are lifting a "closure class" (a preflight class that has an inflight `handle` // method is being called) the reason we might not have "property" set is because closure classes might be // syntheticaly generated by the compiler from closures. From 36b89b8d836a3d7755e867d20524dbfdd72b4e1c Mon Sep 17 00:00:00 2001 From: Yoav Steinberg Date: Mon, 12 Feb 2024 20:36:50 +0200 Subject: [PATCH 11/78] visit all udt refs before qualifying inflight type lifts so we're sure the type is lifted --- libs/wingc/src/lifting.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/libs/wingc/src/lifting.rs b/libs/wingc/src/lifting.rs index ec4660acf67..e676f5c49b5 100644 --- a/libs/wingc/src/lifting.rs +++ b/libs/wingc/src/lifting.rs @@ -278,7 +278,13 @@ impl<'a> Visit<'a> for LiftVisitor<'a> { // } // } // } - else if expr_phase == Phase::Inflight { + + + // Before we continue lets dive into this (non-preflight) expression to see if we need to lift any parts of it + visit::visit_expr(v, node); + + // Check if this is an inflight class defined preflight and if we need to qualify the lift + if expr_phase == Phase::Inflight { // If this is a reference to an inflight class defined preflight then we need to lift it and qualify it with the // current property if let Some(class) = expr_type.as_class() { @@ -299,8 +305,6 @@ impl<'a> Visit<'a> for LiftVisitor<'a> { } } } - - visit::visit_expr(v, node); }); } From d3ef0cc23b987abaac11f237f8411c801ba74fde Mon Sep 17 00:00:00 2001 From: Yoav Steinberg Date: Fri, 16 Feb 2024 16:47:02 +0200 Subject: [PATCH 12/78] Qualify inflight class usage even when type not explicitly lifted --- libs/wingc/src/jsify.rs | 9 +++++++++ libs/wingc/src/lifting.rs | 15 +++++---------- libs/wingc/src/type_check.rs | 11 +++++++++++ 3 files changed, 25 insertions(+), 10 deletions(-) diff --git a/libs/wingc/src/jsify.rs b/libs/wingc/src/jsify.rs index 3b7b3bb6592..5f5d470d2e2 100644 --- a/libs/wingc/src/jsify.rs +++ b/libs/wingc/src/jsify.rs @@ -1506,10 +1506,19 @@ impl<'a> JSifier<'a> { code.add_code(self.jsify_register_bind_method(class, class_type, BindMethod::Type, ctx)); code.close("}"); + code.line(format!( + "const {} = {};", + self.unique_class_alias(class_type), + class.name + )); code }) } + pub fn unique_class_alias(&self, type_: TypeRef) -> String { + format!("$UniqueClassAlias{}", type_.as_class().unwrap().uid) + } + fn jsify_preflight_constructor(&self, class: &AstClass, ctx: &mut JSifyContext) -> CodeMaker { let mut code = new_code!( &class.name.span, diff --git a/libs/wingc/src/lifting.rs b/libs/wingc/src/lifting.rs index e676f5c49b5..8f3dd8744cf 100644 --- a/libs/wingc/src/lifting.rs +++ b/libs/wingc/src/lifting.rs @@ -283,22 +283,17 @@ impl<'a> Visit<'a> for LiftVisitor<'a> { // Before we continue lets dive into this (non-preflight) expression to see if we need to lift any parts of it visit::visit_expr(v, node); - // Check if this is an inflight class defined preflight and if we need to qualify the lift + // Check if this is an inflight class defined preflight and if we need to qualify the lift with the current property if expr_phase == Phase::Inflight { - // If this is a reference to an inflight class defined preflight then we need to lift it and qualify it with the - // current property if let Some(class) = expr_type.as_class() { - //let tmp_udt = UserDefinedType::for_name(&class.name); - //let class_defined_in = get_udt_definition_phase(&tmp_udt, v.ctx.current_env().expect("an env")).expect("a phase"); if class.phase == Phase::Inflight && class.defined_in_phase == Phase::Preflight { if let Some(property) = v.ctx.current_property() { let m = v.ctx.current_method().map(|(m,_)|m).expect("a method"); - //println!("Access to {property} of preflight defined inflight class {expr_type}, should qualify method {m}!"); let mut lifts = v.lifts_stack.pop().unwrap(); - // Get convert the expression to its type - // let code = v.jsify_expr_to_type(&code); - //lifts.lift(v.ctx.current_method().map(|(m,_)|m), Some(property), &code, false, Some(expr_type)); - lifts.qualify_lifted_type(m, property, expr_type); + // Get preflight code that references the type of the class so we can qualify the lift, note we use a unique + // type alias here since we might not have the actual type name available in scope here. + let code = &v.jsify.unique_class_alias(expr_type); + lifts.lift(m, Some(property), code, false, Some(expr_type)); v.lifts_stack.push(lifts); return; } diff --git a/libs/wingc/src/type_check.rs b/libs/wingc/src/type_check.rs index 0bad3713c5e..2bfbb428108 100644 --- a/libs/wingc/src/type_check.rs +++ b/libs/wingc/src/type_check.rs @@ -334,6 +334,10 @@ pub struct Class { // to have a construct which does not have these arguments, in which case we can't use the `as` `in` keywords // and instead the user will need to pass the relevant args to the class's init method. pub std_construct_args: bool, + + // Unique identifier for this class type, used to generate a unique type alias for this class se we can + // reference it regardless of type name shadowing. + pub uid: usize, } impl Class { pub(crate) fn set_lifts(&mut self, lifts: Lifts) { @@ -1763,6 +1767,9 @@ pub struct TypeChecker<'a> { is_in_mut_json: bool, + /// Class counter, used to generate unique names class types + class_counter: usize, + ctx: VisitContext, } @@ -1793,6 +1800,7 @@ impl<'a> TypeChecker<'a> { jsii_imports, is_in_mut_json: false, ctx: VisitContext::new(), + class_counter: 0, } } @@ -3894,7 +3902,9 @@ impl<'a> TypeChecker<'a> { docs: Docs::default(), std_construct_args: ast_class.phase == Phase::Preflight, lifts: None, + uid: self.class_counter, }; + self.class_counter += 1; let mut class_type = self.types.add_type(Type::Class(class_spec)); match env.define( &ast_class.name, @@ -4967,6 +4977,7 @@ impl<'a> TypeChecker<'a> { docs: original_type_class.docs.clone(), std_construct_args: original_type_class.std_construct_args, lifts: None, + uid: original_type_class.uid, }); // TODO: here we add a new type regardless whether we already "hydrated" `original_type` with these `type_params`. Cache! From f8dd4620de0354dcf0177653ec8e45f3b7260e2a Mon Sep 17 00:00:00 2001 From: Yoav Steinberg Date: Fri, 16 Feb 2024 16:49:37 +0200 Subject: [PATCH 13/78] test qualify inflight type when not available in scope --- libs/wingc/src/jsify/tests.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/libs/wingc/src/jsify/tests.rs b/libs/wingc/src/jsify/tests.rs index 6b9ccd7a1c8..42906166b3a 100644 --- a/libs/wingc/src/jsify/tests.rs +++ b/libs/wingc/src/jsify/tests.rs @@ -43,6 +43,29 @@ fn free_inflight_obj_from_inflight() { ); } +#[test] +fn qualify_inflight_type_refrencing_preflight_instance() { + assert_compile_ok!( + r#" + class PreflightC { + pub inflight bar() {} + } + let pc = new PreflightC(); + + inflight class InflightC { + pub foo() { + pc.bar(); + } + } + + test "test" { + let ic = new InflightC(); + ic.foo(); + } + "# + ); +} + #[test] fn call_static_inflight_from_static_inflight() { assert_compile_ok!( From cb94d46f5e923b736703e8e326836fadeaf79e7d Mon Sep 17 00:00:00 2001 From: Yoav Steinberg Date: Fri, 16 Feb 2024 17:02:47 +0200 Subject: [PATCH 14/78] test --- ...ight_class_capture_preflight_object.test.w | 37 ++++++++++++------- 1 file changed, 23 insertions(+), 14 deletions(-) diff --git a/examples/tests/valid/inflight_class_capture_preflight_object.test.w b/examples/tests/valid/inflight_class_capture_preflight_object.test.w index 1dfeaceedaf..da89f06e311 100644 --- a/examples/tests/valid/inflight_class_capture_preflight_object.test.w +++ b/examples/tests/valid/inflight_class_capture_preflight_object.test.w @@ -1,18 +1,27 @@ -// https://github.com/winglang/wing/issues/2730 -// FAILING: +bring cloud; -// bring cloud; +let b = new cloud.Bucket(); -// let b = new cloud.Bucket(); -// let myConst = "bang bang"; +inflight class Foo { + pub uploadToBucket(k: str, value: str) { + b.put(k, value); + assert(b.get(k) == value); + log(b.get(k)); + } +} -// inflight class Foo { -// uploadToBucket(k: str, value: str) { -// b.put(k, value); -// } -// } +test "inflight class captures preflight resource" { + let f = new Foo(); + f.uploadToBucket("hello.txt", "world"); +} -// test "inflight class captures preflight resource" { -// let f = new Foo(); -// f.uploadToBucket("hello.txt", "world"); -// } +let getFoo = inflight () => { + return new Foo(); +}; + +test "inflight class qualified without explicit reference" { + // Get instance of Foo without mentioning the type + let foo = getFoo(); + // Now Foo needs to be qualified correcly + foo.uploadToBucket("greetings.txt", "universe"); +} From b8339820de90b44031aa6961cc58bd38b1716114 Mon Sep 17 00:00:00 2001 From: Yoav Steinberg Date: Fri, 16 Feb 2024 17:13:18 +0200 Subject: [PATCH 15/78] cleanup --- .../tests/valid/inflight_class_capture_preflight_object.test.w | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/tests/valid/inflight_class_capture_preflight_object.test.w b/examples/tests/valid/inflight_class_capture_preflight_object.test.w index da89f06e311..ea351aba51c 100644 --- a/examples/tests/valid/inflight_class_capture_preflight_object.test.w +++ b/examples/tests/valid/inflight_class_capture_preflight_object.test.w @@ -6,7 +6,6 @@ inflight class Foo { pub uploadToBucket(k: str, value: str) { b.put(k, value); assert(b.get(k) == value); - log(b.get(k)); } } From 9fee686bb008981d2da81a7fb46d284e6b6931fd Mon Sep 17 00:00:00 2001 From: Yoav Steinberg Date: Fri, 16 Feb 2024 17:17:35 +0200 Subject: [PATCH 16/78] generate less class aliases (smaller snapshot diff) --- libs/wingc/src/jsify.rs | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/libs/wingc/src/jsify.rs b/libs/wingc/src/jsify.rs index 5f5d470d2e2..6a8e27f1755 100644 --- a/libs/wingc/src/jsify.rs +++ b/libs/wingc/src/jsify.rs @@ -1506,11 +1506,17 @@ impl<'a> JSifier<'a> { code.add_code(self.jsify_register_bind_method(class, class_type, BindMethod::Type, ctx)); code.close("}"); - code.line(format!( - "const {} = {};", - self.unique_class_alias(class_type), - class.name - )); + + // Inflight classes might need their type to be lift-qualified (onLift), but their type name might not be necessarily avaialble + // at the scope when they are qualified (it might even be shadowed by another type name). Here we generate a unique + // type name to be used in such cases. + if class.phase == Phase::Inflight { + code.line(format!( + "const {} = {};", + self.unique_class_alias(class_type), + class.name + )); + } code }) } From 463568c9531e054cd52673abaf8b23cc48cc7b4c Mon Sep 17 00:00:00 2001 From: Yoav Steinberg Date: Fri, 16 Feb 2024 17:28:43 +0200 Subject: [PATCH 17/78] added test --- .../inflight_class_capture_preflight_object.test.w | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/examples/tests/valid/inflight_class_capture_preflight_object.test.w b/examples/tests/valid/inflight_class_capture_preflight_object.test.w index ea351aba51c..d4ed2a385d5 100644 --- a/examples/tests/valid/inflight_class_capture_preflight_object.test.w +++ b/examples/tests/valid/inflight_class_capture_preflight_object.test.w @@ -24,3 +24,15 @@ test "inflight class qualified without explicit reference" { // Now Foo needs to be qualified correcly foo.uploadToBucket("greetings.txt", "universe"); } + +test "inflight class defined inflight captures preflight object" { + class Foo2 { + pub uploadToBucket() { + b.put("x", "y"); + assert(b.get("x") == "y"); + } + } + + let f = new Foo2(); + f.uploadToBucket(); +} From 916b54fb371e52a1de9bc13a24a0a75daba2c3fd Mon Sep 17 00:00:00 2001 From: Yoav Steinberg Date: Fri, 16 Feb 2024 17:54:31 +0200 Subject: [PATCH 18/78] typo --- libs/wingc/src/jsify.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/wingc/src/jsify.rs b/libs/wingc/src/jsify.rs index 6a8e27f1755..901457a8177 100644 --- a/libs/wingc/src/jsify.rs +++ b/libs/wingc/src/jsify.rs @@ -1823,7 +1823,7 @@ impl<'a> JSifier<'a> { .expect(&format!("method \"{m}\" doesn't exist in {class_name}")) .kind; // TODO: the following hints that instead of `onLiftType` and `onLift` we need to mark each lift as a - // field lift or a type lift. Then for each instance lifts we need to make sure to call their typeLiftToo. + // field lift or a type lift. Then for each instance lifts we need to make sure to call their typeLift too. if class.phase == Phase::Inflight { // All lifts in inflight classes are "type" lifts since `this` has no preflight fields which need to be // lifted based on the object's instance From 0b149b668dde10cda1f2b49a6d28894f35d374af Mon Sep 17 00:00:00 2001 From: Yoav Steinberg Date: Fri, 16 Feb 2024 18:50:02 +0200 Subject: [PATCH 19/78] test static method lifts of inflight class --- .../valid/inflight_class_capture_preflight_object.test.w | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/examples/tests/valid/inflight_class_capture_preflight_object.test.w b/examples/tests/valid/inflight_class_capture_preflight_object.test.w index d4ed2a385d5..eaedad92c3a 100644 --- a/examples/tests/valid/inflight_class_capture_preflight_object.test.w +++ b/examples/tests/valid/inflight_class_capture_preflight_object.test.w @@ -7,6 +7,10 @@ inflight class Foo { b.put(k, value); assert(b.get(k) == value); } + + static pub fooStatic() { + b.list(); + } } test "inflight class captures preflight resource" { @@ -14,6 +18,11 @@ test "inflight class captures preflight resource" { f.uploadToBucket("hello.txt", "world"); } +test "inflight class type captures preflight resource" { + Foo.fooStatic(); +} + + let getFoo = inflight () => { return new Foo(); }; From 48ecb71d3c0f2c80b7f1bd457c9686940daf4528 Mon Sep 17 00:00:00 2001 From: Yoav Steinberg Date: Sat, 17 Feb 2024 16:22:59 +0200 Subject: [PATCH 20/78] fix after merge --- libs/wingc/src/type_check/jsii_importer.rs | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libs/wingc/src/type_check/jsii_importer.rs b/libs/wingc/src/type_check/jsii_importer.rs index 71003f7c657..714007abff9 100644 --- a/libs/wingc/src/type_check/jsii_importer.rs +++ b/libs/wingc/src/type_check/jsii_importer.rs @@ -765,6 +765,10 @@ impl<'a> JsiiImporter<'a> { docs: Docs::from(&jsii_class.docs), std_construct_args: false, // Temporary value, will be updated once we parse the initializer args lifts: None, + + // uid is used to create unique names class types so we can access the correct type regradless of type name shadowing, + // this isn't relevant for imported types (that aren't code generated), so we can default to 0 + uid: 0, }; let mut new_type = self.wing_types.add_type(Type::Class(class_spec)); self.register_jsii_type(&jsii_class_fqn, &new_type_symbol, new_type); From c8c8678d7adecb8d58e1ced038930a23f0773b7e Mon Sep 17 00:00:00 2001 From: "monada-bot[bot]" Date: Sat, 17 Feb 2024 14:36:41 +0000 Subject: [PATCH 21/78] chore: self mutation (e2e-1of2.diff) Signed-off-by: monada-bot[bot] --- .../valid/bring_jsii.test.w_compile_tf-aws.md | 1 + ..._static_of_myself.test.w_compile_tf-aws.md | 16 +- .../valid/doubler.test.w_compile_tf-aws.md | 2 + ...as_struct_members.test.w_compile_tf-aws.md | 7 +- ..._preflight_object.test.w_compile_tf-aws.md | 359 ++++++++++++++++++ ...apture_preflight_object.test.w_test_sim.md | 7 +- .../inflight_init.test.w_compile_tf-aws.md | 17 +- ...erit_stdlib_class.test.w_compile_tf-aws.md | 1 + ...ce_class_inflight.test.w_compile_tf-aws.md | 1 + .../valid/issue_2889.test.w_compile_tf-aws.md | 3 + ...t_shared_resource.test.w_compile_tf-aws.md | 1 + ...ft_with_phase_ind.test.w_compile_tf-aws.md | 1 + ..._after_class_init.test.w_compile_tf-aws.md | 1 + .../valid/on_lift.test.w_compile_tf-aws.md | 2 + .../valid/redis.test.w_compile_tf-aws.md | 1 + .../valid/resource.test.w_compile_tf-aws.md | 1 + .../struct_from_json.test.w_compile_tf-aws.md | 9 + 17 files changed, 417 insertions(+), 13 deletions(-) diff --git a/tools/hangar/__snapshots__/test_corpus/valid/bring_jsii.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/bring_jsii.test.w_compile_tf-aws.md index 230e60f4d84..b6ae8591058 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/bring_jsii.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/bring_jsii.test.w_compile_tf-aws.md @@ -84,6 +84,7 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$stdlib.core.toLiftableModuleType(stuff.HelloWorld, "jsii-code-samples", "HelloWorld"), []], [greeting, []], ], "$inflight_init": [ diff --git a/tools/hangar/__snapshots__/test_corpus/valid/call_static_of_myself.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/call_static_of_myself.test.w_compile_tf-aws.md index 839285eb60f..0e0c5c646d0 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/call_static_of_myself.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/call_static_of_myself.test.w_compile_tf-aws.md @@ -163,21 +163,21 @@ class $Root extends $stdlib.std.Resource { })()) `; } - get _liftMap() { + static get _liftTypeMap() { return ({ + "bar": [ + ], "callThis": [ + [Bar, ["bar"]], ], - "$inflight_init": [ + "init": [ ], - }); - } - static get _liftTypeMap() { - return ({ - "bar": [ + "$inflight_init": [ ], }); } } + const $UniqueClassAlias1 = Bar; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -207,6 +207,8 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$UniqueClassAlias1, ["callThis"]], + [Bar, ["bar"]], [Foo, ["foo"]], [foo, ["callThis"]], ], diff --git a/tools/hangar/__snapshots__/test_corpus/valid/doubler.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/doubler.test.w_compile_tf-aws.md index 301f4600efe..5708b2f0688 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/doubler.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/doubler.test.w_compile_tf-aws.md @@ -357,6 +357,8 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$stdlib.core.toLiftableModuleType(std.Json, "@winglang/sdk/std", "Json"), ["stringify"]], + [$stdlib.core.toLiftableModuleType(std.Number, "@winglang/sdk/std", "Number"), ["fromStr"]], [handler, ["handle"]], ], "$inflight_init": [ diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_as_struct_members.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_as_struct_members.test.w_compile_tf-aws.md index 572d6fb296b..dde0439b2a1 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_as_struct_members.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_as_struct_members.test.w_compile_tf-aws.md @@ -108,15 +108,18 @@ class $Root extends $stdlib.std.Resource { })()) `; } - get _liftMap() { + static get _liftTypeMap() { return ({ "get": [ ], + "init": [ + ], "$inflight_init": [ ], }); } } + const $UniqueClassAlias0 = Foo; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -144,6 +147,7 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [Foo, []], ], "$inflight_init": [ ], @@ -177,6 +181,7 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$UniqueClassAlias0, ["get"]], [getBar, ["handle"]], ], "$inflight_init": [ diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_capture_preflight_object.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_capture_preflight_object.test.w_compile_tf-aws.md index 3c75b317ca1..3ada96aec13 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_capture_preflight_object.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_capture_preflight_object.test.w_compile_tf-aws.md @@ -1,5 +1,133 @@ # [inflight_class_capture_preflight_object.test.w](../../../../../examples/tests/valid/inflight_class_capture_preflight_object.test.w) | compile | tf-aws +## inflight.$Closure1-1.js +```js +"use strict"; +const $helpers = require("@winglang/sdk/lib/helpers"); +module.exports = function({ $Foo }) { + class $Closure1 { + constructor({ }) { + const $obj = (...args) => this.handle(...args); + Object.setPrototypeOf($obj, this); + return $obj; + } + async handle() { + const f = (await (async () => {const o = new $Foo(); await o.$inflight_init?.(); return o; })()); + (await f.uploadToBucket("hello.txt", "world")); + } + } + return $Closure1; +} +//# sourceMappingURL=inflight.$Closure1-1.js.map +``` + +## inflight.$Closure2-1.js +```js +"use strict"; +const $helpers = require("@winglang/sdk/lib/helpers"); +module.exports = function({ $Foo }) { + class $Closure2 { + constructor({ }) { + const $obj = (...args) => this.handle(...args); + Object.setPrototypeOf($obj, this); + return $obj; + } + async handle() { + (await $Foo.fooStatic()); + } + } + return $Closure2; +} +//# sourceMappingURL=inflight.$Closure2-1.js.map +``` + +## inflight.$Closure3-1.js +```js +"use strict"; +const $helpers = require("@winglang/sdk/lib/helpers"); +module.exports = function({ $Foo }) { + class $Closure3 { + constructor({ }) { + const $obj = (...args) => this.handle(...args); + Object.setPrototypeOf($obj, this); + return $obj; + } + async handle() { + return (await (async () => {const o = new $Foo(); await o.$inflight_init?.(); return o; })()); + } + } + return $Closure3; +} +//# sourceMappingURL=inflight.$Closure3-1.js.map +``` + +## inflight.$Closure4-1.js +```js +"use strict"; +const $helpers = require("@winglang/sdk/lib/helpers"); +module.exports = function({ $getFoo }) { + class $Closure4 { + constructor({ }) { + const $obj = (...args) => this.handle(...args); + Object.setPrototypeOf($obj, this); + return $obj; + } + async handle() { + const foo = (await $getFoo()); + (await foo.uploadToBucket("greetings.txt", "universe")); + } + } + return $Closure4; +} +//# sourceMappingURL=inflight.$Closure4-1.js.map +``` + +## inflight.$Closure5-1.js +```js +"use strict"; +const $helpers = require("@winglang/sdk/lib/helpers"); +module.exports = function({ $b }) { + class $Closure5 { + constructor({ }) { + const $obj = (...args) => this.handle(...args); + Object.setPrototypeOf($obj, this); + return $obj; + } + async handle() { + class Foo2 { + async uploadToBucket() { + (await $b.put("x", "y")); + $helpers.assert($helpers.eq((await $b.get("x")), "y"), "b.get(\"x\") == \"y\""); + } + } + const f = (await (async () => {const o = new Foo2(); await o.$inflight_init?.(); return o; })()); + (await f.uploadToBucket()); + } + } + return $Closure5; +} +//# sourceMappingURL=inflight.$Closure5-1.js.map +``` + +## inflight.Foo-1.js +```js +"use strict"; +const $helpers = require("@winglang/sdk/lib/helpers"); +module.exports = function({ $b }) { + class Foo { + async uploadToBucket(k, value) { + (await $b.put(k, value)); + $helpers.assert($helpers.eq((await $b.get(k)), value), "b.get(k) == value"); + } + static async fooStatic() { + (await $b.list()); + } + } + return Foo; +} +//# sourceMappingURL=inflight.Foo-1.js.map +``` + ## main.tf.json ```json { @@ -15,6 +143,20 @@ "aws": [ {} ] + }, + "resource": { + "aws_s3_bucket": { + "cloudBucket": { + "//": { + "metadata": { + "path": "root/Default/Default/cloud.Bucket/Default", + "uniqueId": "cloudBucket" + } + }, + "bucket_prefix": "cloud-bucket-c87175e7-", + "force_destroy": false + } + } } } ``` @@ -28,9 +170,226 @@ const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; +const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + class Foo extends $stdlib.std.Resource { + constructor($scope, $id, ) { + super($scope, $id); + } + static _toInflightType() { + return ` + require("${$helpers.normalPath(__dirname)}/inflight.Foo-1.js")({ + $b: ${$stdlib.core.liftObject(b)}, + }) + `; + } + _toInflight() { + return ` + (await (async () => { + const FooClient = ${Foo._toInflightType()}; + const client = new FooClient({ + }); + if (client.$inflight_init) { await client.$inflight_init(); } + return client; + })()) + `; + } + static get _liftTypeMap() { + return ({ + "uploadToBucket": [ + [b, ["get", "put"]], + ], + "fooStatic": [ + [b, ["list"]], + ], + "init": [ + ], + "$inflight_init": [ + ], + }); + } + } + const $UniqueClassAlias0 = Foo; + class $Closure1 extends $stdlib.std.AutoIdResource { + _id = $stdlib.core.closureId(); + constructor($scope, $id, ) { + super($scope, $id); + $helpers.nodeof(this).hidden = true; + } + static _toInflightType() { + return ` + require("${$helpers.normalPath(__dirname)}/inflight.$Closure1-1.js")({ + $Foo: ${$stdlib.core.liftObject(Foo)}, + }) + `; + } + _toInflight() { + return ` + (await (async () => { + const $Closure1Client = ${$Closure1._toInflightType()}; + const client = new $Closure1Client({ + }); + if (client.$inflight_init) { await client.$inflight_init(); } + return client; + })()) + `; + } + get _liftMap() { + return ({ + "handle": [ + [$UniqueClassAlias0, ["uploadToBucket"]], + [Foo, []], + ], + "$inflight_init": [ + ], + }); + } + } + class $Closure2 extends $stdlib.std.AutoIdResource { + _id = $stdlib.core.closureId(); + constructor($scope, $id, ) { + super($scope, $id); + $helpers.nodeof(this).hidden = true; + } + static _toInflightType() { + return ` + require("${$helpers.normalPath(__dirname)}/inflight.$Closure2-1.js")({ + $Foo: ${$stdlib.core.liftObject(Foo)}, + }) + `; + } + _toInflight() { + return ` + (await (async () => { + const $Closure2Client = ${$Closure2._toInflightType()}; + const client = new $Closure2Client({ + }); + if (client.$inflight_init) { await client.$inflight_init(); } + return client; + })()) + `; + } + get _liftMap() { + return ({ + "handle": [ + [Foo, ["fooStatic"]], + ], + "$inflight_init": [ + ], + }); + } + } + class $Closure3 extends $stdlib.std.AutoIdResource { + _id = $stdlib.core.closureId(); + constructor($scope, $id, ) { + super($scope, $id); + $helpers.nodeof(this).hidden = true; + } + static _toInflightType() { + return ` + require("${$helpers.normalPath(__dirname)}/inflight.$Closure3-1.js")({ + $Foo: ${$stdlib.core.liftObject(Foo)}, + }) + `; + } + _toInflight() { + return ` + (await (async () => { + const $Closure3Client = ${$Closure3._toInflightType()}; + const client = new $Closure3Client({ + }); + if (client.$inflight_init) { await client.$inflight_init(); } + return client; + })()) + `; + } + get _liftMap() { + return ({ + "handle": [ + [Foo, []], + ], + "$inflight_init": [ + ], + }); + } + } + class $Closure4 extends $stdlib.std.AutoIdResource { + _id = $stdlib.core.closureId(); + constructor($scope, $id, ) { + super($scope, $id); + $helpers.nodeof(this).hidden = true; + } + static _toInflightType() { + return ` + require("${$helpers.normalPath(__dirname)}/inflight.$Closure4-1.js")({ + $getFoo: ${$stdlib.core.liftObject(getFoo)}, + }) + `; + } + _toInflight() { + return ` + (await (async () => { + const $Closure4Client = ${$Closure4._toInflightType()}; + const client = new $Closure4Client({ + }); + if (client.$inflight_init) { await client.$inflight_init(); } + return client; + })()) + `; + } + get _liftMap() { + return ({ + "handle": [ + [$UniqueClassAlias0, ["uploadToBucket"]], + [getFoo, ["handle"]], + ], + "$inflight_init": [ + ], + }); + } + } + class $Closure5 extends $stdlib.std.AutoIdResource { + _id = $stdlib.core.closureId(); + constructor($scope, $id, ) { + super($scope, $id); + $helpers.nodeof(this).hidden = true; + } + static _toInflightType() { + return ` + require("${$helpers.normalPath(__dirname)}/inflight.$Closure5-1.js")({ + $b: ${$stdlib.core.liftObject(b)}, + }) + `; + } + _toInflight() { + return ` + (await (async () => { + const $Closure5Client = ${$Closure5._toInflightType()}; + const client = new $Closure5Client({ + }); + if (client.$inflight_init) { await client.$inflight_init(); } + return client; + })()) + `; + } + get _liftMap() { + return ({ + "handle": [ + [b, ["get", "put"]], + ], + "$inflight_init": [ + ], + }); + } + } + const b = this.node.root.new("@winglang/sdk.cloud.Bucket", cloud.Bucket, this, "cloud.Bucket"); + this.node.root.new("@winglang/sdk.std.Test", std.Test, this, "test:inflight class captures preflight resource", new $Closure1(this, "$Closure1")); + this.node.root.new("@winglang/sdk.std.Test", std.Test, this, "test:inflight class type captures preflight resource", new $Closure2(this, "$Closure2")); + const getFoo = new $Closure3(this, "$Closure3"); + this.node.root.new("@winglang/sdk.std.Test", std.Test, this, "test:inflight class qualified without explicit reference", new $Closure4(this, "$Closure4")); + this.node.root.new("@winglang/sdk.std.Test", std.Test, this, "test:inflight class defined inflight captures preflight object", new $Closure5(this, "$Closure5")); } } const $PlatformManager = new $stdlib.platform.PlatformManager({platformPaths: $platforms}); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_capture_preflight_object.test.w_test_sim.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_capture_preflight_object.test.w_test_sim.md index 2be4c0ce123..3c8e725bb3a 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_capture_preflight_object.test.w_test_sim.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_capture_preflight_object.test.w_test_sim.md @@ -2,10 +2,13 @@ ## stdout.log ```log -pass ─ inflight_class_capture_preflight_object.test.wsim (no tests) +pass ─ inflight_class_capture_preflight_object.test.wsim » root/env0/test:inflight class captures preflight resource +pass ─ inflight_class_capture_preflight_object.test.wsim » root/env1/test:inflight class type captures preflight resource +pass ─ inflight_class_capture_preflight_object.test.wsim » root/env2/test:inflight class qualified without explicit reference +pass ─ inflight_class_capture_preflight_object.test.wsim » root/env3/test:inflight class defined inflight captures preflight object -Tests 1 passed (1) +Tests 4 passed (4) Test Files 1 passed (1) Duration ``` diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight_init.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight_init.test.w_compile_tf-aws.md index a0e4b3c093d..545491ee15d 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight_init.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight_init.test.w_compile_tf-aws.md @@ -217,10 +217,12 @@ class $Root extends $stdlib.std.Resource { })()) `; } - get _liftMap() { + static get _liftTypeMap() { return ({ "get_six": [ ], + "init": [ + ], "$inflight_init": [ [this, ["field1", "field2", "get_six"]], ], @@ -231,6 +233,7 @@ class $Root extends $stdlib.std.Resource { }); } } + const $UniqueClassAlias0 = Foo; class FooChild extends Foo { constructor($scope, $id, ) { super($scope, $id); @@ -253,8 +256,10 @@ class $Root extends $stdlib.std.Resource { })()) `; } - get _liftMap() { - return $stdlib.core.mergeLiftDeps(super._liftMap, { + static get _liftTypeMap() { + return $stdlib.core.mergeLiftDeps(super._liftTypeMap, { + "init": [ + ], "$inflight_init": [ [this, ["field3"]], ], @@ -263,6 +268,7 @@ class $Root extends $stdlib.std.Resource { }); } } + const $UniqueClassAlias1 = FooChild; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -290,6 +296,8 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$UniqueClassAlias0, ["field1", "field2"]], + [Foo, []], ], "$inflight_init": [ ], @@ -323,6 +331,8 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$UniqueClassAlias1, ["field1", "field2", "field3"]], + [FooChild, []], ], "$inflight_init": [ ], @@ -388,6 +398,7 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$stdlib.core.toLiftableModuleType(jsii_fixture.JsiiClass, "jsii-fixture", "JsiiClass"), []], ], "$inflight_init": [ ], diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inherit_stdlib_class.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inherit_stdlib_class.test.w_compile_tf-aws.md index 79260066993..fcb36dd11b2 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inherit_stdlib_class.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inherit_stdlib_class.test.w_compile_tf-aws.md @@ -383,6 +383,7 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$stdlib.core.toLiftableModuleType(http.Util, "@winglang/sdk/http", "Util"), ["get"]], [api.url, []], ], "$inflight_init": [ diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inheritance_class_inflight.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inheritance_class_inflight.test.w_compile_tf-aws.md index 991229fd87b..90194a1b9d6 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inheritance_class_inflight.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inheritance_class_inflight.test.w_compile_tf-aws.md @@ -188,6 +188,7 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$stdlib.core.toLiftableModuleType(expect.Util, "@winglang/sdk/expect", "Util"), ["equal"]], [foo, ["bang", "bug", "over_inflight"]], ], "$inflight_init": [ diff --git a/tools/hangar/__snapshots__/test_corpus/valid/issue_2889.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/issue_2889.test.w_compile_tf-aws.md index 39142b20d1c..f0320b4f01c 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/issue_2889.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/issue_2889.test.w_compile_tf-aws.md @@ -309,6 +309,7 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$stdlib.core.toLiftableModuleType(std.Json, "@winglang/sdk/std", "Json"), ["parse", "stringify"]], ], "$inflight_init": [ ], @@ -344,6 +345,8 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$stdlib.core.toLiftableModuleType(http.Util, "@winglang/sdk/http", "Util"), ["get"]], + [$stdlib.core.toLiftableModuleType(std.Json, "@winglang/sdk/std", "Json"), ["parse"]], [api.url, []], ], "$inflight_init": [ diff --git a/tools/hangar/__snapshots__/test_corpus/valid/lift_shared_resource.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/lift_shared_resource.test.w_compile_tf-aws.md index 41ae4659a94..de7b6a5af9b 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/lift_shared_resource.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/lift_shared_resource.test.w_compile_tf-aws.md @@ -408,6 +408,7 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$stdlib.core.toLiftableModuleType(http.Util, "@winglang/sdk/http", "Util"), ["get"]], [api.url, []], ], "$inflight_init": [ diff --git a/tools/hangar/__snapshots__/test_corpus/valid/lift_with_phase_ind.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/lift_with_phase_ind.test.w_compile_tf-aws.md index e767640accf..c0f4327b112 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/lift_with_phase_ind.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/lift_with_phase_ind.test.w_compile_tf-aws.md @@ -87,6 +87,7 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$stdlib.core.toLiftableModuleType(math.Util, "@winglang/sdk/math", "Util"), ["floor", "random"]], [((arr, index) => { if (index < 0 || index >= arr.length) throw new Error("Index out of bounds"); return arr[index]; })(ar, 0), []], [ar, ["at"]], [ar.length, []], diff --git a/tools/hangar/__snapshots__/test_corpus/valid/mutation_after_class_init.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/mutation_after_class_init.test.w_compile_tf-aws.md index c22fee7746d..ab8cf0608a9 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/mutation_after_class_init.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/mutation_after_class_init.test.w_compile_tf-aws.md @@ -515,6 +515,7 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$stdlib.core.toLiftableModuleType(util.Util, "@winglang/sdk/util", "Util"), ["waitUntil"]], [c, ["peek"]], [q, ["push"]], ], diff --git a/tools/hangar/__snapshots__/test_corpus/valid/on_lift.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/on_lift.test.w_compile_tf-aws.md index 0ae4ec97b3e..ff3ea68e50d 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/on_lift.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/on_lift.test.w_compile_tf-aws.md @@ -110,6 +110,7 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "m1": [ + [$stdlib.core.toLiftableModuleType(util.Util, "@winglang/sdk/util", "Util"), ["env"]], ], "$inflight_init": [ ], @@ -118,6 +119,7 @@ class $Root extends $stdlib.std.Resource { static get _liftTypeMap() { return ({ "m2": [ + [$stdlib.core.toLiftableModuleType(util.Util, "@winglang/sdk/util", "Util"), ["env"]], ], }); } diff --git a/tools/hangar/__snapshots__/test_corpus/valid/redis.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/redis.test.w_compile_tf-aws.md index 061341bbe2e..adda2d24a45 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/redis.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/redis.test.w_compile_tf-aws.md @@ -609,6 +609,7 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$stdlib.core.toLiftableModuleType(util.Util, "@winglang/sdk/util", "Util"), ["waitUntil"]], [queue, ["push"]], [r, ["get"]], [r2, ["get", "set"]], diff --git a/tools/hangar/__snapshots__/test_corpus/valid/resource.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/resource.test.w_compile_tf-aws.md index 4790c095540..38a661d0417 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/resource.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/resource.test.w_compile_tf-aws.md @@ -798,6 +798,7 @@ class $Root extends $stdlib.std.Resource { "testTypeAccess": [ [Bar, ["barStatic"]], [Foo, ["fooStatic"]], + [MyEnum, ["B"]], [this.e, []], ], "$inflight_init": [ diff --git a/tools/hangar/__snapshots__/test_corpus/valid/struct_from_json.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/struct_from_json.test.w_compile_tf-aws.md index ad46ca50d46..27d2c6fd176 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/struct_from_json.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/struct_from_json.test.w_compile_tf-aws.md @@ -218,6 +218,7 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$stdlib.core.toLiftableModuleType(cloud_BucketProps, "@winglang/sdk/cloud", "BucketProps"), ["fromJson"]], [j, []], ], "$inflight_init": [ @@ -252,6 +253,7 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [Student, ["fromJson"]], ], "$inflight_init": [ ], @@ -286,6 +288,7 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [Student, ["fromJson"]], [jStudent1, []], ], "$inflight_init": [ @@ -324,7 +327,9 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$stdlib.core.toLiftableModuleType(std.Json, "@winglang/sdk/std", "Json"), ["stringify"]], [(schema.asStr()), []], + [MyStruct, ["schema"]], [expectedSchema, []], [jMyStruct, []], ], @@ -363,6 +368,10 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$stdlib.core.toLiftableModuleType(std.Boolean, "@winglang/sdk/std", "Boolean"), ["fromJson"]], + [$stdlib.core.toLiftableModuleType(std.Number, "@winglang/sdk/std", "Number"), ["fromJson"]], + [$stdlib.core.toLiftableModuleType(std.String, "@winglang/sdk/std", "String"), ["fromJson"]], + [Student, ["fromJson"]], ], "$inflight_init": [ ], From 118510e06c207d49d9261f155b59180c5ba44350 Mon Sep 17 00:00:00 2001 From: "monada-bot[bot]" Date: Sat, 17 Feb 2024 14:36:42 +0000 Subject: [PATCH 22/78] chore: self mutation (e2e-2of2.diff) Signed-off-by: monada-bot[bot] --- tools/hangar/__snapshots__/invalid.ts.snap | 14 -------------- .../valid/api.test.w_compile_tf-aws.md | 1 + .../api_cors_custom.test.w_compile_tf-aws.md | 8 ++++++++ .../api_cors_default.test.w_compile_tf-aws.md | 5 +++++ ...ssigable_class_field.test.w_compile_tf-aws.md | 1 + .../valid/class.test.w_compile_tf-aws.md | 14 +++++++++++--- .../valid/enums.test.w_compile_tf-aws.md | 1 + ...light_capture_static.test.w_compile_tf-aws.md | 13 +++++++------ ..._class_capture_const.test.w_compile_tf-aws.md | 7 ++++++- ...ht_class_definitions.test.w_compile_tf-aws.md | 14 ++++++++++++-- ...ight_class_modifiers.test.w_compile_tf-aws.md | 5 ++++- ...ide_inflight_closure.test.w_compile_tf-aws.md | 7 ++++++- ...ral_interace_handler.test.w_compile_tf-aws.md | 7 ++++++- ...t_class_without_init.test.w_compile_tf-aws.md | 6 +++++- ...ht_handler_singleton.test.w_compile_tf-aws.md | 1 + .../valid/json_static.test.w_compile_tf-aws.md | 2 ++ .../valid/lift_this.test.w_compile_tf-aws.md | 1 + .../valid/super_call.test.w_compile_tf-aws.md | 16 +++++++++++++--- .../website_with_api.test.w_compile_tf-aws.md | 8 ++++++++ 19 files changed, 98 insertions(+), 33 deletions(-) diff --git a/tools/hangar/__snapshots__/invalid.ts.snap b/tools/hangar/__snapshots__/invalid.ts.snap index b3f147dfdcf..27f0408fb33 100644 --- a/tools/hangar/__snapshots__/invalid.ts.snap +++ b/tools/hangar/__snapshots__/invalid.ts.snap @@ -2159,13 +2159,6 @@ error: Cannot create preflight class \\"PreflightClass\\" in inflight phase | ^^^^^^^^^^^^^^^^^^^^ Cannot create preflight class \\"PreflightClass\\" in inflight phase -error: Cannot qualify access to a lifted type \\"PreflightClass\\" (see https://github.com/winglang/wing/issues/76 for more details) - --> ../../../examples/tests/invalid/inflight_class_created_in_preflight.test.w:19:7 - | -19 | new PreflightClass(); - | ^^^^^^^^^^^^^^ Cannot qualify access to a lifted type \\"PreflightClass\\" (see https://github.com/winglang/wing/issues/76 for more details) - - Tests 1 failed (1) @@ -3365,13 +3358,6 @@ exports[`resource_inflight.test.w 1`] = ` | ^^^^^^^^^^^^^^^^^^ Cannot create preflight class \\"Bucket\\" in inflight phase -error: Cannot qualify access to a lifted type \\"Bucket\\" (see https://github.com/winglang/wing/issues/76 for more details) - --> ../../../examples/tests/invalid/resource_inflight.test.w:4:7 - | -4 | new cloud.Bucket(); // Should fail because we can't create resources inflight - | ^^^^^^^^^^^^ Cannot qualify access to a lifted type \\"Bucket\\" (see https://github.com/winglang/wing/issues/76 for more details) - - Tests 1 failed (1) diff --git a/tools/hangar/__snapshots__/test_corpus/valid/api.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/api.test.w_compile_tf-aws.md index 003feb13aaa..d88595a674a 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/api.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/api.test.w_compile_tf-aws.md @@ -508,6 +508,7 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$stdlib.core.toLiftableModuleType(std.Json, "@winglang/sdk/std", "Json"), ["stringify"]], [counter, ["inc"]], ], "$inflight_init": [ diff --git a/tools/hangar/__snapshots__/test_corpus/valid/api_cors_custom.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/api_cors_custom.test.w_compile_tf-aws.md index c6d1fdfbb3e..0b31d245d27 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/api_cors_custom.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/api_cors_custom.test.w_compile_tf-aws.md @@ -400,6 +400,8 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$stdlib.core.toLiftableModuleType(expect.Util, "@winglang/sdk/expect", "Util"), ["equal", "nil"]], + [$stdlib.core.toLiftableModuleType(http.Util, "@winglang/sdk/http", "Util"), ["get"]], [api.url, []], ], "$inflight_init": [ @@ -437,6 +439,9 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$stdlib.core.toLiftableModuleType(expect.Util, "@winglang/sdk/expect", "Util"), ["equal", "nil"]], + [$stdlib.core.toLiftableModuleType(http.HttpMethod, "@winglang/sdk/http", "HttpMethod"), ["OPTIONS"]], + [$stdlib.core.toLiftableModuleType(http.Util, "@winglang/sdk/http", "Util"), ["fetch"]], [api.url, []], ], "$inflight_init": [ @@ -474,6 +479,9 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$stdlib.core.toLiftableModuleType(expect.Util, "@winglang/sdk/expect", "Util"), ["equal"]], + [$stdlib.core.toLiftableModuleType(http.HttpMethod, "@winglang/sdk/http", "HttpMethod"), ["OPTIONS"]], + [$stdlib.core.toLiftableModuleType(http.Util, "@winglang/sdk/http", "Util"), ["fetch"]], [api.url, []], ], "$inflight_init": [ diff --git a/tools/hangar/__snapshots__/test_corpus/valid/api_cors_default.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/api_cors_default.test.w_compile_tf-aws.md index bd724ad586f..8d8115cd80a 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/api_cors_default.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/api_cors_default.test.w_compile_tf-aws.md @@ -375,6 +375,8 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$stdlib.core.toLiftableModuleType(expect.Util, "@winglang/sdk/expect", "Util"), ["equal", "nil"]], + [$stdlib.core.toLiftableModuleType(http.Util, "@winglang/sdk/http", "Util"), ["get"]], [apiDefaultCors.url, []], ], "$inflight_init": [ @@ -412,6 +414,9 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$stdlib.core.toLiftableModuleType(expect.Util, "@winglang/sdk/expect", "Util"), ["equal", "nil"]], + [$stdlib.core.toLiftableModuleType(http.HttpMethod, "@winglang/sdk/http", "HttpMethod"), ["OPTIONS"]], + [$stdlib.core.toLiftableModuleType(http.Util, "@winglang/sdk/http", "Util"), ["fetch"]], [apiDefaultCors.url, []], ], "$inflight_init": [ diff --git a/tools/hangar/__snapshots__/test_corpus/valid/capture_reassigable_class_field.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/capture_reassigable_class_field.test.w_compile_tf-aws.md index 87dc018afcf..cc8061f6bc6 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/capture_reassigable_class_field.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/capture_reassigable_class_field.test.w_compile_tf-aws.md @@ -298,6 +298,7 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$stdlib.core.toLiftableModuleType(util.Util, "@winglang/sdk/util", "Util"), ["waitUntil"]], [counter, ["peek"]], [kv, ["get", "set"]], ], diff --git a/tools/hangar/__snapshots__/test_corpus/valid/class.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/class.test.w_compile_tf-aws.md index 311ab057587..4410731f072 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/class.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/class.test.w_compile_tf-aws.md @@ -765,8 +765,10 @@ class $Root extends $stdlib.std.Resource { })()) `; } - get _liftMap() { + static get _liftTypeMap() { return ({ + "init": [ + ], "$inflight_init": [ [this, ["sound"]], ], @@ -775,6 +777,7 @@ class $Root extends $stdlib.std.Resource { }); } } + const $UniqueClassAlias12 = A; class B extends A { constructor($scope, $id, ) { super($scope, $id); @@ -797,13 +800,16 @@ class $Root extends $stdlib.std.Resource { })()) `; } - get _liftMap() { - return $stdlib.core.mergeLiftDeps(super._liftMap, { + static get _liftTypeMap() { + return $stdlib.core.mergeLiftDeps(super._liftTypeMap, { + "init": [ + ], "$inflight_init": [ ], }); } } + const $UniqueClassAlias13 = B; class $Closure4 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -831,6 +837,8 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$UniqueClassAlias13, ["sound"]], + [B, []], ], "$inflight_init": [ ], diff --git a/tools/hangar/__snapshots__/test_corpus/valid/enums.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/enums.test.w_compile_tf-aws.md index f52c6f0468b..bcd7e0ea92a 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/enums.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/enums.test.w_compile_tf-aws.md @@ -89,6 +89,7 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [SomeEnum, ["ONE", "TWO"]], [one, []], [two, []], ], diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight_capture_static.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight_capture_static.test.w_compile_tf-aws.md index 51608265c98..dd39e3cca8e 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight_capture_static.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight_capture_static.test.w_compile_tf-aws.md @@ -213,19 +213,18 @@ class $Root extends $stdlib.std.Resource { })()) `; } - get _liftMap() { - return ({ - "$inflight_init": [ - ], - }); - } static get _liftTypeMap() { return ({ "staticMethod": [ ], + "init": [ + ], + "$inflight_init": [ + ], }); } } + const $UniqueClassAlias1 = OuterInflight; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -287,6 +286,7 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [OuterInflight, ["staticMethod"]], ], "$inflight_init": [ ], @@ -352,6 +352,7 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$stdlib.core.toLiftableModuleType(util.Util, "@winglang/sdk/util", "Util"), ["tryEnv"]], ], "$inflight_init": [ ], diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_capture_const.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_capture_const.test.w_compile_tf-aws.md index b4f1e154ff9..98f784b32f6 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_capture_const.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_capture_const.test.w_compile_tf-aws.md @@ -90,16 +90,19 @@ class $Root extends $stdlib.std.Resource { })()) `; } - get _liftMap() { + static get _liftTypeMap() { return ({ "getValue": [ [myConst, []], ], + "init": [ + ], "$inflight_init": [ ], }); } } + const $UniqueClassAlias0 = Foo; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -128,6 +131,8 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$UniqueClassAlias0, ["getValue"]], + [Foo, []], [myConst, []], ], "$inflight_init": [ diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_definitions.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_definitions.test.w_compile_tf-aws.md index 78424142140..4f1a9f2fc79 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_definitions.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_definitions.test.w_compile_tf-aws.md @@ -235,15 +235,18 @@ class $Root extends $stdlib.std.Resource { })()) `; } - get _liftMap() { + static get _liftTypeMap() { return ({ "foo": [ ], + "init": [ + ], "$inflight_init": [ ], }); } } + const $UniqueClassAlias1 = B; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -333,15 +336,18 @@ class $Root extends $stdlib.std.Resource { })()) `; } - get _liftMap() { + static get _liftTypeMap() { return ({ "foo": [ ], + "init": [ + ], "$inflight_init": [ ], }); } } + const $UniqueClassAlias7 = F; const __parent_this_2 = this; class $Closure2 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); @@ -370,6 +376,8 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$UniqueClassAlias7, ["foo"]], + [F, ["foo"]], ], "$inflight_init": [ ], @@ -441,6 +449,8 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$UniqueClassAlias1, ["foo"]], + [B, []], [a, ["goo"]], [d, ["callInner"]], [fn, ["handle"]], diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_modifiers.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_modifiers.test.w_compile_tf-aws.md index dac4699fca0..b5cf8742f3e 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_modifiers.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_modifiers.test.w_compile_tf-aws.md @@ -71,10 +71,12 @@ class $Root extends $stdlib.std.Resource { })()) `; } - get _liftMap() { + static get _liftTypeMap() { return ({ "method": [ ], + "init": [ + ], "$inflight_init": [ [this, ["field"]], ], @@ -83,6 +85,7 @@ class $Root extends $stdlib.std.Resource { }); } } + const $UniqueClassAlias0 = C; } } const $PlatformManager = new $stdlib.platform.PlatformManager({platformPaths: $platforms}); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_outside_inflight_closure.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_outside_inflight_closure.test.w_compile_tf-aws.md index 87dc7f77b94..c551ba5f458 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_outside_inflight_closure.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_outside_inflight_closure.test.w_compile_tf-aws.md @@ -95,11 +95,13 @@ class $Root extends $stdlib.std.Resource { })()) `; } - get _liftMap() { + static get _liftTypeMap() { return ({ "add": [ [this, ["lhs", "rhs"]], ], + "init": [ + ], "$inflight_init": [ [this, ["lhs", "rhs"]], ], @@ -110,6 +112,7 @@ class $Root extends $stdlib.std.Resource { }); } } + const $UniqueClassAlias0 = BinaryOperation; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -137,6 +140,8 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$UniqueClassAlias0, ["add"]], + [BinaryOperation, []], ], "$inflight_init": [ ], diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_structural_interace_handler.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_structural_interace_handler.test.w_compile_tf-aws.md index a16515b231f..21655cfe03e 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_structural_interace_handler.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_structural_interace_handler.test.w_compile_tf-aws.md @@ -79,6 +79,7 @@ class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); class NotGoo extends $stdlib.std.Resource { + _id = $stdlib.core.closureId(); constructor($scope, $id, ) { super($scope, $id); } @@ -99,15 +100,18 @@ class $Root extends $stdlib.std.Resource { })()) `; } - get _liftMap() { + static get _liftTypeMap() { return ({ "handle": [ ], + "init": [ + ], "$inflight_init": [ ], }); } } + const $UniqueClassAlias0 = NotGoo; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -135,6 +139,7 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [NotGoo, []], ], "$inflight_init": [ ], diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_without_init.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_without_init.test.w_compile_tf-aws.md index 22d2abcc789..cb0f160f632 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_without_init.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_without_init.test.w_compile_tf-aws.md @@ -85,13 +85,16 @@ class $Root extends $stdlib.std.Resource { })()) `; } - get _liftMap() { + static get _liftTypeMap() { return ({ + "init": [ + ], "$inflight_init": [ ], }); } } + const $UniqueClassAlias0 = Foo; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -119,6 +122,7 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [Foo, []], ], "$inflight_init": [ ], diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight_handler_singleton.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight_handler_singleton.test.w_compile_tf-aws.md index 21c2aee535d..4fe04ef9ae7 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight_handler_singleton.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight_handler_singleton.test.w_compile_tf-aws.md @@ -443,6 +443,7 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$stdlib.core.toLiftableModuleType(expect.Util, "@winglang/sdk/expect", "Util"), ["equal"]], [fn, ["invoke"]], [fn2, ["invoke"]], [sim, []], diff --git a/tools/hangar/__snapshots__/test_corpus/valid/json_static.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/json_static.test.w_compile_tf-aws.md index c024c5d489e..b972ca912a6 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/json_static.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/json_static.test.w_compile_tf-aws.md @@ -103,6 +103,7 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$stdlib.core.toLiftableModuleType(std.Json, "@winglang/sdk/std", "Json"), ["stringify"]], [jj, []], ], "$inflight_init": [ @@ -137,6 +138,7 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$stdlib.core.toLiftableModuleType(std.Json, "@winglang/sdk/std", "Json"), ["has"]], ], "$inflight_init": [ ], diff --git a/tools/hangar/__snapshots__/test_corpus/valid/lift_this.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/lift_this.test.w_compile_tf-aws.md index 36212fa7b07..2e9d4a08d69 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/lift_this.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/lift_this.test.w_compile_tf-aws.md @@ -144,6 +144,7 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$stdlib.core.toLiftableModuleType(util.Util, "@winglang/sdk/util", "Util"), ["env"]], [f, ["foo"]], ], "$inflight_init": [ diff --git a/tools/hangar/__snapshots__/test_corpus/valid/super_call.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/super_call.test.w_compile_tf-aws.md index ede504a4990..fb892b0fe21 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/super_call.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/super_call.test.w_compile_tf-aws.md @@ -403,15 +403,18 @@ class $Root extends $stdlib.std.Resource { })()) `; } - get _liftMap() { + static get _liftTypeMap() { return ({ "description": [ ], + "init": [ + ], "$inflight_init": [ ], }); } } + const $UniqueClassAlias5 = InflightA; class InflightB extends InflightA { constructor($scope, $id, ) { super($scope, $id); @@ -434,15 +437,18 @@ class $Root extends $stdlib.std.Resource { })()) `; } - get _liftMap() { - return $stdlib.core.mergeLiftDeps(super._liftMap, { + static get _liftTypeMap() { + return $stdlib.core.mergeLiftDeps(super._liftTypeMap, { "description": [ ], + "init": [ + ], "$inflight_init": [ ], }); } } + const $UniqueClassAlias6 = InflightB; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -471,6 +477,9 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$UniqueClassAlias6, ["description"]], + [$stdlib.core.toLiftableModuleType(expect.Util, "@winglang/sdk/expect", "Util"), ["equal"]], + [InflightB, []], ], "$inflight_init": [ ], @@ -570,6 +579,7 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$stdlib.core.toLiftableModuleType(expect.Util, "@winglang/sdk/expect", "Util"), ["equal"]], [extended, ["do"]], ], "$inflight_init": [ diff --git a/tools/hangar/__snapshots__/test_corpus/valid/website_with_api.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/website_with_api.test.w_compile_tf-aws.md index 6bf7cc79f97..84ff3eca47c 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/website_with_api.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/website_with_api.test.w_compile_tf-aws.md @@ -660,6 +660,7 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$stdlib.core.toLiftableModuleType(std.Json, "@winglang/sdk/std", "Json"), ["stringify"]], [usersTable, ["list"]], ], "$inflight_init": [ @@ -695,6 +696,7 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$stdlib.core.toLiftableModuleType(std.Json, "@winglang/sdk/std", "Json"), ["parse", "stringify"]], [usersTable, ["insert"]], ], "$inflight_init": [ @@ -732,6 +734,9 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$stdlib.core.toLiftableModuleType(expect.Util, "@winglang/sdk/expect", "Util"), ["equal", "nil"]], + [$stdlib.core.toLiftableModuleType(http.HttpMethod, "@winglang/sdk/http", "HttpMethod"), ["GET"]], + [$stdlib.core.toLiftableModuleType(http.Util, "@winglang/sdk/http", "Util"), ["fetch"]], [api.url, []], ], "$inflight_init": [ @@ -769,6 +774,9 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$stdlib.core.toLiftableModuleType(expect.Util, "@winglang/sdk/expect", "Util"), ["equal"]], + [$stdlib.core.toLiftableModuleType(http.HttpMethod, "@winglang/sdk/http", "HttpMethod"), ["OPTIONS"]], + [$stdlib.core.toLiftableModuleType(http.Util, "@winglang/sdk/http", "Util"), ["fetch"]], [api.url, []], ], "$inflight_init": [ From 2d436f0eda52d7c2ef9671650a342e7c822dd090 Mon Sep 17 00:00:00 2001 From: Yoav Steinberg Date: Sat, 17 Feb 2024 16:37:18 +0200 Subject: [PATCH 23/78] lint --- libs/wingc/src/lifting.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/wingc/src/lifting.rs b/libs/wingc/src/lifting.rs index 8f3dd8744cf..43ef1d559d9 100644 --- a/libs/wingc/src/lifting.rs +++ b/libs/wingc/src/lifting.rs @@ -279,7 +279,7 @@ impl<'a> Visit<'a> for LiftVisitor<'a> { // } // } - + // Before we continue lets dive into this (non-preflight) expression to see if we need to lift any parts of it visit::visit_expr(v, node); From d6f024290d4366d0205d2e613f010932c3007e30 Mon Sep 17 00:00:00 2001 From: "monada-bot[bot]" Date: Sat, 17 Feb 2024 14:50:52 +0000 Subject: [PATCH 24/78] chore: self mutation (build.diff) Signed-off-by: monada-bot[bot] --- ..._static_inflight_from_static_inflight.snap | 11 +- .../snapshots/capture_in_keyword_args.snap | 1 + ...capture_type_new_inflight_class_outer.snap | 6 +- ...ure_type_static_method_inflight_class.snap | 12 +- ...ht_class_extends_outer_inflight_class.snap | 6 +- .../src/jsify/snapshots/closure_field.snap | 2 +- .../wingc/src/jsify/snapshots/enum_value.snap | 1 + ...inflight_class_extends_inflight_class.snap | 12 +- .../inflight_field_from_inflight_class.snap | 5 +- .../src/jsify/snapshots/json_object.snap | 1 + .../namespaced_static_from_inflight.snap | 1 + .../jsify/snapshots/new_inflight_object.snap | 6 +- ...ht_type_refrencing_preflight_instance.snap | 203 ++++++++++++++++++ .../snapshots/reference_inflight_class.snap | 12 +- .../reference_inflight_from_inflight.snap | 6 +- .../static_external_inflight_class.snap | 12 +- .../jsify/snapshots/static_on_std_type.snap | 2 + ...ansitive_reference_via_inflight_class.snap | 7 +- .../jsify/snapshots/use_util_functions.snap | 1 + libs/wingc/src/jsify/snapshots/wait_util.snap | 1 + libs/wingsdk/src/core/lifting.ts | 5 +- 21 files changed, 275 insertions(+), 38 deletions(-) create mode 100644 libs/wingc/src/jsify/snapshots/qualify_inflight_type_refrencing_preflight_instance.snap diff --git a/libs/wingc/src/jsify/snapshots/call_static_inflight_from_static_inflight.snap b/libs/wingc/src/jsify/snapshots/call_static_inflight_from_static_inflight.snap index 18deefa82a0..6d345a4548b 100644 --- a/libs/wingc/src/jsify/snapshots/call_static_inflight_from_static_inflight.snap +++ b/libs/wingc/src/jsify/snapshots/call_static_inflight_from_static_inflight.snap @@ -120,20 +120,19 @@ class $Root extends $stdlib.std.Resource { })()) `; } - get _liftMap() { - return ({ - "$inflight_init": [ - ], - }); - } static get _liftTypeMap() { return ({ "bar": [ [A, ["foo"]], ], + "init": [ + ], + "$inflight_init": [ + ], }); } } + const $UniqueClassAlias1 = B; } } const $PlatformManager = new $stdlib.platform.PlatformManager({platformPaths: $platforms}); diff --git a/libs/wingc/src/jsify/snapshots/capture_in_keyword_args.snap b/libs/wingc/src/jsify/snapshots/capture_in_keyword_args.snap index c32d86e3584..cb04460836c 100644 --- a/libs/wingc/src/jsify/snapshots/capture_in_keyword_args.snap +++ b/libs/wingc/src/jsify/snapshots/capture_in_keyword_args.snap @@ -80,6 +80,7 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$stdlib.core.toLiftableModuleType(util.Util, "@winglang/sdk/util", "Util"), ["waitUntil"]], [x, []], ], "$inflight_init": [ diff --git a/libs/wingc/src/jsify/snapshots/capture_type_new_inflight_class_outer.snap b/libs/wingc/src/jsify/snapshots/capture_type_new_inflight_class_outer.snap index c033562be92..50614c3674b 100644 --- a/libs/wingc/src/jsify/snapshots/capture_type_new_inflight_class_outer.snap +++ b/libs/wingc/src/jsify/snapshots/capture_type_new_inflight_class_outer.snap @@ -81,13 +81,16 @@ class $Root extends $stdlib.std.Resource { })()) `; } - get _liftMap() { + static get _liftTypeMap() { return ({ + "init": [ + ], "$inflight_init": [ ], }); } } + const $UniqueClassAlias0 = Foo; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -115,6 +118,7 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [Foo, []], ], "$inflight_init": [ ], diff --git a/libs/wingc/src/jsify/snapshots/capture_type_static_method_inflight_class.snap b/libs/wingc/src/jsify/snapshots/capture_type_static_method_inflight_class.snap index 37b020d05fb..6f834d42933 100644 --- a/libs/wingc/src/jsify/snapshots/capture_type_static_method_inflight_class.snap +++ b/libs/wingc/src/jsify/snapshots/capture_type_static_method_inflight_class.snap @@ -86,19 +86,18 @@ class $Root extends $stdlib.std.Resource { })()) `; } - get _liftMap() { - return ({ - "$inflight_init": [ - ], - }); - } static get _liftTypeMap() { return ({ "bar": [ ], + "init": [ + ], + "$inflight_init": [ + ], }); } } + const $UniqueClassAlias0 = Foo; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -126,6 +125,7 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [Foo, ["bar"]], ], "$inflight_init": [ ], diff --git a/libs/wingc/src/jsify/snapshots/closed_inflight_class_extends_outer_inflight_class.snap b/libs/wingc/src/jsify/snapshots/closed_inflight_class_extends_outer_inflight_class.snap index 044c9b3f4f4..94379cc395d 100644 --- a/libs/wingc/src/jsify/snapshots/closed_inflight_class_extends_outer_inflight_class.snap +++ b/libs/wingc/src/jsify/snapshots/closed_inflight_class_extends_outer_inflight_class.snap @@ -84,13 +84,16 @@ class $Root extends $stdlib.std.Resource { })()) `; } - get _liftMap() { + static get _liftTypeMap() { return ({ + "init": [ + ], "$inflight_init": [ ], }); } } + const $UniqueClassAlias0 = Base; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -118,6 +121,7 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [Base, []], ], "$inflight_init": [ ], diff --git a/libs/wingc/src/jsify/snapshots/closure_field.snap b/libs/wingc/src/jsify/snapshots/closure_field.snap index ea3b7d3413a..504fbe67c12 100644 --- a/libs/wingc/src/jsify/snapshots/closure_field.snap +++ b/libs/wingc/src/jsify/snapshots/closure_field.snap @@ -170,7 +170,7 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "foo": [ - [this.closure, []], + [this.closure, ["handle"]], ], "$inflight_init": [ [this.closure, []], diff --git a/libs/wingc/src/jsify/snapshots/enum_value.snap b/libs/wingc/src/jsify/snapshots/enum_value.snap index 192a093c0d4..2e569b2cc32 100644 --- a/libs/wingc/src/jsify/snapshots/enum_value.snap +++ b/libs/wingc/src/jsify/snapshots/enum_value.snap @@ -85,6 +85,7 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [MyEnum, ["B", "C"]], [x, []], ], "$inflight_init": [ diff --git a/libs/wingc/src/jsify/snapshots/inflight_class_extends_inflight_class.snap b/libs/wingc/src/jsify/snapshots/inflight_class_extends_inflight_class.snap index 2c232deff47..389949f667e 100644 --- a/libs/wingc/src/jsify/snapshots/inflight_class_extends_inflight_class.snap +++ b/libs/wingc/src/jsify/snapshots/inflight_class_extends_inflight_class.snap @@ -70,13 +70,16 @@ class $Root extends $stdlib.std.Resource { })()) `; } - get _liftMap() { + static get _liftTypeMap() { return ({ + "init": [ + ], "$inflight_init": [ ], }); } } + const $UniqueClassAlias0 = A; class B extends A { constructor($scope, $id, ) { super($scope, $id); @@ -99,13 +102,16 @@ class $Root extends $stdlib.std.Resource { })()) `; } - get _liftMap() { - return $stdlib.core.mergeLiftDeps(super._liftMap, { + static get _liftTypeMap() { + return $stdlib.core.mergeLiftDeps(super._liftTypeMap, { + "init": [ + ], "$inflight_init": [ ], }); } } + const $UniqueClassAlias1 = B; } } const $PlatformManager = new $stdlib.platform.PlatformManager({platformPaths: $platforms}); diff --git a/libs/wingc/src/jsify/snapshots/inflight_field_from_inflight_class.snap b/libs/wingc/src/jsify/snapshots/inflight_field_from_inflight_class.snap index 554f4fdb526..690a3d1f67d 100644 --- a/libs/wingc/src/jsify/snapshots/inflight_field_from_inflight_class.snap +++ b/libs/wingc/src/jsify/snapshots/inflight_field_from_inflight_class.snap @@ -71,11 +71,13 @@ class $Root extends $stdlib.std.Resource { })()) `; } - get _liftMap() { + static get _liftTypeMap() { return ({ "getField": [ [this, ["field"]], ], + "init": [ + ], "$inflight_init": [ [this, ["field"]], ], @@ -84,6 +86,7 @@ class $Root extends $stdlib.std.Resource { }); } } + const $UniqueClassAlias0 = MyType; } } const $PlatformManager = new $stdlib.platform.PlatformManager({platformPaths: $platforms}); diff --git a/libs/wingc/src/jsify/snapshots/json_object.snap b/libs/wingc/src/jsify/snapshots/json_object.snap index 4475c13be11..1b44543a72f 100644 --- a/libs/wingc/src/jsify/snapshots/json_object.snap +++ b/libs/wingc/src/jsify/snapshots/json_object.snap @@ -75,6 +75,7 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$stdlib.core.toLiftableModuleType(std.Json, "@winglang/sdk/std", "Json"), ["stringify"]], [jsonObj1, []], ], "$inflight_init": [ diff --git a/libs/wingc/src/jsify/snapshots/namespaced_static_from_inflight.snap b/libs/wingc/src/jsify/snapshots/namespaced_static_from_inflight.snap index 27bf7a8a335..172c5bd0f11 100644 --- a/libs/wingc/src/jsify/snapshots/namespaced_static_from_inflight.snap +++ b/libs/wingc/src/jsify/snapshots/namespaced_static_from_inflight.snap @@ -74,6 +74,7 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$stdlib.core.toLiftableModuleType(util.Util, "@winglang/sdk/util", "Util"), ["tryEnv"]], ], "$inflight_init": [ ], diff --git a/libs/wingc/src/jsify/snapshots/new_inflight_object.snap b/libs/wingc/src/jsify/snapshots/new_inflight_object.snap index 330edc5ce56..0de318f80bd 100644 --- a/libs/wingc/src/jsify/snapshots/new_inflight_object.snap +++ b/libs/wingc/src/jsify/snapshots/new_inflight_object.snap @@ -81,13 +81,16 @@ class $Root extends $stdlib.std.Resource { })()) `; } - get _liftMap() { + static get _liftTypeMap() { return ({ + "init": [ + ], "$inflight_init": [ ], }); } } + const $UniqueClassAlias0 = Foo; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -115,6 +118,7 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [Foo, []], ], "$inflight_init": [ ], diff --git a/libs/wingc/src/jsify/snapshots/qualify_inflight_type_refrencing_preflight_instance.snap b/libs/wingc/src/jsify/snapshots/qualify_inflight_type_refrencing_preflight_instance.snap new file mode 100644 index 00000000000..8dad2436359 --- /dev/null +++ b/libs/wingc/src/jsify/snapshots/qualify_inflight_type_refrencing_preflight_instance.snap @@ -0,0 +1,203 @@ +--- +source: libs/wingc/src/jsify/tests.rs +--- +## Code + +```w + + class PreflightC { + pub inflight bar() {} + } + let pc = new PreflightC(); + + inflight class InflightC { + pub foo() { + pc.bar(); + } + } + + test "test" { + let ic = new InflightC(); + ic.foo(); + } + +``` + +## inflight.$Closure1-1.js + +```js +"use strict"; +const $helpers = require("@winglang/sdk/lib/helpers"); +module.exports = function({ $InflightC }) { + class $Closure1 { + constructor({ }) { + const $obj = (...args) => this.handle(...args); + Object.setPrototypeOf($obj, this); + return $obj; + } + async handle() { + const ic = (await (async () => {const o = new $InflightC(); await o.$inflight_init?.(); return o; })()); + (await ic.foo()); + } + } + return $Closure1; +} +//# sourceMappingURL=inflight.$Closure1-1.js.map +``` + +## inflight.InflightC-1.js + +```js +"use strict"; +const $helpers = require("@winglang/sdk/lib/helpers"); +module.exports = function({ $pc }) { + class InflightC { + async foo() { + (await $pc.bar()); + } + } + return InflightC; +} +//# sourceMappingURL=inflight.InflightC-1.js.map +``` + +## inflight.PreflightC-1.js + +```js +"use strict"; +const $helpers = require("@winglang/sdk/lib/helpers"); +module.exports = function({ }) { + class PreflightC { + constructor({ }) { + } + async bar() { + } + } + return PreflightC; +} +//# sourceMappingURL=inflight.PreflightC-1.js.map +``` + +## preflight.js + +```js +"use strict"; +const $stdlib = require('@winglang/sdk'); +const $platforms = ((s) => !s ? [] : s.split(';'))(process.env.WING_PLATFORMS); +const $outdir = process.env.WING_SYNTH_DIR ?? "."; +const $wing_is_test = process.env.WING_IS_TEST === "true"; +const std = $stdlib.std; +const $helpers = $stdlib.helpers; +class $Root extends $stdlib.std.Resource { + constructor($scope, $id) { + super($scope, $id); + class PreflightC extends $stdlib.std.Resource { + constructor($scope, $id, ) { + super($scope, $id); + } + static _toInflightType() { + return ` + require("${$helpers.normalPath(__dirname)}/inflight.PreflightC-1.js")({ + }) + `; + } + _toInflight() { + return ` + (await (async () => { + const PreflightCClient = ${PreflightC._toInflightType()}; + const client = new PreflightCClient({ + }); + if (client.$inflight_init) { await client.$inflight_init(); } + return client; + })()) + `; + } + get _liftMap() { + return ({ + "bar": [ + ], + "$inflight_init": [ + ], + }); + } + } + class InflightC extends $stdlib.std.Resource { + constructor($scope, $id, ) { + super($scope, $id); + } + static _toInflightType() { + return ` + require("${$helpers.normalPath(__dirname)}/inflight.InflightC-1.js")({ + $pc: ${$stdlib.core.liftObject(pc)}, + }) + `; + } + _toInflight() { + return ` + (await (async () => { + const InflightCClient = ${InflightC._toInflightType()}; + const client = new InflightCClient({ + }); + if (client.$inflight_init) { await client.$inflight_init(); } + return client; + })()) + `; + } + static get _liftTypeMap() { + return ({ + "foo": [ + [pc, ["bar"]], + ], + "init": [ + ], + "$inflight_init": [ + ], + }); + } + } + const $UniqueClassAlias1 = InflightC; + class $Closure1 extends $stdlib.std.AutoIdResource { + _id = $stdlib.core.closureId(); + constructor($scope, $id, ) { + super($scope, $id); + $helpers.nodeof(this).hidden = true; + } + static _toInflightType() { + return ` + require("${$helpers.normalPath(__dirname)}/inflight.$Closure1-1.js")({ + $InflightC: ${$stdlib.core.liftObject(InflightC)}, + }) + `; + } + _toInflight() { + return ` + (await (async () => { + const $Closure1Client = ${$Closure1._toInflightType()}; + const client = new $Closure1Client({ + }); + if (client.$inflight_init) { await client.$inflight_init(); } + return client; + })()) + `; + } + get _liftMap() { + return ({ + "handle": [ + [$UniqueClassAlias1, ["foo"]], + [InflightC, []], + ], + "$inflight_init": [ + ], + }); + } + } + const pc = new PreflightC(this, "PreflightC"); + this.node.root.new("@winglang/sdk.std.Test", std.Test, this, "test:test", new $Closure1(this, "$Closure1")); + } +} +const $PlatformManager = new $stdlib.platform.PlatformManager({platformPaths: $platforms}); +const $APP = $PlatformManager.createApp({ outdir: $outdir, name: "main", rootConstruct: $Root, isTestEnvironment: $wing_is_test, entrypointDir: process.env['WING_SOURCE_DIR'], rootId: process.env['WING_ROOT_ID'] }); +$APP.synth(); +//# sourceMappingURL=preflight.js.map +``` + diff --git a/libs/wingc/src/jsify/snapshots/reference_inflight_class.snap b/libs/wingc/src/jsify/snapshots/reference_inflight_class.snap index be270c0c949..091360d9f95 100644 --- a/libs/wingc/src/jsify/snapshots/reference_inflight_class.snap +++ b/libs/wingc/src/jsify/snapshots/reference_inflight_class.snap @@ -86,19 +86,18 @@ class $Root extends $stdlib.std.Resource { })()) `; } - get _liftMap() { - return ({ - "$inflight_init": [ - ], - }); - } static get _liftTypeMap() { return ({ "a": [ ], + "init": [ + ], + "$inflight_init": [ + ], }); } } + const $UniqueClassAlias0 = Foo; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -126,6 +125,7 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [Foo, ["a"]], ], "$inflight_init": [ ], diff --git a/libs/wingc/src/jsify/snapshots/reference_inflight_from_inflight.snap b/libs/wingc/src/jsify/snapshots/reference_inflight_from_inflight.snap index 9bf288297f9..92a074b1e50 100644 --- a/libs/wingc/src/jsify/snapshots/reference_inflight_from_inflight.snap +++ b/libs/wingc/src/jsify/snapshots/reference_inflight_from_inflight.snap @@ -99,16 +99,19 @@ class $Root extends $stdlib.std.Resource { })()) `; } - get _liftMap() { + static get _liftTypeMap() { return ({ "foofoo1": [ [s, []], ], + "init": [ + ], "$inflight_init": [ ], }); } } + const $UniqueClassAlias0 = Foo; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -136,6 +139,7 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [Foo, []], ], "$inflight_init": [ ], diff --git a/libs/wingc/src/jsify/snapshots/static_external_inflight_class.snap b/libs/wingc/src/jsify/snapshots/static_external_inflight_class.snap index 24d7763fb3a..6af66caeb09 100644 --- a/libs/wingc/src/jsify/snapshots/static_external_inflight_class.snap +++ b/libs/wingc/src/jsify/snapshots/static_external_inflight_class.snap @@ -97,19 +97,18 @@ class $Root extends $stdlib.std.Resource { })()) `; } - get _liftMap() { - return ({ - "$inflight_init": [ - ], - }); - } static get _liftTypeMap() { return ({ "foo": [ ], + "init": [ + ], + "$inflight_init": [ + ], }); } } + const $UniqueClassAlias0 = A; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -137,6 +136,7 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [A, ["foo"]], ], "$inflight_init": [ ], diff --git a/libs/wingc/src/jsify/snapshots/static_on_std_type.snap b/libs/wingc/src/jsify/snapshots/static_on_std_type.snap index 73f7620608e..5a32478cdfc 100644 --- a/libs/wingc/src/jsify/snapshots/static_on_std_type.snap +++ b/libs/wingc/src/jsify/snapshots/static_on_std_type.snap @@ -75,6 +75,8 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$stdlib.core.toLiftableModuleType(std.Json, "@winglang/sdk/std", "Json"), ["values"]], + [$stdlib.core.toLiftableModuleType(std.String, "@winglang/sdk/std", "String"), ["fromJson"]], ], "$inflight_init": [ ], diff --git a/libs/wingc/src/jsify/snapshots/transitive_reference_via_inflight_class.snap b/libs/wingc/src/jsify/snapshots/transitive_reference_via_inflight_class.snap index 20d6d5cba8c..79941e16227 100644 --- a/libs/wingc/src/jsify/snapshots/transitive_reference_via_inflight_class.snap +++ b/libs/wingc/src/jsify/snapshots/transitive_reference_via_inflight_class.snap @@ -96,16 +96,19 @@ class $Root extends $stdlib.std.Resource { })()) `; } - get _liftMap() { + static get _liftTypeMap() { return ({ "putInBucket": [ [b, ["put"]], ], + "init": [ + ], "$inflight_init": [ ], }); } } + const $UniqueClassAlias0 = MyInflightClass; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -133,6 +136,8 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$UniqueClassAlias0, ["putInBucket"]], + [MyInflightClass, []], ], "$inflight_init": [ ], diff --git a/libs/wingc/src/jsify/snapshots/use_util_functions.snap b/libs/wingc/src/jsify/snapshots/use_util_functions.snap index 39f0bb5d65b..77d8599b09a 100644 --- a/libs/wingc/src/jsify/snapshots/use_util_functions.snap +++ b/libs/wingc/src/jsify/snapshots/use_util_functions.snap @@ -73,6 +73,7 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$stdlib.core.toLiftableModuleType(util.Util, "@winglang/sdk/util", "Util"), ["env"]], ], "$inflight_init": [ ], diff --git a/libs/wingc/src/jsify/snapshots/wait_util.snap b/libs/wingc/src/jsify/snapshots/wait_util.snap index dec99744c6f..116e5ce1e72 100644 --- a/libs/wingc/src/jsify/snapshots/wait_util.snap +++ b/libs/wingc/src/jsify/snapshots/wait_util.snap @@ -80,6 +80,7 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$stdlib.core.toLiftableModuleType(util.Util, "@winglang/sdk/util", "Util"), ["waitUntil"]], ], "$inflight_init": [ ], diff --git a/libs/wingsdk/src/core/lifting.ts b/libs/wingsdk/src/core/lifting.ts index 998f4545dc0..0d5a73657bb 100644 --- a/libs/wingsdk/src/core/lifting.ts +++ b/libs/wingsdk/src/core/lifting.ts @@ -263,10 +263,7 @@ export function collectLifts( matrix[op] = new Map(); } matrixCache.set(obj, matrix); - } else if ( - typeof obj === "function" && - obj._liftTypeMap !== undefined - ) { + } else if (typeof obj === "function" && obj._liftTypeMap !== undefined) { matrix = parseMatrix(obj._liftTypeMap ?? {}); matrixCache.set(obj, matrix); } else { From eb9205b6f5723ad06ffdfc981bfe9c78209d7988 Mon Sep 17 00:00:00 2001 From: Yoav Steinberg Date: Sun, 18 Feb 2024 11:27:30 +0200 Subject: [PATCH 25/78] No need to store TypeRef in lift qualifications (we use unique type names) --- libs/wingc/src/lifting.rs | 5 ++- libs/wingc/src/type_check/lifts.rs | 54 ++++-------------------------- 2 files changed, 8 insertions(+), 51 deletions(-) diff --git a/libs/wingc/src/lifting.rs b/libs/wingc/src/lifting.rs index 43ef1d559d9..286e77c4a12 100644 --- a/libs/wingc/src/lifting.rs +++ b/libs/wingc/src/lifting.rs @@ -258,7 +258,7 @@ impl<'a> Visit<'a> for LiftVisitor<'a> { let mut lifts = v.lifts_stack.pop().unwrap(); let is_field = code.contains("this."); // TODO: starts_with? - lifts.lift(v.ctx.current_method().map(|(m,_)|m).expect("a method"), property, &code, is_field, None); + lifts.lift(v.ctx.current_method().map(|(m,_)|m).expect("a method"), property, &code, is_field); lifts.capture(&Liftable::Expr(node.id), &code, is_field); v.lifts_stack.push(lifts); return; @@ -293,7 +293,7 @@ impl<'a> Visit<'a> for LiftVisitor<'a> { // Get preflight code that references the type of the class so we can qualify the lift, note we use a unique // type alias here since we might not have the actual type name available in scope here. let code = &v.jsify.unique_class_alias(expr_type); - lifts.lift(m, Some(property), code, false, Some(expr_type)); + lifts.lift(m, Some(property), code, false); v.lifts_stack.push(lifts); return; } @@ -355,7 +355,6 @@ impl<'a> Visit<'a> for LiftVisitor<'a> { property, &code, false, - Some(udt_type), ); self.lifts_stack.push(lifts); } diff --git a/libs/wingc/src/type_check/lifts.rs b/libs/wingc/src/type_check/lifts.rs index c3c7dd8b533..03e7423b39c 100644 --- a/libs/wingc/src/type_check/lifts.rs +++ b/libs/wingc/src/type_check/lifts.rs @@ -2,7 +2,7 @@ use std::collections::{BTreeMap, BTreeSet, HashMap}; use crate::ast::{Symbol, UserDefinedType}; -use super::{ExprId, Subtype, TypeRef, CLASS_INFLIGHT_INIT_NAME}; +use super::{ExprId, CLASS_INFLIGHT_INIT_NAME}; /// A repository of lifts and captures at the class level. #[derive(Debug)] @@ -31,8 +31,6 @@ pub enum Liftable { pub struct LiftQualification { /// The operations that qualify the lift (the property names) pub ops: BTreeSet, - /// For type (not object) lifts, the type these qualify - pub type_: Option, } /// A record that describes a lift from a class. @@ -59,62 +57,22 @@ impl Lifts { } /// Adds a lift for an expression. - pub fn lift(&mut self, method: Symbol, property: Option, code: &str, is_field: bool, type_: Option) { - self.add_lift( - method.name.clone(), - code, - property.as_ref().map(|s| s.name.clone()), - type_, - ); + pub fn lift(&mut self, method: Symbol, property: Option, code: &str, is_field: bool) { + self.add_lift(method.name.clone(), code, property.as_ref().map(|s| s.name.clone())); // add a lift to the inflight initializer or capture it if its not a field if is_field { - self.add_lift(CLASS_INFLIGHT_INIT_NAME.to_string(), code, None, type_); + self.add_lift(CLASS_INFLIGHT_INIT_NAME.to_string(), code, None); } } - pub fn qualify_lifted_type(&mut self, method: Symbol, property: Symbol, type_: TypeRef) { - let Some(method_lifts) = self.lifts_qualifications.get_mut(&method.name) else { - panic!("Can't qualify unlifted type \"{type_}\" with \"{property}\": method \"{method}\" has no lifts."); - }; - - // Make sure this type actually exists in the lifts - // TODO: change this to a lookup instead of a linear search over `code` - let lift_qualification = method_lifts - .values_mut() - .find(|lift| lift.type_.is_some() && lift.type_.unwrap().is_same_type_as(&type_)) - .unwrap_or_else(|| panic!("Can't qualify unlifted type \"{type_}\" with \"{property}\"")); - - // Add the property to the lift qualification - lift_qualification.ops.insert(property.name.clone()); - } - - fn add_lift(&mut self, method: String, code: &str, property: Option, type_: Option) { + fn add_lift(&mut self, method: String, code: &str, property: Option) { let lift = self .lifts_qualifications .entry(method) .or_default() .entry(code.to_string()) - .or_insert(LiftQualification { - ops: BTreeSet::new(), - type_, - }); - - // Make sure the type for the given lift is consistent - match (&lift.type_, &type_) { - (Some(t1), Some(t2)) => { - assert!( - t1.is_same_type_as(t2), - "Lift type mismatch for code \"{code}\": type \"{t1}\" != \"{t2}\"" - ); - } - (Some(t), None) | (None, Some(t)) => { - panic!("Lift type mismatch for code \"{code}\": type \"{t}\" != None"); - } - _ => { - // do nothing - } - } + .or_insert(LiftQualification { ops: BTreeSet::new() }); if let Some(op) = &property { lift.ops.insert(op.clone()); From 4e865a640b9db9603c22e505e1e8818f26f5c726 Mon Sep 17 00:00:00 2001 From: Yoav Steinberg Date: Tue, 20 Feb 2024 14:45:04 +0200 Subject: [PATCH 26/78] use dummy object lift map for inflight class isntead of type lift map this should resolve issue with lifting the type base class of inflight classes. --- libs/wingc/src/jsify.rs | 38 ++++++++++++-------------------------- 1 file changed, 12 insertions(+), 26 deletions(-) diff --git a/libs/wingc/src/jsify.rs b/libs/wingc/src/jsify.rs index f47a61e3348..7e97483c5a8 100644 --- a/libs/wingc/src/jsify.rs +++ b/libs/wingc/src/jsify.rs @@ -1521,10 +1521,10 @@ impl<'a> JSifier<'a> { // at the scope when they are qualified (it might even be shadowed by another type name). Here we generate a unique // type name to be used in such cases. if class.phase == Phase::Inflight { + let inflight_class_unique_instance = self.unique_class_alias(class_type); code.line(format!( - "const {} = {};", - self.unique_class_alias(class_type), - class.name + "const {inflight_class_unique_instance} = new {}(this, \"{inflight_class_unique_instance}\");", + class.name, )); } code @@ -1532,7 +1532,8 @@ impl<'a> JSifier<'a> { } pub fn unique_class_alias(&self, type_: TypeRef) -> String { - format!("$UniqueClassAlias{}", type_.as_class().unwrap().uid) + let c = type_.as_class().unwrap(); + format!("${}_{}", c.name, c.uid) } fn jsify_preflight_constructor(&self, class: &AstClass, ctx: &mut JSifyContext) -> CodeMaker { @@ -1821,18 +1822,9 @@ impl<'a> JSifier<'a> { let is_static = m.is_static; let is_inflight = var_info.phase == Phase::Inflight; - let filter = if class.phase == Phase::Inflight { - // TODO: the following hints that instead of `onLiftType` and `onLift` we need to mark each lift as a - // field lift or a type lift. Then for each instance lifts we need to make sure to call their typeLift too. - - // All lifts in inflight classes are "type" lifts since `this` has no preflight fields which need to be - // lifted based on the object's instance - bind_method_kind == BindMethod::Type - } else { - match bind_method_kind { - BindMethod::Instance => is_inflight && !is_static, - BindMethod::Type => is_inflight && is_static && name.name != CLASS_INFLIGHT_INIT_NAME, - } + let filter = match bind_method_kind { + BindMethod::Instance => is_inflight && !is_static, + BindMethod::Type => is_inflight && (is_static || name.name == CLASS_INFLIGHT_INIT_NAME), }; if filter { if let Some(quals) = lifts.lifts_qualifications.get(&name.name) { @@ -1846,15 +1838,9 @@ impl<'a> JSifier<'a> { for f in class.inflight_fields() { let name = &f.name; let is_static = f.is_static; - let filter = if class.phase == Phase::Inflight { - // All lifts in inflight classes are "type" lifts since `this` has no preflight fields which need to be - // lifted based on the object's instance - bind_method_kind == BindMethod::Type - } else { - match bind_method_kind { - BindMethod::Instance => !is_static, - BindMethod::Type => is_static, - } + let filter = match bind_method_kind { + BindMethod::Instance => !is_static, + BindMethod::Type => is_static, }; if filter { if let Some(quals) = lifts.lifts_qualifications.get(&name.name) { @@ -1873,7 +1859,7 @@ impl<'a> JSifier<'a> { bind_method.open(format!("{modifier}get {bind_method_name}() {{")); if !lift_qualifications.is_empty() { - if class.parent.is_some() { + if bind_method_kind == BindMethod::Instance && class.parent.is_some() { // mergeLiftDeps is a helper method that combines the lift deps of the parent class with the // lift deps of this class bind_method.open(format!( From 7a45ea887c74aedac5bbef1f9d4c439dc1bf6f41 Mon Sep 17 00:00:00 2001 From: Yoav Steinberg Date: Tue, 20 Feb 2024 15:09:07 +0200 Subject: [PATCH 27/78] fix after merge --- libs/wingc/src/lifting.rs | 2 +- libs/wingc/src/type_check/lifts.rs | 4 +--- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/libs/wingc/src/lifting.rs b/libs/wingc/src/lifting.rs index 1a1fc078211..6145f2828b7 100644 --- a/libs/wingc/src/lifting.rs +++ b/libs/wingc/src/lifting.rs @@ -293,7 +293,7 @@ impl<'a> Visit<'a> for LiftVisitor<'a> { // Get preflight code that references the type of the class so we can qualify the lift, note we use a unique // type alias here since we might not have the actual type name available in scope here. let code = &v.jsify.unique_class_alias(expr_type); - lifts.lift(m, Some(property), code, false); + lifts.lift(m, Some(property), code); v.lifts_stack.push(lifts); return; } diff --git a/libs/wingc/src/type_check/lifts.rs b/libs/wingc/src/type_check/lifts.rs index d85ccfa1aba..5744a1f4cd5 100644 --- a/libs/wingc/src/type_check/lifts.rs +++ b/libs/wingc/src/type_check/lifts.rs @@ -57,11 +57,9 @@ impl Lifts { } /// Adds a lift for an expression. - pub fn lift(&mut self, method: Symbol, property: Option, code: &str, is_field: bool) { + pub fn lift(&mut self, method: Symbol, property: Option, code: &str) { self.add_lift(method.name.clone(), code, property.as_ref().map(|s| s.name.clone())); - self.add_lift(method, code, property.as_ref().map(|s| s.name.clone())); - // Add a lift to the inflight initializer to signify this class requires access to that preflight object. // "this" is a special case since it's already in scope and doesn't need to be lifted. if code != "this" { From 0f0b8cd63531c4d000ff65f7c0d6b397bb30881b Mon Sep 17 00:00:00 2001 From: Yoav Steinberg Date: Tue, 20 Feb 2024 15:28:10 +0200 Subject: [PATCH 28/78] remove leftover of experiment generating inflight_init lifitng map for types lifts --- libs/wingc/src/jsify.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/wingc/src/jsify.rs b/libs/wingc/src/jsify.rs index 7e97483c5a8..0f00bd7c0a0 100644 --- a/libs/wingc/src/jsify.rs +++ b/libs/wingc/src/jsify.rs @@ -1824,7 +1824,7 @@ impl<'a> JSifier<'a> { let is_inflight = var_info.phase == Phase::Inflight; let filter = match bind_method_kind { BindMethod::Instance => is_inflight && !is_static, - BindMethod::Type => is_inflight && (is_static || name.name == CLASS_INFLIGHT_INIT_NAME), + BindMethod::Type => is_inflight && is_static && name.name != CLASS_INFLIGHT_INIT_NAME, }; if filter { if let Some(quals) = lifts.lifts_qualifications.get(&name.name) { From 2dbf12a295d7ae7a8a89122e1ab6e289fdf44d6d Mon Sep 17 00:00:00 2001 From: "monada-bot[bot]" Date: Tue, 20 Feb 2024 14:06:01 +0000 Subject: [PATCH 29/78] chore: self mutation (build.diff) Signed-off-by: monada-bot[bot] --- .../call_static_inflight_from_static_inflight.snap | 1 + .../jsify/snapshots/capture_in_keyword_args.snap | 1 + .../capture_type_new_inflight_class_outer.snap | 7 +++---- .../capture_type_static_method_inflight_class.snap | 13 ++++++++----- ...nflight_class_extends_outer_inflight_class.snap | 7 +++---- libs/wingc/src/jsify/snapshots/enum_value.snap | 1 + .../inflight_class_extends_inflight_class.snap | 14 +++++--------- .../inflight_field_from_inflight_class.snap | 6 ++---- libs/wingc/src/jsify/snapshots/json_object.snap | 1 + .../snapshots/namespaced_static_from_inflight.snap | 1 + .../src/jsify/snapshots/new_inflight_object.snap | 7 +++---- ...nflight_type_refrencing_preflight_instance.snap | 11 ++++++----- .../jsify/snapshots/reference_inflight_class.snap | 13 ++++++++----- .../reference_inflight_from_inflight.snap | 7 +++---- .../snapshots/static_external_inflight_class.snap | 13 ++++++++----- .../src/jsify/snapshots/static_on_std_type.snap | 2 ++ .../transitive_reference_via_inflight_class.snap | 10 +++++----- .../src/jsify/snapshots/use_util_functions.snap | 1 + libs/wingc/src/jsify/snapshots/wait_util.snap | 1 + 19 files changed, 63 insertions(+), 54 deletions(-) diff --git a/libs/wingc/src/jsify/snapshots/call_static_inflight_from_static_inflight.snap b/libs/wingc/src/jsify/snapshots/call_static_inflight_from_static_inflight.snap index 5389d06a896..b6257ad1120 100644 --- a/libs/wingc/src/jsify/snapshots/call_static_inflight_from_static_inflight.snap +++ b/libs/wingc/src/jsify/snapshots/call_static_inflight_from_static_inflight.snap @@ -135,6 +135,7 @@ class $Root extends $stdlib.std.Resource { }); } } + const $B_1 = new B(this, "$B_1"); } } const $PlatformManager = new $stdlib.platform.PlatformManager({platformPaths: $platforms}); diff --git a/libs/wingc/src/jsify/snapshots/capture_in_keyword_args.snap b/libs/wingc/src/jsify/snapshots/capture_in_keyword_args.snap index 10c8b28a723..4a9e9d0bd91 100644 --- a/libs/wingc/src/jsify/snapshots/capture_in_keyword_args.snap +++ b/libs/wingc/src/jsify/snapshots/capture_in_keyword_args.snap @@ -84,6 +84,7 @@ class $Root extends $stdlib.std.Resource { [x, []], ], "$inflight_init": [ + [$stdlib.core.toLiftableModuleType(util.Util, "@winglang/sdk/util", "Util"), []], [x, []], ], }); diff --git a/libs/wingc/src/jsify/snapshots/capture_type_new_inflight_class_outer.snap b/libs/wingc/src/jsify/snapshots/capture_type_new_inflight_class_outer.snap index 50614c3674b..e3014bb3e48 100644 --- a/libs/wingc/src/jsify/snapshots/capture_type_new_inflight_class_outer.snap +++ b/libs/wingc/src/jsify/snapshots/capture_type_new_inflight_class_outer.snap @@ -81,16 +81,14 @@ class $Root extends $stdlib.std.Resource { })()) `; } - static get _liftTypeMap() { + get _liftMap() { return ({ - "init": [ - ], "$inflight_init": [ ], }); } } - const $UniqueClassAlias0 = Foo; + const $Foo_0 = new Foo(this, "$Foo_0"); class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -121,6 +119,7 @@ class $Root extends $stdlib.std.Resource { [Foo, []], ], "$inflight_init": [ + [Foo, []], ], }); } diff --git a/libs/wingc/src/jsify/snapshots/capture_type_static_method_inflight_class.snap b/libs/wingc/src/jsify/snapshots/capture_type_static_method_inflight_class.snap index 6f834d42933..48609d69d26 100644 --- a/libs/wingc/src/jsify/snapshots/capture_type_static_method_inflight_class.snap +++ b/libs/wingc/src/jsify/snapshots/capture_type_static_method_inflight_class.snap @@ -86,18 +86,20 @@ class $Root extends $stdlib.std.Resource { })()) `; } + get _liftMap() { + return ({ + "$inflight_init": [ + ], + }); + } static get _liftTypeMap() { return ({ "bar": [ ], - "init": [ - ], - "$inflight_init": [ - ], }); } } - const $UniqueClassAlias0 = Foo; + const $Foo_0 = new Foo(this, "$Foo_0"); class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -128,6 +130,7 @@ class $Root extends $stdlib.std.Resource { [Foo, ["bar"]], ], "$inflight_init": [ + [Foo, []], ], }); } diff --git a/libs/wingc/src/jsify/snapshots/closed_inflight_class_extends_outer_inflight_class.snap b/libs/wingc/src/jsify/snapshots/closed_inflight_class_extends_outer_inflight_class.snap index 94379cc395d..e66e2643fc4 100644 --- a/libs/wingc/src/jsify/snapshots/closed_inflight_class_extends_outer_inflight_class.snap +++ b/libs/wingc/src/jsify/snapshots/closed_inflight_class_extends_outer_inflight_class.snap @@ -84,16 +84,14 @@ class $Root extends $stdlib.std.Resource { })()) `; } - static get _liftTypeMap() { + get _liftMap() { return ({ - "init": [ - ], "$inflight_init": [ ], }); } } - const $UniqueClassAlias0 = Base; + const $Base_0 = new Base(this, "$Base_0"); class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -124,6 +122,7 @@ class $Root extends $stdlib.std.Resource { [Base, []], ], "$inflight_init": [ + [Base, []], ], }); } diff --git a/libs/wingc/src/jsify/snapshots/enum_value.snap b/libs/wingc/src/jsify/snapshots/enum_value.snap index de7b33625e5..cb0470a0723 100644 --- a/libs/wingc/src/jsify/snapshots/enum_value.snap +++ b/libs/wingc/src/jsify/snapshots/enum_value.snap @@ -89,6 +89,7 @@ class $Root extends $stdlib.std.Resource { [x, []], ], "$inflight_init": [ + [MyEnum, []], [x, []], ], }); diff --git a/libs/wingc/src/jsify/snapshots/inflight_class_extends_inflight_class.snap b/libs/wingc/src/jsify/snapshots/inflight_class_extends_inflight_class.snap index 389949f667e..e1b1b85a86f 100644 --- a/libs/wingc/src/jsify/snapshots/inflight_class_extends_inflight_class.snap +++ b/libs/wingc/src/jsify/snapshots/inflight_class_extends_inflight_class.snap @@ -70,16 +70,14 @@ class $Root extends $stdlib.std.Resource { })()) `; } - static get _liftTypeMap() { + get _liftMap() { return ({ - "init": [ - ], "$inflight_init": [ ], }); } } - const $UniqueClassAlias0 = A; + const $A_0 = new A(this, "$A_0"); class B extends A { constructor($scope, $id, ) { super($scope, $id); @@ -102,16 +100,14 @@ class $Root extends $stdlib.std.Resource { })()) `; } - static get _liftTypeMap() { - return $stdlib.core.mergeLiftDeps(super._liftTypeMap, { - "init": [ - ], + get _liftMap() { + return $stdlib.core.mergeLiftDeps(super._liftMap, { "$inflight_init": [ ], }); } } - const $UniqueClassAlias1 = B; + const $B_1 = new B(this, "$B_1"); } } const $PlatformManager = new $stdlib.platform.PlatformManager({platformPaths: $platforms}); diff --git a/libs/wingc/src/jsify/snapshots/inflight_field_from_inflight_class.snap b/libs/wingc/src/jsify/snapshots/inflight_field_from_inflight_class.snap index 690a3d1f67d..c6e6e1adb1a 100644 --- a/libs/wingc/src/jsify/snapshots/inflight_field_from_inflight_class.snap +++ b/libs/wingc/src/jsify/snapshots/inflight_field_from_inflight_class.snap @@ -71,13 +71,11 @@ class $Root extends $stdlib.std.Resource { })()) `; } - static get _liftTypeMap() { + get _liftMap() { return ({ "getField": [ [this, ["field"]], ], - "init": [ - ], "$inflight_init": [ [this, ["field"]], ], @@ -86,7 +84,7 @@ class $Root extends $stdlib.std.Resource { }); } } - const $UniqueClassAlias0 = MyType; + const $MyType_0 = new MyType(this, "$MyType_0"); } } const $PlatformManager = new $stdlib.platform.PlatformManager({platformPaths: $platforms}); diff --git a/libs/wingc/src/jsify/snapshots/json_object.snap b/libs/wingc/src/jsify/snapshots/json_object.snap index cf037b5152d..43641b37216 100644 --- a/libs/wingc/src/jsify/snapshots/json_object.snap +++ b/libs/wingc/src/jsify/snapshots/json_object.snap @@ -79,6 +79,7 @@ class $Root extends $stdlib.std.Resource { [jsonObj1, []], ], "$inflight_init": [ + [$stdlib.core.toLiftableModuleType(std.Json, "@winglang/sdk/std", "Json"), []], [jsonObj1, []], ], }); diff --git a/libs/wingc/src/jsify/snapshots/namespaced_static_from_inflight.snap b/libs/wingc/src/jsify/snapshots/namespaced_static_from_inflight.snap index 172c5bd0f11..03555897fba 100644 --- a/libs/wingc/src/jsify/snapshots/namespaced_static_from_inflight.snap +++ b/libs/wingc/src/jsify/snapshots/namespaced_static_from_inflight.snap @@ -77,6 +77,7 @@ class $Root extends $stdlib.std.Resource { [$stdlib.core.toLiftableModuleType(util.Util, "@winglang/sdk/util", "Util"), ["tryEnv"]], ], "$inflight_init": [ + [$stdlib.core.toLiftableModuleType(util.Util, "@winglang/sdk/util", "Util"), []], ], }); } diff --git a/libs/wingc/src/jsify/snapshots/new_inflight_object.snap b/libs/wingc/src/jsify/snapshots/new_inflight_object.snap index 0de318f80bd..1ec87a74133 100644 --- a/libs/wingc/src/jsify/snapshots/new_inflight_object.snap +++ b/libs/wingc/src/jsify/snapshots/new_inflight_object.snap @@ -81,16 +81,14 @@ class $Root extends $stdlib.std.Resource { })()) `; } - static get _liftTypeMap() { + get _liftMap() { return ({ - "init": [ - ], "$inflight_init": [ ], }); } } - const $UniqueClassAlias0 = Foo; + const $Foo_0 = new Foo(this, "$Foo_0"); class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -121,6 +119,7 @@ class $Root extends $stdlib.std.Resource { [Foo, []], ], "$inflight_init": [ + [Foo, []], ], }); } diff --git a/libs/wingc/src/jsify/snapshots/qualify_inflight_type_refrencing_preflight_instance.snap b/libs/wingc/src/jsify/snapshots/qualify_inflight_type_refrencing_preflight_instance.snap index 8dad2436359..39252dbd0ff 100644 --- a/libs/wingc/src/jsify/snapshots/qualify_inflight_type_refrencing_preflight_instance.snap +++ b/libs/wingc/src/jsify/snapshots/qualify_inflight_type_refrencing_preflight_instance.snap @@ -143,19 +143,18 @@ class $Root extends $stdlib.std.Resource { })()) `; } - static get _liftTypeMap() { + get _liftMap() { return ({ "foo": [ [pc, ["bar"]], ], - "init": [ - ], "$inflight_init": [ + [pc, []], ], }); } } - const $UniqueClassAlias1 = InflightC; + const $InflightC_1 = new InflightC(this, "$InflightC_1"); class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -183,10 +182,12 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ - [$UniqueClassAlias1, ["foo"]], + [$InflightC_1, ["foo"]], [InflightC, []], ], "$inflight_init": [ + [$InflightC_1, []], + [InflightC, []], ], }); } diff --git a/libs/wingc/src/jsify/snapshots/reference_inflight_class.snap b/libs/wingc/src/jsify/snapshots/reference_inflight_class.snap index 091360d9f95..3b585a62c6c 100644 --- a/libs/wingc/src/jsify/snapshots/reference_inflight_class.snap +++ b/libs/wingc/src/jsify/snapshots/reference_inflight_class.snap @@ -86,18 +86,20 @@ class $Root extends $stdlib.std.Resource { })()) `; } + get _liftMap() { + return ({ + "$inflight_init": [ + ], + }); + } static get _liftTypeMap() { return ({ "a": [ ], - "init": [ - ], - "$inflight_init": [ - ], }); } } - const $UniqueClassAlias0 = Foo; + const $Foo_0 = new Foo(this, "$Foo_0"); class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -128,6 +130,7 @@ class $Root extends $stdlib.std.Resource { [Foo, ["a"]], ], "$inflight_init": [ + [Foo, []], ], }); } diff --git a/libs/wingc/src/jsify/snapshots/reference_inflight_from_inflight.snap b/libs/wingc/src/jsify/snapshots/reference_inflight_from_inflight.snap index 5cfda1ffbac..ffbc0c17c30 100644 --- a/libs/wingc/src/jsify/snapshots/reference_inflight_from_inflight.snap +++ b/libs/wingc/src/jsify/snapshots/reference_inflight_from_inflight.snap @@ -99,20 +99,18 @@ class $Root extends $stdlib.std.Resource { })()) `; } - static get _liftTypeMap() { + get _liftMap() { return ({ "foofoo1": [ [s, []], ], - "init": [ - ], "$inflight_init": [ [s, []], ], }); } } - const $UniqueClassAlias0 = Foo; + const $Foo_0 = new Foo(this, "$Foo_0"); class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -143,6 +141,7 @@ class $Root extends $stdlib.std.Resource { [Foo, []], ], "$inflight_init": [ + [Foo, []], ], }); } diff --git a/libs/wingc/src/jsify/snapshots/static_external_inflight_class.snap b/libs/wingc/src/jsify/snapshots/static_external_inflight_class.snap index 6af66caeb09..e6ce52e6af7 100644 --- a/libs/wingc/src/jsify/snapshots/static_external_inflight_class.snap +++ b/libs/wingc/src/jsify/snapshots/static_external_inflight_class.snap @@ -97,18 +97,20 @@ class $Root extends $stdlib.std.Resource { })()) `; } + get _liftMap() { + return ({ + "$inflight_init": [ + ], + }); + } static get _liftTypeMap() { return ({ "foo": [ ], - "init": [ - ], - "$inflight_init": [ - ], }); } } - const $UniqueClassAlias0 = A; + const $A_0 = new A(this, "$A_0"); class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -139,6 +141,7 @@ class $Root extends $stdlib.std.Resource { [A, ["foo"]], ], "$inflight_init": [ + [A, []], ], }); } diff --git a/libs/wingc/src/jsify/snapshots/static_on_std_type.snap b/libs/wingc/src/jsify/snapshots/static_on_std_type.snap index 5a32478cdfc..cf1d544914b 100644 --- a/libs/wingc/src/jsify/snapshots/static_on_std_type.snap +++ b/libs/wingc/src/jsify/snapshots/static_on_std_type.snap @@ -79,6 +79,8 @@ class $Root extends $stdlib.std.Resource { [$stdlib.core.toLiftableModuleType(std.String, "@winglang/sdk/std", "String"), ["fromJson"]], ], "$inflight_init": [ + [$stdlib.core.toLiftableModuleType(std.Json, "@winglang/sdk/std", "Json"), []], + [$stdlib.core.toLiftableModuleType(std.String, "@winglang/sdk/std", "String"), []], ], }); } diff --git a/libs/wingc/src/jsify/snapshots/transitive_reference_via_inflight_class.snap b/libs/wingc/src/jsify/snapshots/transitive_reference_via_inflight_class.snap index 70737c412e2..a374d1a3fda 100644 --- a/libs/wingc/src/jsify/snapshots/transitive_reference_via_inflight_class.snap +++ b/libs/wingc/src/jsify/snapshots/transitive_reference_via_inflight_class.snap @@ -96,20 +96,18 @@ class $Root extends $stdlib.std.Resource { })()) `; } - static get _liftTypeMap() { + get _liftMap() { return ({ "putInBucket": [ [b, ["put"]], ], - "init": [ - ], "$inflight_init": [ [b, []], ], }); } } - const $UniqueClassAlias0 = MyInflightClass; + const $MyInflightClass_0 = new MyInflightClass(this, "$MyInflightClass_0"); class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -137,10 +135,12 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ - [$UniqueClassAlias0, ["putInBucket"]], + [$MyInflightClass_0, ["putInBucket"]], [MyInflightClass, []], ], "$inflight_init": [ + [$MyInflightClass_0, []], + [MyInflightClass, []], ], }); } diff --git a/libs/wingc/src/jsify/snapshots/use_util_functions.snap b/libs/wingc/src/jsify/snapshots/use_util_functions.snap index 77d8599b09a..45c850c6974 100644 --- a/libs/wingc/src/jsify/snapshots/use_util_functions.snap +++ b/libs/wingc/src/jsify/snapshots/use_util_functions.snap @@ -76,6 +76,7 @@ class $Root extends $stdlib.std.Resource { [$stdlib.core.toLiftableModuleType(util.Util, "@winglang/sdk/util", "Util"), ["env"]], ], "$inflight_init": [ + [$stdlib.core.toLiftableModuleType(util.Util, "@winglang/sdk/util", "Util"), []], ], }); } diff --git a/libs/wingc/src/jsify/snapshots/wait_util.snap b/libs/wingc/src/jsify/snapshots/wait_util.snap index 116e5ce1e72..17af6096c38 100644 --- a/libs/wingc/src/jsify/snapshots/wait_util.snap +++ b/libs/wingc/src/jsify/snapshots/wait_util.snap @@ -83,6 +83,7 @@ class $Root extends $stdlib.std.Resource { [$stdlib.core.toLiftableModuleType(util.Util, "@winglang/sdk/util", "Util"), ["waitUntil"]], ], "$inflight_init": [ + [$stdlib.core.toLiftableModuleType(util.Util, "@winglang/sdk/util", "Util"), []], ], }); } From fd71b889cfb1f0a3586d1e193482126fb599e351 Mon Sep 17 00:00:00 2001 From: "monada-bot[bot]" Date: Tue, 20 Feb 2024 14:06:02 +0000 Subject: [PATCH 30/78] chore: self mutation (e2e-1of2.diff) Signed-off-by: monada-bot[bot] --- .../valid/bring_jsii.test.w_compile_tf-aws.md | 1 + ..._static_of_myself.test.w_compile_tf-aws.md | 19 +++++++++----- .../valid/doubler.test.w_compile_tf-aws.md | 2 ++ ...as_struct_members.test.w_compile_tf-aws.md | 10 +++---- ..._preflight_object.test.w_compile_tf-aws.md | 26 +++++++++++++------ .../inflight_init.test.w_compile_tf-aws.md | 23 ++++++++-------- ...erit_stdlib_class.test.w_compile_tf-aws.md | 1 + ...ce_class_inflight.test.w_compile_tf-aws.md | 1 + .../valid/issue_2889.test.w_compile_tf-aws.md | 3 +++ ...t_shared_resource.test.w_compile_tf-aws.md | 1 + ...ft_with_phase_ind.test.w_compile_tf-aws.md | 1 + ..._after_class_init.test.w_compile_tf-aws.md | 1 + .../valid/on_lift.test.w_compile_tf-aws.md | 1 + .../valid/redis.test.w_compile_tf-aws.md | 1 + .../valid/resource.test.w_compile_tf-aws.md | 1 + .../struct_from_json.test.w_compile_tf-aws.md | 9 +++++++ 16 files changed, 70 insertions(+), 31 deletions(-) diff --git a/tools/hangar/__snapshots__/test_corpus/valid/bring_jsii.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/bring_jsii.test.w_compile_tf-aws.md index d8e18180b27..1bdb0676f4c 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/bring_jsii.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/bring_jsii.test.w_compile_tf-aws.md @@ -88,6 +88,7 @@ class $Root extends $stdlib.std.Resource { [greeting, []], ], "$inflight_init": [ + [$stdlib.core.toLiftableModuleType(stuff.HelloWorld, "jsii-code-samples", "HelloWorld"), []], [greeting, []], ], }); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/call_static_of_myself.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/call_static_of_myself.test.w_compile_tf-aws.md index ea4af2198b6..298b5826ac2 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/call_static_of_myself.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/call_static_of_myself.test.w_compile_tf-aws.md @@ -164,21 +164,24 @@ class $Root extends $stdlib.std.Resource { })()) `; } - static get _liftTypeMap() { + get _liftMap() { return ({ - "bar": [ - ], "callThis": [ [Bar, ["bar"]], ], - "init": [ - ], "$inflight_init": [ + [Bar, []], + ], + }); + } + static get _liftTypeMap() { + return ({ + "bar": [ ], }); } } - const $UniqueClassAlias1 = Bar; + const $Bar_1 = new Bar(this, "$Bar_1"); class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -208,12 +211,14 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ - [$UniqueClassAlias1, ["callThis"]], + [$Bar_1, ["callThis"]], [Bar, ["bar"]], [Foo, ["foo"]], [foo, ["callThis"]], ], "$inflight_init": [ + [$Bar_1, []], + [Bar, []], [Foo, []], [foo, []], ], diff --git a/tools/hangar/__snapshots__/test_corpus/valid/doubler.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/doubler.test.w_compile_tf-aws.md index e91173874d4..10a794edc3e 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/doubler.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/doubler.test.w_compile_tf-aws.md @@ -362,6 +362,8 @@ class $Root extends $stdlib.std.Resource { [handler, ["handle"]], ], "$inflight_init": [ + [$stdlib.core.toLiftableModuleType(std.Json, "@winglang/sdk/std", "Json"), []], + [$stdlib.core.toLiftableModuleType(std.Number, "@winglang/sdk/std", "Number"), []], [handler, []], ], }); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_as_struct_members.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_as_struct_members.test.w_compile_tf-aws.md index 4e6b953b3d7..c83c59f785f 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_as_struct_members.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_as_struct_members.test.w_compile_tf-aws.md @@ -108,18 +108,16 @@ class $Root extends $stdlib.std.Resource { })()) `; } - static get _liftTypeMap() { + get _liftMap() { return ({ "get": [ ], - "init": [ - ], "$inflight_init": [ ], }); } } - const $UniqueClassAlias0 = Foo; + const $Foo_0 = new Foo(this, "$Foo_0"); class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -150,6 +148,7 @@ class $Root extends $stdlib.std.Resource { [Foo, []], ], "$inflight_init": [ + [Foo, []], ], }); } @@ -181,10 +180,11 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ - [$UniqueClassAlias0, ["get"]], + [$Foo_0, ["get"]], [getBar, ["handle"]], ], "$inflight_init": [ + [$Foo_0, []], [getBar, []], ], }); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_capture_preflight_object.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_capture_preflight_object.test.w_compile_tf-aws.md index 3ada96aec13..2fdde13ef2a 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_capture_preflight_object.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_capture_preflight_object.test.w_compile_tf-aws.md @@ -196,22 +196,25 @@ class $Root extends $stdlib.std.Resource { })()) `; } - static get _liftTypeMap() { + get _liftMap() { return ({ "uploadToBucket": [ [b, ["get", "put"]], ], + "$inflight_init": [ + [b, []], + ], + }); + } + static get _liftTypeMap() { + return ({ "fooStatic": [ [b, ["list"]], ], - "init": [ - ], - "$inflight_init": [ - ], }); } } - const $UniqueClassAlias0 = Foo; + const $Foo_0 = new Foo(this, "$Foo_0"); class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -239,10 +242,12 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ - [$UniqueClassAlias0, ["uploadToBucket"]], + [$Foo_0, ["uploadToBucket"]], [Foo, []], ], "$inflight_init": [ + [$Foo_0, []], + [Foo, []], ], }); } @@ -277,6 +282,7 @@ class $Root extends $stdlib.std.Resource { [Foo, ["fooStatic"]], ], "$inflight_init": [ + [Foo, []], ], }); } @@ -311,6 +317,7 @@ class $Root extends $stdlib.std.Resource { [Foo, []], ], "$inflight_init": [ + [Foo, []], ], }); } @@ -342,10 +349,12 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ - [$UniqueClassAlias0, ["uploadToBucket"]], + [$Foo_0, ["uploadToBucket"]], [getFoo, ["handle"]], ], "$inflight_init": [ + [$Foo_0, []], + [getFoo, []], ], }); } @@ -380,6 +389,7 @@ class $Root extends $stdlib.std.Resource { [b, ["get", "put"]], ], "$inflight_init": [ + [b, []], ], }); } diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight_init.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight_init.test.w_compile_tf-aws.md index 545491ee15d..ea595705b5c 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight_init.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight_init.test.w_compile_tf-aws.md @@ -217,12 +217,10 @@ class $Root extends $stdlib.std.Resource { })()) `; } - static get _liftTypeMap() { + get _liftMap() { return ({ "get_six": [ ], - "init": [ - ], "$inflight_init": [ [this, ["field1", "field2", "get_six"]], ], @@ -233,7 +231,7 @@ class $Root extends $stdlib.std.Resource { }); } } - const $UniqueClassAlias0 = Foo; + const $Foo_0 = new Foo(this, "$Foo_0"); class FooChild extends Foo { constructor($scope, $id, ) { super($scope, $id); @@ -256,10 +254,8 @@ class $Root extends $stdlib.std.Resource { })()) `; } - static get _liftTypeMap() { - return $stdlib.core.mergeLiftDeps(super._liftTypeMap, { - "init": [ - ], + get _liftMap() { + return $stdlib.core.mergeLiftDeps(super._liftMap, { "$inflight_init": [ [this, ["field3"]], ], @@ -268,7 +264,7 @@ class $Root extends $stdlib.std.Resource { }); } } - const $UniqueClassAlias1 = FooChild; + const $FooChild_1 = new FooChild(this, "$FooChild_1"); class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -296,10 +292,12 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ - [$UniqueClassAlias0, ["field1", "field2"]], + [$Foo_0, ["field1", "field2"]], [Foo, []], ], "$inflight_init": [ + [$Foo_0, []], + [Foo, []], ], }); } @@ -331,10 +329,12 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ - [$UniqueClassAlias1, ["field1", "field2", "field3"]], + [$FooChild_1, ["field1", "field2", "field3"]], [FooChild, []], ], "$inflight_init": [ + [$FooChild_1, []], + [FooChild, []], ], }); } @@ -401,6 +401,7 @@ class $Root extends $stdlib.std.Resource { [$stdlib.core.toLiftableModuleType(jsii_fixture.JsiiClass, "jsii-fixture", "JsiiClass"), []], ], "$inflight_init": [ + [$stdlib.core.toLiftableModuleType(jsii_fixture.JsiiClass, "jsii-fixture", "JsiiClass"), []], ], }); } diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inherit_stdlib_class.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inherit_stdlib_class.test.w_compile_tf-aws.md index fdf7654be61..2b1cbd88016 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inherit_stdlib_class.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inherit_stdlib_class.test.w_compile_tf-aws.md @@ -387,6 +387,7 @@ class $Root extends $stdlib.std.Resource { [api.url, []], ], "$inflight_init": [ + [$stdlib.core.toLiftableModuleType(http.Util, "@winglang/sdk/http", "Util"), []], [api.url, []], ], }); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inheritance_class_inflight.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inheritance_class_inflight.test.w_compile_tf-aws.md index bc4eeca5cad..21bd7e2bb58 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inheritance_class_inflight.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inheritance_class_inflight.test.w_compile_tf-aws.md @@ -192,6 +192,7 @@ class $Root extends $stdlib.std.Resource { [foo, ["bang", "bug", "over_inflight"]], ], "$inflight_init": [ + [$stdlib.core.toLiftableModuleType(expect.Util, "@winglang/sdk/expect", "Util"), []], [foo, []], ], }); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/issue_2889.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/issue_2889.test.w_compile_tf-aws.md index f0844c39bdf..7d56e53ce3f 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/issue_2889.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/issue_2889.test.w_compile_tf-aws.md @@ -312,6 +312,7 @@ class $Root extends $stdlib.std.Resource { [$stdlib.core.toLiftableModuleType(std.Json, "@winglang/sdk/std", "Json"), ["parse", "stringify"]], ], "$inflight_init": [ + [$stdlib.core.toLiftableModuleType(std.Json, "@winglang/sdk/std", "Json"), []], ], }); } @@ -350,6 +351,8 @@ class $Root extends $stdlib.std.Resource { [api.url, []], ], "$inflight_init": [ + [$stdlib.core.toLiftableModuleType(http.Util, "@winglang/sdk/http", "Util"), []], + [$stdlib.core.toLiftableModuleType(std.Json, "@winglang/sdk/std", "Json"), []], [api.url, []], ], }); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/lift_shared_resource.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/lift_shared_resource.test.w_compile_tf-aws.md index 7da69b511de..8723fd13354 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/lift_shared_resource.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/lift_shared_resource.test.w_compile_tf-aws.md @@ -414,6 +414,7 @@ class $Root extends $stdlib.std.Resource { [api.url, []], ], "$inflight_init": [ + [$stdlib.core.toLiftableModuleType(http.Util, "@winglang/sdk/http", "Util"), []], [api.url, []], ], }); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/lift_with_phase_ind.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/lift_with_phase_ind.test.w_compile_tf-aws.md index 3f456a5a1e5..729141ecf02 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/lift_with_phase_ind.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/lift_with_phase_ind.test.w_compile_tf-aws.md @@ -93,6 +93,7 @@ class $Root extends $stdlib.std.Resource { [ar.length, []], ], "$inflight_init": [ + [$stdlib.core.toLiftableModuleType(math.Util, "@winglang/sdk/math", "Util"), []], [((arr, index) => { if (index < 0 || index >= arr.length) throw new Error("Index out of bounds"); return arr[index]; })(ar, 0), []], [ar, []], [ar.length, []], diff --git a/tools/hangar/__snapshots__/test_corpus/valid/mutation_after_class_init.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/mutation_after_class_init.test.w_compile_tf-aws.md index 66afd5229a1..bb7ffc488d1 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/mutation_after_class_init.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/mutation_after_class_init.test.w_compile_tf-aws.md @@ -522,6 +522,7 @@ class $Root extends $stdlib.std.Resource { [q, ["push"]], ], "$inflight_init": [ + [$stdlib.core.toLiftableModuleType(util.Util, "@winglang/sdk/util", "Util"), []], [c, []], [q, []], ], diff --git a/tools/hangar/__snapshots__/test_corpus/valid/on_lift.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/on_lift.test.w_compile_tf-aws.md index 634a6dd0cd2..39d39d510cc 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/on_lift.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/on_lift.test.w_compile_tf-aws.md @@ -113,6 +113,7 @@ class $Root extends $stdlib.std.Resource { [$stdlib.core.toLiftableModuleType(util.Util, "@winglang/sdk/util", "Util"), ["env"]], ], "$inflight_init": [ + [$stdlib.core.toLiftableModuleType(util.Util, "@winglang/sdk/util", "Util"), []], ], }); } diff --git a/tools/hangar/__snapshots__/test_corpus/valid/redis.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/redis.test.w_compile_tf-aws.md index 72cc8fa3cac..84743fba484 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/redis.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/redis.test.w_compile_tf-aws.md @@ -616,6 +616,7 @@ class $Root extends $stdlib.std.Resource { [r2, ["get", "set"]], ], "$inflight_init": [ + [$stdlib.core.toLiftableModuleType(util.Util, "@winglang/sdk/util", "Util"), []], [queue, []], [r, []], [r2, []], diff --git a/tools/hangar/__snapshots__/test_corpus/valid/resource.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/resource.test.w_compile_tf-aws.md index 7e5d983e964..efec6d2f791 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/resource.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/resource.test.w_compile_tf-aws.md @@ -804,6 +804,7 @@ class $Root extends $stdlib.std.Resource { "$inflight_init": [ [Bar, []], [Foo, []], + [MyEnum, []], [this.b, []], [this.e, []], [this.foo, []], diff --git a/tools/hangar/__snapshots__/test_corpus/valid/struct_from_json.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/struct_from_json.test.w_compile_tf-aws.md index 789469b6376..3bca3a4c0d4 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/struct_from_json.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/struct_from_json.test.w_compile_tf-aws.md @@ -222,6 +222,7 @@ class $Root extends $stdlib.std.Resource { [j, []], ], "$inflight_init": [ + [$stdlib.core.toLiftableModuleType(cloud_BucketProps, "@winglang/sdk/cloud", "BucketProps"), []], [j, []], ], }); @@ -257,6 +258,7 @@ class $Root extends $stdlib.std.Resource { [Student, ["fromJson"]], ], "$inflight_init": [ + [Student, []], ], }); } @@ -293,6 +295,7 @@ class $Root extends $stdlib.std.Resource { [jStudent1, []], ], "$inflight_init": [ + [Student, []], [jStudent1, []], ], }); @@ -336,7 +339,9 @@ class $Root extends $stdlib.std.Resource { [jMyStruct, []], ], "$inflight_init": [ + [$stdlib.core.toLiftableModuleType(std.Json, "@winglang/sdk/std", "Json"), []], [(schema.asStr()), []], + [MyStruct, []], [expectedSchema, []], [jMyStruct, []], ], @@ -379,6 +384,10 @@ class $Root extends $stdlib.std.Resource { [Student, ["fromJson"]], ], "$inflight_init": [ + [$stdlib.core.toLiftableModuleType(std.Boolean, "@winglang/sdk/std", "Boolean"), []], + [$stdlib.core.toLiftableModuleType(std.Number, "@winglang/sdk/std", "Number"), []], + [$stdlib.core.toLiftableModuleType(std.String, "@winglang/sdk/std", "String"), []], + [Student, []], ], }); } From 0db70d9cd61c67a5720c674cd9a2b6a2fd84cf3c Mon Sep 17 00:00:00 2001 From: "monada-bot[bot]" Date: Tue, 20 Feb 2024 14:06:02 +0000 Subject: [PATCH 31/78] chore: self mutation (e2e-2of2.diff) Signed-off-by: monada-bot[bot] --- .../valid/api.test.w_compile_tf-aws.md | 1 + .../api_cors_custom.test.w_compile_tf-aws.md | 8 ++++++++ .../api_cors_default.test.w_compile_tf-aws.md | 5 +++++ ...gable_class_field.test.w_compile_tf-aws.md | 1 + .../valid/class.test.w_compile_tf-aws.md | 18 ++++++++--------- .../valid/enums.test.w_compile_tf-aws.md | 1 + ...ht_capture_static.test.w_compile_tf-aws.md | 14 ++++++++----- ...ass_capture_const.test.w_compile_tf-aws.md | 10 +++++----- ...class_definitions.test.w_compile_tf-aws.md | 20 +++++++++---------- ...t_class_modifiers.test.w_compile_tf-aws.md | 6 ++---- ..._inflight_closure.test.w_compile_tf-aws.md | 10 +++++----- ..._interace_handler.test.w_compile_tf-aws.md | 7 +++---- ...lass_without_init.test.w_compile_tf-aws.md | 7 +++---- ...handler_singleton.test.w_compile_tf-aws.md | 1 + .../json_static.test.w_compile_tf-aws.md | 2 ++ .../valid/lift_this.test.w_compile_tf-aws.md | 1 + .../valid/super_call.test.w_compile_tf-aws.md | 20 +++++++++---------- .../website_with_api.test.w_compile_tf-aws.md | 8 ++++++++ 18 files changed, 83 insertions(+), 57 deletions(-) diff --git a/tools/hangar/__snapshots__/test_corpus/valid/api.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/api.test.w_compile_tf-aws.md index 8095394e4fc..7f82d148320 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/api.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/api.test.w_compile_tf-aws.md @@ -512,6 +512,7 @@ class $Root extends $stdlib.std.Resource { [counter, ["inc"]], ], "$inflight_init": [ + [$stdlib.core.toLiftableModuleType(std.Json, "@winglang/sdk/std", "Json"), []], [counter, []], ], }); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/api_cors_custom.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/api_cors_custom.test.w_compile_tf-aws.md index db75f39463a..66f94d7b84b 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/api_cors_custom.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/api_cors_custom.test.w_compile_tf-aws.md @@ -405,6 +405,8 @@ class $Root extends $stdlib.std.Resource { [api.url, []], ], "$inflight_init": [ + [$stdlib.core.toLiftableModuleType(expect.Util, "@winglang/sdk/expect", "Util"), []], + [$stdlib.core.toLiftableModuleType(http.Util, "@winglang/sdk/http", "Util"), []], [api.url, []], ], }); @@ -446,6 +448,9 @@ class $Root extends $stdlib.std.Resource { [api.url, []], ], "$inflight_init": [ + [$stdlib.core.toLiftableModuleType(expect.Util, "@winglang/sdk/expect", "Util"), []], + [$stdlib.core.toLiftableModuleType(http.HttpMethod, "@winglang/sdk/http", "HttpMethod"), []], + [$stdlib.core.toLiftableModuleType(http.Util, "@winglang/sdk/http", "Util"), []], [api.url, []], ], }); @@ -487,6 +492,9 @@ class $Root extends $stdlib.std.Resource { [api.url, []], ], "$inflight_init": [ + [$stdlib.core.toLiftableModuleType(expect.Util, "@winglang/sdk/expect", "Util"), []], + [$stdlib.core.toLiftableModuleType(http.HttpMethod, "@winglang/sdk/http", "HttpMethod"), []], + [$stdlib.core.toLiftableModuleType(http.Util, "@winglang/sdk/http", "Util"), []], [api.url, []], ], }); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/api_cors_default.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/api_cors_default.test.w_compile_tf-aws.md index 9e915b3165d..e822800a42f 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/api_cors_default.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/api_cors_default.test.w_compile_tf-aws.md @@ -380,6 +380,8 @@ class $Root extends $stdlib.std.Resource { [apiDefaultCors.url, []], ], "$inflight_init": [ + [$stdlib.core.toLiftableModuleType(expect.Util, "@winglang/sdk/expect", "Util"), []], + [$stdlib.core.toLiftableModuleType(http.Util, "@winglang/sdk/http", "Util"), []], [apiDefaultCors.url, []], ], }); @@ -421,6 +423,9 @@ class $Root extends $stdlib.std.Resource { [apiDefaultCors.url, []], ], "$inflight_init": [ + [$stdlib.core.toLiftableModuleType(expect.Util, "@winglang/sdk/expect", "Util"), []], + [$stdlib.core.toLiftableModuleType(http.HttpMethod, "@winglang/sdk/http", "HttpMethod"), []], + [$stdlib.core.toLiftableModuleType(http.Util, "@winglang/sdk/http", "Util"), []], [apiDefaultCors.url, []], ], }); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/capture_reassigable_class_field.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/capture_reassigable_class_field.test.w_compile_tf-aws.md index e8ae6212609..b12c28041a2 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/capture_reassigable_class_field.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/capture_reassigable_class_field.test.w_compile_tf-aws.md @@ -304,6 +304,7 @@ class $Root extends $stdlib.std.Resource { [kv, ["get", "set"]], ], "$inflight_init": [ + [$stdlib.core.toLiftableModuleType(util.Util, "@winglang/sdk/util", "Util"), []], [counter, []], [kv, []], ], diff --git a/tools/hangar/__snapshots__/test_corpus/valid/class.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/class.test.w_compile_tf-aws.md index d28d2f67c22..a11851fe350 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/class.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/class.test.w_compile_tf-aws.md @@ -770,10 +770,8 @@ class $Root extends $stdlib.std.Resource { })()) `; } - static get _liftTypeMap() { + get _liftMap() { return ({ - "init": [ - ], "$inflight_init": [ [this, ["sound"]], ], @@ -782,7 +780,7 @@ class $Root extends $stdlib.std.Resource { }); } } - const $UniqueClassAlias12 = A; + const $A_12 = new A(this, "$A_12"); class B extends A { constructor($scope, $id, ) { super($scope, $id); @@ -805,16 +803,14 @@ class $Root extends $stdlib.std.Resource { })()) `; } - static get _liftTypeMap() { - return $stdlib.core.mergeLiftDeps(super._liftTypeMap, { - "init": [ - ], + get _liftMap() { + return $stdlib.core.mergeLiftDeps(super._liftMap, { "$inflight_init": [ ], }); } } - const $UniqueClassAlias13 = B; + const $B_13 = new B(this, "$B_13"); class $Closure4 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -842,10 +838,12 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ - [$UniqueClassAlias13, ["sound"]], + [$B_13, ["sound"]], [B, []], ], "$inflight_init": [ + [$B_13, []], + [B, []], ], }); } diff --git a/tools/hangar/__snapshots__/test_corpus/valid/enums.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/enums.test.w_compile_tf-aws.md index 69bc6c3985f..987f8f2c3d0 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/enums.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/enums.test.w_compile_tf-aws.md @@ -94,6 +94,7 @@ class $Root extends $stdlib.std.Resource { [two, []], ], "$inflight_init": [ + [SomeEnum, []], [one, []], [two, []], ], diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight_capture_static.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight_capture_static.test.w_compile_tf-aws.md index 5051b1ee3d2..468cc8756d9 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight_capture_static.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight_capture_static.test.w_compile_tf-aws.md @@ -213,18 +213,20 @@ class $Root extends $stdlib.std.Resource { })()) `; } + get _liftMap() { + return ({ + "$inflight_init": [ + ], + }); + } static get _liftTypeMap() { return ({ "staticMethod": [ ], - "init": [ - ], - "$inflight_init": [ - ], }); } } - const $UniqueClassAlias1 = OuterInflight; + const $OuterInflight_1 = new OuterInflight(this, "$OuterInflight_1"); class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -290,6 +292,7 @@ class $Root extends $stdlib.std.Resource { [OuterInflight, ["staticMethod"]], ], "$inflight_init": [ + [OuterInflight, []], ], }); } @@ -356,6 +359,7 @@ class $Root extends $stdlib.std.Resource { [$stdlib.core.toLiftableModuleType(util.Util, "@winglang/sdk/util", "Util"), ["tryEnv"]], ], "$inflight_init": [ + [$stdlib.core.toLiftableModuleType(util.Util, "@winglang/sdk/util", "Util"), []], ], }); } diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_capture_const.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_capture_const.test.w_compile_tf-aws.md index 291b7d22b4d..d59d737b4d5 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_capture_const.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_capture_const.test.w_compile_tf-aws.md @@ -90,20 +90,18 @@ class $Root extends $stdlib.std.Resource { })()) `; } - static get _liftTypeMap() { + get _liftMap() { return ({ "getValue": [ [myConst, []], ], - "init": [ - ], "$inflight_init": [ [myConst, []], ], }); } } - const $UniqueClassAlias0 = Foo; + const $Foo_0 = new Foo(this, "$Foo_0"); class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -132,11 +130,13 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ - [$UniqueClassAlias0, ["getValue"]], + [$Foo_0, ["getValue"]], [Foo, []], [myConst, []], ], "$inflight_init": [ + [$Foo_0, []], + [Foo, []], [myConst, []], ], }); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_definitions.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_definitions.test.w_compile_tf-aws.md index b0a8f1b66bb..f1ac7bc6fdc 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_definitions.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_definitions.test.w_compile_tf-aws.md @@ -235,18 +235,16 @@ class $Root extends $stdlib.std.Resource { })()) `; } - static get _liftTypeMap() { + get _liftMap() { return ({ "foo": [ ], - "init": [ - ], "$inflight_init": [ ], }); } } - const $UniqueClassAlias1 = B; + const $B_1 = new B(this, "$B_1"); class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -336,18 +334,16 @@ class $Root extends $stdlib.std.Resource { })()) `; } - static get _liftTypeMap() { + get _liftMap() { return ({ "foo": [ ], - "init": [ - ], "$inflight_init": [ ], }); } } - const $UniqueClassAlias7 = F; + const $F_7 = new F(this, "$F_7"); const __parent_this_2 = this; class $Closure2 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); @@ -376,10 +372,12 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ - [$UniqueClassAlias7, ["foo"]], + [$F_7, ["foo"]], [F, ["foo"]], ], "$inflight_init": [ + [$F_7, []], + [F, []], ], }); } @@ -449,7 +447,7 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ - [$UniqueClassAlias1, ["foo"]], + [$B_1, ["foo"]], [B, []], [a, ["goo"]], [d, ["callInner"]], @@ -457,6 +455,8 @@ class $Root extends $stdlib.std.Resource { [innerD, ["handle"]], ], "$inflight_init": [ + [$B_1, []], + [B, []], [a, []], [d, []], [fn, []], diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_modifiers.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_modifiers.test.w_compile_tf-aws.md index b5cf8742f3e..beab5c3b958 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_modifiers.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_modifiers.test.w_compile_tf-aws.md @@ -71,12 +71,10 @@ class $Root extends $stdlib.std.Resource { })()) `; } - static get _liftTypeMap() { + get _liftMap() { return ({ "method": [ ], - "init": [ - ], "$inflight_init": [ [this, ["field"]], ], @@ -85,7 +83,7 @@ class $Root extends $stdlib.std.Resource { }); } } - const $UniqueClassAlias0 = C; + const $C_0 = new C(this, "$C_0"); } } const $PlatformManager = new $stdlib.platform.PlatformManager({platformPaths: $platforms}); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_outside_inflight_closure.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_outside_inflight_closure.test.w_compile_tf-aws.md index c551ba5f458..3072bf38b9e 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_outside_inflight_closure.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_outside_inflight_closure.test.w_compile_tf-aws.md @@ -95,13 +95,11 @@ class $Root extends $stdlib.std.Resource { })()) `; } - static get _liftTypeMap() { + get _liftMap() { return ({ "add": [ [this, ["lhs", "rhs"]], ], - "init": [ - ], "$inflight_init": [ [this, ["lhs", "rhs"]], ], @@ -112,7 +110,7 @@ class $Root extends $stdlib.std.Resource { }); } } - const $UniqueClassAlias0 = BinaryOperation; + const $BinaryOperation_0 = new BinaryOperation(this, "$BinaryOperation_0"); class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -140,10 +138,12 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ - [$UniqueClassAlias0, ["add"]], + [$BinaryOperation_0, ["add"]], [BinaryOperation, []], ], "$inflight_init": [ + [$BinaryOperation_0, []], + [BinaryOperation, []], ], }); } diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_structural_interace_handler.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_structural_interace_handler.test.w_compile_tf-aws.md index 21655cfe03e..aaeae2fae0f 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_structural_interace_handler.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_structural_interace_handler.test.w_compile_tf-aws.md @@ -100,18 +100,16 @@ class $Root extends $stdlib.std.Resource { })()) `; } - static get _liftTypeMap() { + get _liftMap() { return ({ "handle": [ ], - "init": [ - ], "$inflight_init": [ ], }); } } - const $UniqueClassAlias0 = NotGoo; + const $NotGoo_0 = new NotGoo(this, "$NotGoo_0"); class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -142,6 +140,7 @@ class $Root extends $stdlib.std.Resource { [NotGoo, []], ], "$inflight_init": [ + [NotGoo, []], ], }); } diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_without_init.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_without_init.test.w_compile_tf-aws.md index cb0f160f632..f927dce2d28 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_without_init.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_without_init.test.w_compile_tf-aws.md @@ -85,16 +85,14 @@ class $Root extends $stdlib.std.Resource { })()) `; } - static get _liftTypeMap() { + get _liftMap() { return ({ - "init": [ - ], "$inflight_init": [ ], }); } } - const $UniqueClassAlias0 = Foo; + const $Foo_0 = new Foo(this, "$Foo_0"); class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -125,6 +123,7 @@ class $Root extends $stdlib.std.Resource { [Foo, []], ], "$inflight_init": [ + [Foo, []], ], }); } diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight_handler_singleton.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight_handler_singleton.test.w_compile_tf-aws.md index 010240aceae..a908bf9ed81 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight_handler_singleton.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight_handler_singleton.test.w_compile_tf-aws.md @@ -451,6 +451,7 @@ class $Root extends $stdlib.std.Resource { [sim, []], ], "$inflight_init": [ + [$stdlib.core.toLiftableModuleType(expect.Util, "@winglang/sdk/expect", "Util"), []], [fn, []], [fn2, []], [sim, []], diff --git a/tools/hangar/__snapshots__/test_corpus/valid/json_static.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/json_static.test.w_compile_tf-aws.md index f71cc594cb7..a36820157a7 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/json_static.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/json_static.test.w_compile_tf-aws.md @@ -107,6 +107,7 @@ class $Root extends $stdlib.std.Resource { [jj, []], ], "$inflight_init": [ + [$stdlib.core.toLiftableModuleType(std.Json, "@winglang/sdk/std", "Json"), []], [jj, []], ], }); @@ -142,6 +143,7 @@ class $Root extends $stdlib.std.Resource { [$stdlib.core.toLiftableModuleType(std.Json, "@winglang/sdk/std", "Json"), ["has"]], ], "$inflight_init": [ + [$stdlib.core.toLiftableModuleType(std.Json, "@winglang/sdk/std", "Json"), []], ], }); } diff --git a/tools/hangar/__snapshots__/test_corpus/valid/lift_this.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/lift_this.test.w_compile_tf-aws.md index 8b117c9e153..60c5358d69e 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/lift_this.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/lift_this.test.w_compile_tf-aws.md @@ -148,6 +148,7 @@ class $Root extends $stdlib.std.Resource { [f, ["foo"]], ], "$inflight_init": [ + [$stdlib.core.toLiftableModuleType(util.Util, "@winglang/sdk/util", "Util"), []], [f, []], ], }); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/super_call.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/super_call.test.w_compile_tf-aws.md index 1697dc0d418..73719d4beb5 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/super_call.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/super_call.test.w_compile_tf-aws.md @@ -403,18 +403,16 @@ class $Root extends $stdlib.std.Resource { })()) `; } - static get _liftTypeMap() { + get _liftMap() { return ({ "description": [ ], - "init": [ - ], "$inflight_init": [ ], }); } } - const $UniqueClassAlias5 = InflightA; + const $InflightA_5 = new InflightA(this, "$InflightA_5"); class InflightB extends InflightA { constructor($scope, $id, ) { super($scope, $id); @@ -437,18 +435,16 @@ class $Root extends $stdlib.std.Resource { })()) `; } - static get _liftTypeMap() { - return $stdlib.core.mergeLiftDeps(super._liftTypeMap, { + get _liftMap() { + return $stdlib.core.mergeLiftDeps(super._liftMap, { "description": [ ], - "init": [ - ], "$inflight_init": [ ], }); } } - const $UniqueClassAlias6 = InflightB; + const $InflightB_6 = new InflightB(this, "$InflightB_6"); class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -477,11 +473,14 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ - [$UniqueClassAlias6, ["description"]], + [$InflightB_6, ["description"]], [$stdlib.core.toLiftableModuleType(expect.Util, "@winglang/sdk/expect", "Util"), ["equal"]], [InflightB, []], ], "$inflight_init": [ + [$InflightB_6, []], + [$stdlib.core.toLiftableModuleType(expect.Util, "@winglang/sdk/expect", "Util"), []], + [InflightB, []], ], }); } @@ -585,6 +584,7 @@ class $Root extends $stdlib.std.Resource { [extended, ["do"]], ], "$inflight_init": [ + [$stdlib.core.toLiftableModuleType(expect.Util, "@winglang/sdk/expect", "Util"), []], [extended, []], ], }); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/website_with_api.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/website_with_api.test.w_compile_tf-aws.md index 9dc744eeec9..53ce75458a0 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/website_with_api.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/website_with_api.test.w_compile_tf-aws.md @@ -664,6 +664,7 @@ class $Root extends $stdlib.std.Resource { [usersTable, ["list"]], ], "$inflight_init": [ + [$stdlib.core.toLiftableModuleType(std.Json, "@winglang/sdk/std", "Json"), []], [usersTable, []], ], }); @@ -701,6 +702,7 @@ class $Root extends $stdlib.std.Resource { [usersTable, ["insert"]], ], "$inflight_init": [ + [$stdlib.core.toLiftableModuleType(std.Json, "@winglang/sdk/std", "Json"), []], [usersTable, []], ], }); @@ -742,6 +744,9 @@ class $Root extends $stdlib.std.Resource { [api.url, []], ], "$inflight_init": [ + [$stdlib.core.toLiftableModuleType(expect.Util, "@winglang/sdk/expect", "Util"), []], + [$stdlib.core.toLiftableModuleType(http.HttpMethod, "@winglang/sdk/http", "HttpMethod"), []], + [$stdlib.core.toLiftableModuleType(http.Util, "@winglang/sdk/http", "Util"), []], [api.url, []], ], }); @@ -783,6 +788,9 @@ class $Root extends $stdlib.std.Resource { [api.url, []], ], "$inflight_init": [ + [$stdlib.core.toLiftableModuleType(expect.Util, "@winglang/sdk/expect", "Util"), []], + [$stdlib.core.toLiftableModuleType(http.HttpMethod, "@winglang/sdk/http", "HttpMethod"), []], + [$stdlib.core.toLiftableModuleType(http.Util, "@winglang/sdk/http", "Util"), []], [api.url, []], ], }); From 8e90a4f23fe8c3462d409fead653b9c498596408 Mon Sep 17 00:00:00 2001 From: Yoav Steinberg Date: Sun, 10 Mar 2024 11:33:57 +0200 Subject: [PATCH 32/78] inflight class singletons are defined per root node and not globaly --- libs/wingc/src/jsify.rs | 43 ++++++++++++++++++++++++++++---- libs/wingc/src/lifting.rs | 2 +- libs/wingc/src/type_check.rs | 13 +++++----- libs/wingsdk/src/std/resource.ts | 43 +++++++++++++++++++++++++++++--- 4 files changed, 84 insertions(+), 17 deletions(-) diff --git a/libs/wingc/src/jsify.rs b/libs/wingc/src/jsify.rs index 0f00bd7c0a0..16138c12348 100644 --- a/libs/wingc/src/jsify.rs +++ b/libs/wingc/src/jsify.rs @@ -56,6 +56,10 @@ const NODE_MODULES_SCOPE_SPECIFIER: &str = "@"; const SUPER_CLASS_INFLIGHT_INIT_NAME: &str = formatcp!("super_{CLASS_INFLIGHT_INIT_NAME}"); +//const PREFLIGHT_TYPES_MAP: &str = "globalThis.$preflightTypesMap"; +//const PREFLIGHT_TYPES_MAP: &str = "this.node.root.$preflightTypesMap"; +const PREFLIGHT_TYPES_MAP: &str = "$helpers.nodeof(this).root.$preflightTypesMap"; + pub struct JSifyContext<'a> { pub lifts: Option<&'a Lifts>, pub visit_ctx: &'a mut VisitContext, @@ -185,6 +189,7 @@ impl<'a> JSifier<'a> { // "std" is implicitly imported output.line(format!("const std = {STDLIB}.{WINGSDK_STD_MODULE};")); output.line(format!("const {HELPERS_VAR} = {STDLIB}.helpers;")); + output.add_code(imports); if is_entrypoint { @@ -193,6 +198,10 @@ impl<'a> JSifier<'a> { root_class.open(format!("{JS_CONSTRUCTOR}($scope, $id) {{")); root_class.line("super($scope, $id);"); root_class.add_code(self.jsify_struct_schemas()); + + // Create global map of preflight class types + root_class.line(format!("{PREFLIGHT_TYPES_MAP} = {{}};")); + root_class.add_code(js); root_class.close("}"); root_class.close("}"); @@ -1520,20 +1529,44 @@ impl<'a> JSifier<'a> { // Inflight classes might need their type to be lift-qualified (onLift), but their type name might not be necessarily avaialble // at the scope when they are qualified (it might even be shadowed by another type name). Here we generate a unique // type name to be used in such cases. + // if class.phase == Phase::Inflight { + // let inflight_class_unique_instance = self.unique_class_alias(class_type); + // code.line(format!( + // "const {inflight_class_unique_instance} = new {}(this, \"{inflight_class_unique_instance}\");", + // class.name, + // )); + // } + + // Inflight classes might need to be lift-qualified (onLift), but their type name might not be necessarily avaialble + // at the scope when they are qualified (it might even be shadowed by another type name). We atore a reference to these + // class types in a global preflight types map indexed by the class's unique id. if class.phase == Phase::Inflight { - let inflight_class_unique_instance = self.unique_class_alias(class_type); code.line(format!( - "const {inflight_class_unique_instance} = new {}(this, \"{inflight_class_unique_instance}\");", - class.name, + "if ({PREFLIGHT_TYPES_MAP}[{}]) {{ throw new Error(\"{} is already in type map\"); }}", + class_type.as_class().unwrap().uid, + class.name + )); + code.line(format!( + "{PREFLIGHT_TYPES_MAP}[{}] = {};", + class_type.as_class().unwrap().uid, + class.name + )); + code.line(format!( + "console.log(`Adding {} to ${{$helpers.nodeof(this).root.node.id}}`);", + class.name )); } + code }) } - pub fn unique_class_alias(&self, type_: TypeRef) -> String { + pub fn class_singleton(&self, type_: TypeRef) -> String { let c = type_.as_class().unwrap(); - format!("${}_{}", c.name, c.uid) + format!( + "{PREFLIGHT_TYPES_MAP}[{}]._singleton(this,\"{}_singleton_{}\")", + c.uid, c.name, c.uid + ) } fn jsify_preflight_constructor(&self, class: &AstClass, ctx: &mut JSifyContext) -> CodeMaker { diff --git a/libs/wingc/src/lifting.rs b/libs/wingc/src/lifting.rs index 6145f2828b7..034d2560be9 100644 --- a/libs/wingc/src/lifting.rs +++ b/libs/wingc/src/lifting.rs @@ -292,7 +292,7 @@ impl<'a> Visit<'a> for LiftVisitor<'a> { let mut lifts = v.lifts_stack.pop().unwrap(); // Get preflight code that references the type of the class so we can qualify the lift, note we use a unique // type alias here since we might not have the actual type name available in scope here. - let code = &v.jsify.unique_class_alias(expr_type); + let code = &v.jsify.class_singleton(expr_type); lifts.lift(m, Some(property), code); v.lifts_stack.push(lifts); return; diff --git a/libs/wingc/src/type_check.rs b/libs/wingc/src/type_check.rs index 700f3537690..4c780b43687 100644 --- a/libs/wingc/src/type_check.rs +++ b/libs/wingc/src/type_check.rs @@ -41,6 +41,7 @@ use std::cmp; use std::collections::{BTreeMap, HashMap, HashSet}; use std::fmt::{Debug, Display}; use std::iter::FilterMap; +use std::sync::atomic::{AtomicUsize, Ordering}; use symbol_env::{StatementIdx, SymbolEnv}; use wingii::fqn::FQN; use wingii::type_system::TypeSystem; @@ -336,7 +337,7 @@ pub struct Class { pub std_construct_args: bool, // Unique identifier for this class type, used to generate a unique type alias for this class se we can - // reference it regardless of type name shadowing. + // reference it regardless of type name shadowing or scoping. pub uid: usize, } impl Class { @@ -1797,12 +1798,12 @@ pub struct TypeChecker<'a> { is_in_mut_json: bool, - /// Class counter, used to generate unique names class types - class_counter: usize, - ctx: VisitContext, } +/// Class counter, used to generate unique names class types +static CLASS_COUNTER: AtomicUsize = AtomicUsize::new(0); + enum ExprVisitInfo { /// The current expression has no special properties NoInfo, @@ -1830,7 +1831,6 @@ impl<'a> TypeChecker<'a> { jsii_imports, is_in_mut_json: false, ctx: VisitContext::new(), - class_counter: 0, } } @@ -4149,9 +4149,8 @@ impl<'a> TypeChecker<'a> { docs: Docs::default(), std_construct_args: ast_class.phase == Phase::Preflight, lifts: None, - uid: self.class_counter, + uid: CLASS_COUNTER.fetch_add(1, Ordering::Relaxed), }; - self.class_counter += 1; let mut class_type = self.types.add_type(Type::Class(class_spec)); match env.define( &ast_class.name, diff --git a/libs/wingsdk/src/std/resource.ts b/libs/wingsdk/src/std/resource.ts index 5df01e17178..47cfea0f806 100644 --- a/libs/wingsdk/src/std/resource.ts +++ b/libs/wingsdk/src/std/resource.ts @@ -139,8 +139,7 @@ export abstract class Resource extends Construct implements IResource { */ public static onLiftType(host: IInflightHost, ops: string[]): void { log( - `onLiftType called on a resource type (${ - this.constructor.name + `onLiftType called on a resource type (${this.constructor.name }) with a host (${host.node.path}) and ops: ${JSON.stringify(ops)}` ); } @@ -199,8 +198,7 @@ export abstract class Resource extends Construct implements IResource { */ public onLift(host: IInflightHost, ops: string[]): void { log( - `onLift called on a resource (${this.node.path}) with a host (${ - host.node.path + `onLift called on a resource (${this.node.path}) with a host (${host.node.path }) and ops: ${JSON.stringify(ops)}` ); @@ -225,6 +223,43 @@ export abstract class Resource extends Construct implements IResource { public _preSynthesize(): void { // do nothing by default } + + + /** + * A singleton instance of this resource. Specifically used for inflight classes defined in preflight code. + * see `singleton` method for more details. + * @internal + */ + //private static _singletonInstance: Resource; + + /** + * Create a singleton of this resource. This uses `this` in a static context + * to create a singleton of any subclass of `Resource`. + * This helper function is used to create a single dummy instance of `inflight class`es + * defined in preflight code. This instances are needed to creaete a lift qualification + * map for such classes. + * + * @internal + */ + public static _singleton(scope: Construct, id: string): Resource { + console.log(`creating singleto for ${id} in ${Node.of(scope).root.node.path}`) + //const root: any = scope.node.root; + const root: any = Node.of(scope).root; + let t: any = this; + if (root.resourceSingletons === undefined) { + root.resourceSingletons = {}; + } + const instance = root.resourceSingletons[t]; + if (instance) { + return instance; + } + root.resourceSingletons[t] = new t(root, id); + return root.resourceSingletons[t]; + // if (!this._singletonInstance) { + // this._singletonInstance = new t(scope.node.root, id); + // } + // return this._singletonInstance; + } } /** From 69deae182755a9edaf1a4b6da86f0aa7533f9612 Mon Sep 17 00:00:00 2001 From: Yoav Steinberg Date: Sat, 8 Jun 2024 15:29:39 +0300 Subject: [PATCH 33/78] cleanup --- libs/wingc/src/jsify.rs | 6 +----- libs/wingc/src/type_check.rs | 2 +- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/libs/wingc/src/jsify.rs b/libs/wingc/src/jsify.rs index 16138c12348..fb4ad4cbd28 100644 --- a/libs/wingc/src/jsify.rs +++ b/libs/wingc/src/jsify.rs @@ -153,11 +153,7 @@ impl<'a> JSifier<'a> { }) { let scope_env = self.types.get_scope_env(&scope); let s = self.jsify_statement(&scope_env, statement, &mut jsify_context); // top level statements are always preflight - if let StmtKind::Bring { - identifier: _, - source: _, - } = statement.kind - { + if matches!(statement.kind, StmtKind::Bring { .. }) { imports.add_code(s); } else { js.add_code(s); diff --git a/libs/wingc/src/type_check.rs b/libs/wingc/src/type_check.rs index 4c780b43687..8784b6c39f0 100644 --- a/libs/wingc/src/type_check.rs +++ b/libs/wingc/src/type_check.rs @@ -336,7 +336,7 @@ pub struct Class { // and instead the user will need to pass the relevant args to the class's init method. pub std_construct_args: bool, - // Unique identifier for this class type, used to generate a unique type alias for this class se we can + // Unique identifier for this class type, used to generate a unique type alias for this class so we can // reference it regardless of type name shadowing or scoping. pub uid: usize, } From 138a4b008009e7557a3627250e4199c0c451c7a3 Mon Sep 17 00:00:00 2001 From: Yoav Steinberg Date: Sat, 8 Jun 2024 15:31:03 +0300 Subject: [PATCH 34/78] wip --- libs/wingsdk/src/std/resource.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libs/wingsdk/src/std/resource.ts b/libs/wingsdk/src/std/resource.ts index 47cfea0f806..f6b5d299900 100644 --- a/libs/wingsdk/src/std/resource.ts +++ b/libs/wingsdk/src/std/resource.ts @@ -242,7 +242,7 @@ export abstract class Resource extends Construct implements IResource { * @internal */ public static _singleton(scope: Construct, id: string): Resource { - console.log(`creating singleto for ${id} in ${Node.of(scope).root.node.path}`) + console.log(`creating singleton for ${id} in ${Node.of(scope).root.node.path}`) //const root: any = scope.node.root; const root: any = Node.of(scope).root; let t: any = this; @@ -251,8 +251,10 @@ export abstract class Resource extends Construct implements IResource { } const instance = root.resourceSingletons[t]; if (instance) { + console.log(`reusing...`); return instance; } + console.log(`creating...`); root.resourceSingletons[t] = new t(root, id); return root.resourceSingletons[t]; // if (!this._singletonInstance) { From 0baf19778705af917c9fa5d01aeae8d79e25e5f7 Mon Sep 17 00:00:00 2001 From: Yoav Steinberg Date: Tue, 11 Jun 2024 22:49:24 +0300 Subject: [PATCH 35/78] wip --- libs/wingc/package.json | 2 +- libs/wingc/scripts/postcompile.sh | 26 +++++++++ libs/wingc/src/jsify.rs | 92 ++++++++++++++++++++----------- libs/wingsdk/src/helpers.ts | 11 ++++ 4 files changed, 98 insertions(+), 33 deletions(-) create mode 100755 libs/wingc/scripts/postcompile.sh diff --git a/libs/wingc/package.json b/libs/wingc/package.json index cad6ae5e78a..0581867cea5 100644 --- a/libs/wingc/package.json +++ b/libs/wingc/package.json @@ -2,7 +2,7 @@ "name": "@winglang/wingc", "private": true, "scripts": { - "compile": "cargo build --target wasm32-wasi --release && ../../.cargo/binaryen-version_116/bin/wasm-opt --enable-bulk-memory --strip-debug --strip-producers -O3 -o wingc.wasm ../../target/wasm32-wasi/release/wingc.wasm", + "compile": "cargo build --target wasm32-wasi --release && ./scripts/postcompile.sh", "dev": "cargo run --example compile --release", "test": "cargo test", "lint": "cargo fmt && cargo clippy --fix --no-deps --allow-dirty --target wasm32-wasi --release" diff --git a/libs/wingc/scripts/postcompile.sh b/libs/wingc/scripts/postcompile.sh new file mode 100755 index 00000000000..5702df3f046 --- /dev/null +++ b/libs/wingc/scripts/postcompile.sh @@ -0,0 +1,26 @@ +#!/usr/bin/env bash + +### +# This script should be run after release build of wingc to the wasm32-wasi target. +# The end result will be a final wasm file in the wingc directory. +# If running in CI (env "CI" is set), it will run wasm-opt on the generated wasm file. +# Otherwise, the wasm file will be copied to the wingc directory from its original output location. +### + +wingc=$(cd $(dirname $0)/.. && pwd) + +# Currently we only do release wasm builds +target="release" + +wasm_opt="$wingc/../../.cargo/binaryen-version_117/bin/wasm-opt" +input_wasm="$wingc/../../target/wasm32-wasi/$target/wingc.wasm" +output_wasm="$wingc/wingc.wasm" + +# If CI env is set, run wasm-opt with extra optimizations +echo "Optimising wasm..." +if [ -n "$CI" ]; then + $wasm_opt --enable-bulk-memory --strip-debug --strip-producers -O3 -o $output_wasm $input_wasm +else + $wasm_opt --enable-bulk-memory --strip-debug --strip-producers -o $output_wasm $input_wasm +fi +echo "Done!" diff --git a/libs/wingc/src/jsify.rs b/libs/wingc/src/jsify.rs index fb4ad4cbd28..f7a790076fa 100644 --- a/libs/wingc/src/jsify.rs +++ b/libs/wingc/src/jsify.rs @@ -59,6 +59,7 @@ const SUPER_CLASS_INFLIGHT_INIT_NAME: &str = formatcp!("super_{CLASS_INFLIGHT_IN //const PREFLIGHT_TYPES_MAP: &str = "globalThis.$preflightTypesMap"; //const PREFLIGHT_TYPES_MAP: &str = "this.node.root.$preflightTypesMap"; const PREFLIGHT_TYPES_MAP: &str = "$helpers.nodeof(this).root.$preflightTypesMap"; +const MODULE_PREFLIGHT_TYPES_MAP: &str = "$preflightTypesMap"; pub struct JSifyContext<'a> { pub lifts: Option<&'a Lifts>, @@ -186,6 +187,10 @@ impl<'a> JSifier<'a> { output.line(format!("const std = {STDLIB}.{WINGSDK_STD_MODULE};")); output.line(format!("const {HELPERS_VAR} = {STDLIB}.helpers;")); + // A single preflight types map per file, all preflight types defined in this file and imported from other files + // go into this map. + output.line(format!("let {MODULE_PREFLIGHT_TYPES_MAP} = {{}};")); + output.add_code(imports); if is_entrypoint { @@ -195,8 +200,8 @@ impl<'a> JSifier<'a> { root_class.line("super($scope, $id);"); root_class.add_code(self.jsify_struct_schemas()); - // Create global map of preflight class types - root_class.line(format!("{PREFLIGHT_TYPES_MAP} = {{}};")); + // Create global map of preflight class types and add all preflight types to it + root_class.line(format!("{PREFLIGHT_TYPES_MAP} = {MODULE_PREFLIGHT_TYPES_MAP};")); root_class.add_code(js); root_class.close("}"); @@ -227,25 +232,53 @@ impl<'a> JSifier<'a> { // ...require("./preflight.inner-file2.js"), // }; // ``` - output.open("module.exports = {"); + // output.open("module.exports = {"); + // for file in directory_children { + // let preflight_file_name = preflight_file_map.get(file).expect("no emitted JS file found"); + // if file.is_dir() { + // let directory_name = file.file_stem().unwrap(); + // output.line(format!( + // "get {directory_name}() {{ return require(\"./{preflight_file_name}\") }}," + // )); + // } else { + // output.line(format!("...require(\"./{preflight_file_name}\"),")); + // } + // } + // output.close("};"); + + // supposing a directory has a files and a subdirectory in it, + // we generate code like this: + // ``` + // let $brought; + // $brought = $helpers.bringJs("./preflight.inner-file1.js", "$preflightTypesMap", $preflightTypesMap); + // module.exports = { ...module.export, ...$brought }; + // $brought = $helpers.bringJs("./preflight.inner-directory1.js", "$preflightTypesMap", $preflightTypesMap); + // module.exports = { ...module.export, get inner_directory1() { return $brought; } }; + // ``` + + output.line("let $brought;"); for file in directory_children { let preflight_file_name = preflight_file_map.get(file).expect("no emitted JS file found"); if file.is_dir() { let directory_name = file.file_stem().unwrap(); + output.line(format!("$brought = $helpers.bringJs(`${{__dirname}}/{preflight_file_name}`, \"{MODULE_PREFLIGHT_TYPES_MAP}\", {MODULE_PREFLIGHT_TYPES_MAP});")); output.line(format!( - "get {directory_name}() {{ return require(\"./{preflight_file_name}\") }}," + "module.exports = {{ ...module.exports, get {directory_name}() {{ return $brought; }} }};" )); } else { - output.line(format!("...require(\"./{preflight_file_name}\"),")); + output.line(format!("$brought = $helpers.bringJs(`${{__dirname}}/{preflight_file_name}`, \"{MODULE_PREFLIGHT_TYPES_MAP}\", {MODULE_PREFLIGHT_TYPES_MAP});")); + output.line("module.exports = { ...module.exports, ...$brought };"); } } - output.close("};"); + output.line(format!( + "module.exports = {{ ...module.exports, {MODULE_PREFLIGHT_TYPES_MAP} }};" + )); } else { output.add_code(self.jsify_struct_schemas()); output.add_code(js); let exports = get_public_symbols(&scope); output.line(format!( - "module.exports = {{ {} }};", + "module.exports = {{ {}, {MODULE_PREFLIGHT_TYPES_MAP} }};", exports.iter().map(ToString::to_string).join(", ") )); } @@ -916,25 +949,10 @@ impl<'a> JSifier<'a> { code.line(format!("const {var_name} = require(\"{name}\");")) } BringSource::WingLibrary(_, module_dir) => { - // checked during type checking - let var_name = identifier.as_ref().expect("bring wing library requires an alias"); - let preflight_file_map = self.preflight_file_map.borrow(); - let preflight_file_name = preflight_file_map.get(module_dir).unwrap(); - code.line(format!("const {var_name} = require(\"./{preflight_file_name}\");")) + code.append(self.jsify_bring_stmt(module_dir, identifier)); } - BringSource::WingFile(name) => { - // checked during type checking - let var_name = identifier.as_ref().expect("bring wing file requires an alias"); - let preflight_file_map = self.preflight_file_map.borrow(); - let preflight_file_name = preflight_file_map.get(Utf8Path::new(&name.name)).unwrap(); - code.line(format!("const {var_name} = require(\"./{preflight_file_name}\");")) - } - BringSource::Directory(name) => { - // checked during type checking - let preflight_file_map = self.preflight_file_map.borrow(); - let preflight_file_name = preflight_file_map.get(Utf8Path::new(&name.name)).unwrap(); - let var_name = identifier.as_ref().expect("bring wing directory requires an alias"); - code.line(format!("const {var_name} = require(\"./{preflight_file_name}\");")) + BringSource::Directory(name) | BringSource::WingFile(name) => { + code.append(self.jsify_bring_stmt(Utf8Path::new(&name.name), identifier)); } }, StmtKind::SuperConstructor { arg_list } => { @@ -1207,6 +1225,20 @@ impl<'a> JSifier<'a> { code } + fn jsify_bring_stmt(&self, path: &Utf8Path, identifier: &Option) -> CodeMaker { + let mut code = CodeMaker::default(); + // checked during type checking + let var_name = identifier.as_ref().expect("bring wing module requires an alias"); + let preflight_file_map = self.preflight_file_map.borrow(); + let preflight_file_name = preflight_file_map.get(path).unwrap(); + code.line(format!("const {var_name} = require(\"./{preflight_file_name}\");")); + // Add brought preflight types to this module's preflight types + code.line(format!( + "Object.assign({MODULE_PREFLIGHT_TYPES_MAP}, {var_name}.{MODULE_PREFLIGHT_TYPES_MAP});" + )); + code + } + fn jsify_enum(&self, name: &Symbol, values: &IndexSet) -> CodeMaker { let mut code = CodeMaker::with_source(&name.span); let mut value_index = 0; @@ -1538,19 +1570,15 @@ impl<'a> JSifier<'a> { // class types in a global preflight types map indexed by the class's unique id. if class.phase == Phase::Inflight { code.line(format!( - "if ({PREFLIGHT_TYPES_MAP}[{}]) {{ throw new Error(\"{} is already in type map\"); }}", + "if ({MODULE_PREFLIGHT_TYPES_MAP}[{}]) {{ throw new Error(\"{} is already in type map\"); }}", class_type.as_class().unwrap().uid, class.name )); code.line(format!( - "{PREFLIGHT_TYPES_MAP}[{}] = {};", + "{MODULE_PREFLIGHT_TYPES_MAP}[{}] = {};", class_type.as_class().unwrap().uid, class.name )); - code.line(format!( - "console.log(`Adding {} to ${{$helpers.nodeof(this).root.node.id}}`);", - class.name - )); } code @@ -1560,7 +1588,7 @@ impl<'a> JSifier<'a> { pub fn class_singleton(&self, type_: TypeRef) -> String { let c = type_.as_class().unwrap(); format!( - "{PREFLIGHT_TYPES_MAP}[{}]._singleton(this,\"{}_singleton_{}\")", + "{MODULE_PREFLIGHT_TYPES_MAP}[{}]._singleton(this,\"{}_singleton_{}\")", c.uid, c.name, c.uid ) } diff --git a/libs/wingsdk/src/helpers.ts b/libs/wingsdk/src/helpers.ts index a565c8d369e..38b27b0960f 100644 --- a/libs/wingsdk/src/helpers.ts +++ b/libs/wingsdk/src/helpers.ts @@ -52,3 +52,14 @@ export function unwrap(value: T): T | never { } throw new Error("Unexpected nil"); } + +export function bringJs(moduleFile: string, preflightTypesObjectName: string, outPreflightTypesObject: Object): Object { + return Object.fromEntries(Object.entries(require(moduleFile)).filter(([k, v]) => { + // If this is the preflight types array then update the input object and skip it + if (k === preflightTypesObjectName) { + Object.assign(outPreflightTypesObject, v); + return false; + } + return true; + })); +} From e498b9edbfde8cbabaf373232478d7865ab54075 Mon Sep 17 00:00:00 2001 From: Yoav Steinberg Date: Wed, 12 Jun 2024 11:28:02 +0300 Subject: [PATCH 36/78] wip --- libs/wingc/src/jsify.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libs/wingc/src/jsify.rs b/libs/wingc/src/jsify.rs index f7a790076fa..d6f4a4574be 100644 --- a/libs/wingc/src/jsify.rs +++ b/libs/wingc/src/jsify.rs @@ -201,7 +201,9 @@ impl<'a> JSifier<'a> { root_class.add_code(self.jsify_struct_schemas()); // Create global map of preflight class types and add all preflight types to it - root_class.line(format!("{PREFLIGHT_TYPES_MAP} = {MODULE_PREFLIGHT_TYPES_MAP};")); + root_class.line(format!( + "{PREFLIGHT_TYPES_MAP} = {{ ...{MODULE_PREFLIGHT_TYPES_MAP} }};" + )); root_class.add_code(js); root_class.close("}"); @@ -278,7 +280,7 @@ impl<'a> JSifier<'a> { output.add_code(js); let exports = get_public_symbols(&scope); output.line(format!( - "module.exports = {{ {}, {MODULE_PREFLIGHT_TYPES_MAP} }};", + "module.exports = {{ {MODULE_PREFLIGHT_TYPES_MAP}, {} }};", exports.iter().map(ToString::to_string).join(", ") )); } From 0e48d9a60ee51f2878879f4fab62d5627d682ae6 Mon Sep 17 00:00:00 2001 From: Yoav Steinberg Date: Wed, 12 Jun 2024 22:56:49 +0300 Subject: [PATCH 37/78] modules are imported into root ctor --- libs/wingc/src/jsify.rs | 44 ++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 22 deletions(-) diff --git a/libs/wingc/src/jsify.rs b/libs/wingc/src/jsify.rs index d6f4a4574be..5bd1ea75fdb 100644 --- a/libs/wingc/src/jsify.rs +++ b/libs/wingc/src/jsify.rs @@ -187,23 +187,21 @@ impl<'a> JSifier<'a> { output.line(format!("const std = {STDLIB}.{WINGSDK_STD_MODULE};")); output.line(format!("const {HELPERS_VAR} = {STDLIB}.helpers;")); - // A single preflight types map per file, all preflight types defined in this file and imported from other files - // go into this map. - output.line(format!("let {MODULE_PREFLIGHT_TYPES_MAP} = {{}};")); - - output.add_code(imports); - if is_entrypoint { let mut root_class = CodeMaker::default(); root_class.open(format!("class {} extends {} {{", ROOT_CLASS, STDLIB_CORE_RESOURCE)); root_class.open(format!("{JS_CONSTRUCTOR}($scope, $id) {{")); root_class.line("super($scope, $id);"); + root_class.line(format!("{PREFLIGHT_TYPES_MAP} = {{ }};")); + + // The root preflight types map + root_class.line(format!("let {MODULE_PREFLIGHT_TYPES_MAP} = {{}};")); + + root_class.add_code(imports); root_class.add_code(self.jsify_struct_schemas()); - // Create global map of preflight class types and add all preflight types to it - root_class.line(format!( - "{PREFLIGHT_TYPES_MAP} = {{ ...{MODULE_PREFLIGHT_TYPES_MAP} }};" - )); + // A global map pointing to the root preflight types map + root_class.line(format!("{PREFLIGHT_TYPES_MAP} = {MODULE_PREFLIGHT_TYPES_MAP};")); root_class.add_code(js); root_class.close("}"); @@ -258,24 +256,29 @@ impl<'a> JSifier<'a> { // module.exports = { ...module.export, get inner_directory1() { return $brought; } }; // ``` - output.line("let $brought;"); + // This module's preflight type map + output.line(format!("let {MODULE_PREFLIGHT_TYPES_MAP} = {{}};")); + for file in directory_children { let preflight_file_name = preflight_file_map.get(file).expect("no emitted JS file found"); if file.is_dir() { let directory_name = file.file_stem().unwrap(); - output.line(format!("$brought = $helpers.bringJs(`${{__dirname}}/{preflight_file_name}`, \"{MODULE_PREFLIGHT_TYPES_MAP}\", {MODULE_PREFLIGHT_TYPES_MAP});")); output.line(format!( - "module.exports = {{ ...module.exports, get {directory_name}() {{ return $brought; }} }};" + "Object.assign(module.exports, {{ get {directory_name}() {{ return $helpers.bringJs(`${{__dirname}}/{preflight_file_name}`, \"{MODULE_PREFLIGHT_TYPES_MAP}\", {MODULE_PREFLIGHT_TYPES_MAP}); }} }});" )); } else { - output.line(format!("$brought = $helpers.bringJs(`${{__dirname}}/{preflight_file_name}`, \"{MODULE_PREFLIGHT_TYPES_MAP}\", {MODULE_PREFLIGHT_TYPES_MAP});")); - output.line("module.exports = { ...module.exports, ...$brought };"); + output.line(format!( + "Object.assign(module.exports, $helpers.bringJs(`${{__dirname}}/{preflight_file_name}`, \"{MODULE_PREFLIGHT_TYPES_MAP}\", {MODULE_PREFLIGHT_TYPES_MAP}));" + )); } } output.line(format!( "module.exports = {{ ...module.exports, {MODULE_PREFLIGHT_TYPES_MAP} }};" )); } else { + // This module's preflight type map + output.line(format!("let {MODULE_PREFLIGHT_TYPES_MAP} = {{}};")); + output.add_code(imports); output.add_code(self.jsify_struct_schemas()); output.add_code(js); let exports = get_public_symbols(&scope); @@ -940,10 +943,7 @@ impl<'a> JSifier<'a> { code.line(format!("const {var_name} = {STDLIB}.{name};")) } BringSource::TrustedModule(name, module_dir) => { - let preflight_file_map = self.preflight_file_map.borrow(); - let preflight_file_name = preflight_file_map.get(module_dir).unwrap(); - let var_name = identifier.as_ref().unwrap_or(&name); - code.line(format!("const {var_name} = require(\"./{preflight_file_name}\");")) + code.append(self.jsify_bring_stmt(module_dir, &Some(identifier.as_ref().unwrap_or(name).clone()))); } BringSource::JsiiModule(name) => { // checked during type checking @@ -1567,8 +1567,8 @@ impl<'a> JSifier<'a> { // )); // } - // Inflight classes might need to be lift-qualified (onLift), but their type name might not be necessarily avaialble - // at the scope when they are qualified (it might even be shadowed by another type name). We atore a reference to these + // Inflight classes might need to be lift-qualified (onLift), but their type name might not be necessarily available + // at the scope when they are qualified (it might even be shadowed by another type name). We store a reference to these // class types in a global preflight types map indexed by the class's unique id. if class.phase == Phase::Inflight { code.line(format!( @@ -1590,7 +1590,7 @@ impl<'a> JSifier<'a> { pub fn class_singleton(&self, type_: TypeRef) -> String { let c = type_.as_class().unwrap(); format!( - "{MODULE_PREFLIGHT_TYPES_MAP}[{}]._singleton(this,\"{}_singleton_{}\")", + "{PREFLIGHT_TYPES_MAP}[{}]._singleton(this,\"{}_singleton_{}\")", c.uid, c.name, c.uid ) } From 0032c4ac086a408bb87ed9526ba52a54f491d99c Mon Sep 17 00:00:00 2001 From: Yoav Steinberg Date: Wed, 12 Jun 2024 23:01:51 +0300 Subject: [PATCH 38/78] cleanup --- libs/wingsdk/src/std/resource.ts | 8 -------- 1 file changed, 8 deletions(-) diff --git a/libs/wingsdk/src/std/resource.ts b/libs/wingsdk/src/std/resource.ts index f6b5d299900..48ff9e90012 100644 --- a/libs/wingsdk/src/std/resource.ts +++ b/libs/wingsdk/src/std/resource.ts @@ -242,8 +242,6 @@ export abstract class Resource extends Construct implements IResource { * @internal */ public static _singleton(scope: Construct, id: string): Resource { - console.log(`creating singleton for ${id} in ${Node.of(scope).root.node.path}`) - //const root: any = scope.node.root; const root: any = Node.of(scope).root; let t: any = this; if (root.resourceSingletons === undefined) { @@ -251,16 +249,10 @@ export abstract class Resource extends Construct implements IResource { } const instance = root.resourceSingletons[t]; if (instance) { - console.log(`reusing...`); return instance; } - console.log(`creating...`); root.resourceSingletons[t] = new t(root, id); return root.resourceSingletons[t]; - // if (!this._singletonInstance) { - // this._singletonInstance = new t(scope.node.root, id); - // } - // return this._singletonInstance; } } From 7db93843bdb16bd0a8320c237fbedb07d487c397 Mon Sep 17 00:00:00 2001 From: Yoav Steinberg Date: Thu, 13 Jun 2024 12:40:56 +0300 Subject: [PATCH 39/78] fixes after merge --- libs/wingc/src/lifting.rs | 7 +++-- libs/wingc/src/type_check.rs | 48 ++++++++++++++++----------------- libs/wingc/src/visit_context.rs | 2 +- 3 files changed, 28 insertions(+), 29 deletions(-) diff --git a/libs/wingc/src/lifting.rs b/libs/wingc/src/lifting.rs index 0b49d5aea76..adf1977adec 100644 --- a/libs/wingc/src/lifting.rs +++ b/libs/wingc/src/lifting.rs @@ -290,7 +290,6 @@ impl<'a> Visit<'a> for LiftVisitor<'a> { // } // } - // Before we continue lets dive into this (non-preflight) expression to see if we need to lift any parts of it visit::visit_expr(v, node); @@ -298,13 +297,13 @@ impl<'a> Visit<'a> for LiftVisitor<'a> { if expr_phase == Phase::Inflight { if let Some(class) = expr_type.as_class() { if class.phase == Phase::Inflight && class.defined_in_phase == Phase::Preflight { - if let Some(property) = v.ctx.current_property() { - let m = v.ctx.current_method().map(|(m,_)|m).expect("a method"); + if let Some((_, property)) = v.ctx.current_property() { + let m = v.ctx.current_method().map(|(m, _)| m).expect("a method"); let mut lifts = v.lifts_stack.pop().unwrap(); // Get preflight code that references the type of the class so we can qualify the lift, note we use a unique // type alias here since we might not have the actual type name available in scope here. let code = &v.jsify.class_singleton(expr_type); - lifts.lift(m, Some(property), code); + lifts.lift(m, Some(property.to_string()), code); v.lifts_stack.push(lifts); return; } diff --git a/libs/wingc/src/type_check.rs b/libs/wingc/src/type_check.rs index 3cb819b964e..fb2bbdcdbca 100644 --- a/libs/wingc/src/type_check.rs +++ b/libs/wingc/src/type_check.rs @@ -1248,7 +1248,7 @@ impl TypeRef { Type::MutArray(t) => t.is_serializable(), Type::Map(t) => t.is_serializable(), Type::MutMap(t) => t.is_serializable(), - Type::Struct(s) => s.fields(true).map(|(_, t)| t).all(|t| t.is_serializable()), + Type::Struct(s) => s.fields(true).map(|(_, v)| v.type_).all(|t| t.is_serializable()), Type::Enum(_) => true, // not serializable Type::Duration => false, @@ -2273,29 +2273,29 @@ new cloud.Function(@inflight("./handler.ts"), lifts: { bucket: ["put"] }); op: &BinaryOperator, exp: &Expr, ) -> (TypeRef, Phase) { - let (ltype, ltype_phase) = self.type_check_exp(left, env); - let (rtype, rtype_phase) = self.type_check_exp(right, env); + let (ltype, ltype_phase) = self.type_check_exp(left, env); + let (rtype, rtype_phase) = self.type_check_exp(right, env); - // Resolve the phase - let phase = combine_phases(ltype_phase, rtype_phase); + // Resolve the phase + let phase = combine_phases(ltype_phase, rtype_phase); - match op { - BinaryOperator::LogicalAnd | BinaryOperator::LogicalOr => { - self.validate_type(ltype, self.types.bool(), left); - self.validate_type(rtype, self.types.bool(), right); - (self.types.bool(), phase) - } - BinaryOperator::AddOrConcat => { - if ltype.is_subtype_of(&self.types.number()) && rtype.is_subtype_of(&self.types.number()) { - (self.types.number(), phase) - } else if ltype.is_subtype_of(&self.types.string()) && rtype.is_subtype_of(&self.types.string()) { - (self.types.string(), phase) - } else { - // If any of the types are unresolved (error) then don't report this assuming the error has already been reported - if !ltype.is_unresolved() && !rtype.is_unresolved() { - self.spanned_error( - exp, - format!( + match op { + BinaryOperator::LogicalAnd | BinaryOperator::LogicalOr => { + self.validate_type(ltype, self.types.bool(), left); + self.validate_type(rtype, self.types.bool(), right); + (self.types.bool(), phase) + } + BinaryOperator::AddOrConcat => { + if ltype.is_subtype_of(&self.types.number()) && rtype.is_subtype_of(&self.types.number()) { + (self.types.number(), phase) + } else if ltype.is_subtype_of(&self.types.string()) && rtype.is_subtype_of(&self.types.string()) { + (self.types.string(), phase) + } else { + // If any of the types are unresolved (error) then don't report this assuming the error has already been reported + if !ltype.is_unresolved() && !rtype.is_unresolved() { + self.spanned_error( + exp, + format!( "Binary operator '+' cannot be applied to operands of type '{}' and '{}'; only ({}, {}) and ({}, {}) are supported", ltype, rtype, @@ -2304,7 +2304,7 @@ new cloud.Function(@inflight("./handler.ts"), lifts: { bucket: ["put"] }); self.types.string(), self.types.string(), ), - ); + ); } self.resolved_error() } @@ -3046,7 +3046,7 @@ new cloud.Function(@inflight("./handler.ts"), lifts: { bucket: ["put"] }); pub fn all_optional_struct(t: TypeRef) -> bool { match &*t { - Type::Struct(s) => s.fields(true).all(|(_, t)| t.is_option()), + Type::Struct(s) => s.fields(true).all(|(_, v)| v.type_.is_option()), _ => false, } } diff --git a/libs/wingc/src/visit_context.rs b/libs/wingc/src/visit_context.rs index 18700d8f094..f2850b9424e 100644 --- a/libs/wingc/src/visit_context.rs +++ b/libs/wingc/src/visit_context.rs @@ -1,7 +1,7 @@ use itertools::Itertools; use crate::{ - ast::{Class, ExprId, FunctionSignature, Phase, Stmt, StmtKind, Symbol, UserDefinedType}, + ast::{Class, Expr, ExprId, FunctionSignature, Phase, Stmt, StmtKind, Symbol, UserDefinedType}, type_check::symbol_env::SymbolEnvRef, }; From a3f45921778350733e03b1a2f61ea3cc1bf24639 Mon Sep 17 00:00:00 2001 From: Yoav Steinberg Date: Thu, 13 Jun 2024 12:55:06 +0300 Subject: [PATCH 40/78] more fixes after merge --- libs/wingc/src/lifting.rs | 2 +- libs/wingsdk/src/std/resource.ts | 64 ++++++++++++++------------------ 2 files changed, 29 insertions(+), 37 deletions(-) diff --git a/libs/wingc/src/lifting.rs b/libs/wingc/src/lifting.rs index adf1977adec..7f41d530dc7 100644 --- a/libs/wingc/src/lifting.rs +++ b/libs/wingc/src/lifting.rs @@ -303,7 +303,7 @@ impl<'a> Visit<'a> for LiftVisitor<'a> { // Get preflight code that references the type of the class so we can qualify the lift, note we use a unique // type alias here since we might not have the actual type name available in scope here. let code = &v.jsify.class_singleton(expr_type); - lifts.lift(m, Some(property.to_string()), code); + lifts.lift(m, Some(v.jsify_symbol_to_op_array(&property)), code); v.lifts_stack.push(lifts); return; } diff --git a/libs/wingsdk/src/std/resource.ts b/libs/wingsdk/src/std/resource.ts index b740610040d..75691c2404a 100644 --- a/libs/wingsdk/src/std/resource.ts +++ b/libs/wingsdk/src/std/resource.ts @@ -211,6 +211,29 @@ export abstract class Resource extends Construct implements IResource { addConnectionsFromLiftMap(this, this._liftMap); } } + + /** + * Create a singleton of this resource. This uses `this` in a static context + * to create a singleton of any subclass of `Resource`. + * This helper function is used to create a single dummy instance of `inflight class`es + * defined in preflight code. This instances are needed to create a lift qualification + * map for such classes. + * + * @internal + */ + public static _singleton(scope: Construct, id: string): Resource { + const root: any = Node.of(scope).root; + let t: any = this; + if (root.resourceSingletons === undefined) { + root.resourceSingletons = {}; + } + const instance = root.resourceSingletons[t]; + if (instance) { + return instance; + } + root.resourceSingletons[t] = new t(root, id); + return root.resourceSingletons[t]; + } } function addConnectionsFromLiftMap( @@ -237,45 +260,14 @@ function addConnectionsFromLiftMap( } } } - - - /** - * A singleton instance of this resource. Specifically used for inflight classes defined in preflight code. - * see `singleton` method for more details. - * @internal - */ - //private static _singletonInstance: Resource; - - /** - * Create a singleton of this resource. This uses `this` in a static context - * to create a singleton of any subclass of `Resource`. - * This helper function is used to create a single dummy instance of `inflight class`es - * defined in preflight code. This instances are needed to creaete a lift qualification - * map for such classes. - * - * @internal - */ - public static _singleton(scope: Construct, id: string): Resource { - const root: any = Node.of(scope).root; - let t: any = this; - if (root.resourceSingletons === undefined) { - root.resourceSingletons = {}; - } - const instance = root.resourceSingletons[t]; - if (instance) { - return instance; - } - root.resourceSingletons[t] = new t(root, id); - return root.resourceSingletons[t]; - } } /** - * A resource that has an automatically generated id. - * Used by the Wing compiler to generate unique ids for auto generated resources - * from inflight function closures. - * @noinflight - */ +* A resource that has an automatically generated id. +* Used by the Wing compiler to generate unique ids for auto generated resources +* from inflight function closures. +* @noinflight +*/ export abstract class AutoIdResource extends Resource { constructor(scope: Construct, idPrefix: string = "") { const id = App.of(scope).makeId(scope, idPrefix ? `${idPrefix}_` : ""); From 5729cb5173b977f15aa9d99d7608d0e74ee9e2ef Mon Sep 17 00:00:00 2001 From: Yoav Steinberg Date: Thu, 13 Jun 2024 13:01:36 +0300 Subject: [PATCH 41/78] lint --- libs/wingsdk/src/std/resource.ts | 46 ++++++++++++++++---------------- 1 file changed, 23 insertions(+), 23 deletions(-) diff --git a/libs/wingsdk/src/std/resource.ts b/libs/wingsdk/src/std/resource.ts index 75691c2404a..ce7431261af 100644 --- a/libs/wingsdk/src/std/resource.ts +++ b/libs/wingsdk/src/std/resource.ts @@ -148,6 +148,29 @@ export abstract class Resource extends Construct implements IResource { return obj._toInflight(); } + /** + * Create a singleton of this resource. This uses `this` in a static context + * to create a singleton of any subclass of `Resource`. + * This helper function is used to create a single dummy instance of `inflight class`es + * defined in preflight code. This instances are needed to create a lift qualification + * map for such classes. + * + * @internal + */ + public static _singleton(scope: Construct, id: string): Resource { + const root: any = Node.of(scope).root; + let t: any = this; + if (root.resourceSingletons === undefined) { + root.resourceSingletons = {}; + } + const instance = root.resourceSingletons[t]; + if (instance) { + return instance; + } + root.resourceSingletons[t] = new t(root, id); + return root.resourceSingletons[t]; + } + /** * Create an instance of this resource with the current App factory. * This is commonly used in the constructor of a pseudo-abstract resource class before the super() call. @@ -211,29 +234,6 @@ export abstract class Resource extends Construct implements IResource { addConnectionsFromLiftMap(this, this._liftMap); } } - - /** - * Create a singleton of this resource. This uses `this` in a static context - * to create a singleton of any subclass of `Resource`. - * This helper function is used to create a single dummy instance of `inflight class`es - * defined in preflight code. This instances are needed to create a lift qualification - * map for such classes. - * - * @internal - */ - public static _singleton(scope: Construct, id: string): Resource { - const root: any = Node.of(scope).root; - let t: any = this; - if (root.resourceSingletons === undefined) { - root.resourceSingletons = {}; - } - const instance = root.resourceSingletons[t]; - if (instance) { - return instance; - } - root.resourceSingletons[t] = new t(root, id); - return root.resourceSingletons[t]; - } } function addConnectionsFromLiftMap( From f3f0f101f051cee4bc75c96c0cbc0c83ad7fe8fe Mon Sep 17 00:00:00 2001 From: "monada-bot[bot]" Date: Thu, 13 Jun 2024 10:14:22 +0000 Subject: [PATCH 42/78] chore: self mutation (e2e-1of2.diff) Signed-off-by: monada-bot[bot] --- .../api_valid_path.test.w_compile_tf-aws.md | 7 +- .../valid/assert.test.w_compile_tf-aws.md | 3 + ...wait_in_functions.test.w_compile_tf-aws.md | 5 +- .../bring_awscdk.test.w_compile_tf-aws.md | 5 +- .../bring_cdk8s.test.w_compile_tf-aws.md | 7 +- .../bring_cdktf.test.w_compile_tf-aws.md | 7 +- .../valid/bring_jsii.test.w_compile_tf-aws.md | 9 ++- .../bypass_return.test.w_compile_tf-aws.md | 3 + ..._static_of_myself.test.w_compile_tf-aws.md | 10 ++- .../capture_mutables.test.w_compile_tf-aws.md | 3 + ...apture_primitives.test.w_compile_tf-aws.md | 5 +- ...resource_and_data.test.w_compile_tf-aws.md | 5 +- .../construct-base.test.w_compile_tf-aws.md | 9 ++- .../container_types.test.w_compile_tf-aws.md | 5 +- .../custom_obj_id.test.w_compile_tf-aws.md | 3 + .../valid/debug_env.test.w_compile_tf-aws.md | 5 +- .../double_reference.test.w_compile_tf-aws.md | 5 +- .../valid/doubler.test.w_compile_tf-aws.md | 5 +- ..._binary_operators.test.w_compile_tf-aws.md | 3 + ...ing_interpolation.test.w_compile_tf-aws.md | 7 +- ...rn_implementation.test.w_compile_tf-aws.md | 5 +- .../file_counter.test.w_compile_tf-aws.md | 5 +- .../function_type.test.w_compile_tf-aws.md | 3 + .../valid/hello.test.w_compile_tf-aws.md | 5 +- .../impl_interface.test.w_compile_tf-aws.md | 9 ++- .../valid/indexing.test.w_compile_tf-aws.md | 7 +- ...light-subscribers.test.w_compile_tf-aws.md | 5 +- ...as_struct_members.test.w_compile_tf-aws.md | 10 ++- ..._preflight_object.test.w_compile_tf-aws.md | 81 ++++++++++--------- ...apture_preflight_object.test.w_test_sim.md | 9 +-- ...r_capture_mutable.test.w_compile_tf-aws.md | 5 +- ...re_as_super_param.test.w_compile_tf-aws.md | 3 + ...ht_closure_autoid.test.w_compile_tf-aws.md | 3 + .../inflight_concat.test.w_compile_tf-aws.md | 5 +- .../inflight_init.test.w_compile_tf-aws.md | 19 +++-- ...erit_stdlib_class.test.w_compile_tf-aws.md | 7 +- ...ce_class_inflight.test.w_compile_tf-aws.md | 9 +-- ...e_class_preflight.test.w_compile_tf-aws.md | 5 +- ...ritance_interface.test.w_compile_tf-aws.md | 5 +- .../valid/intrinsics.test.w_compile_tf-aws.md | 17 ++-- .../valid/issue_2889.test.w_compile_tf-aws.md | 9 ++- .../valid/json.test.w_compile_tf-aws.md | 5 +- ...ft_expr_with_this.test.w_compile_tf-aws.md | 3 + ...ift_parent_fields.test.w_compile_tf-aws.md | 3 + ...lift_redefinition.test.w_compile_tf-aws.md | 3 + ...t_shared_resource.test.w_compile_tf-aws.md | 7 +- ..._closure_explicit.test.w_compile_tf-aws.md | 5 +- .../lift_weird_order.test.w_compile_tf-aws.md | 3 + ...ft_with_phase_ind.test.w_compile_tf-aws.md | 18 ++--- .../map_entries.test.w_compile_tf-aws.md | 3 + ...t_container_types.test.w_compile_tf-aws.md | 5 +- ..._after_class_init.test.w_compile_tf-aws.md | 7 +- .../new_in_static_lib.w_compile_tf-aws.md | 3 +- .../valid/on_lift.test.w_compile_tf-aws.md | 5 +- .../valid/optionals.test.w_compile_tf-aws.md | 5 +- .../parameters.test.w_compile_tf-aws.md | 3 + ..._method_on_string.test.w_compile_tf-aws.md | 9 ++- ...primitive_methods.test.w_compile_tf-aws.md | 3 + .../valid/print.test.w_compile_tf-aws.md | 5 +- .../reassignment.test.w_compile_tf-aws.md | 3 + .../valid/redis.test.w_compile_tf-aws.md | 9 ++- .../valid/resource.test.w_compile_tf-aws.md | 9 ++- ..._inflight_literal.test.w_compile_tf-aws.md | 5 +- ...ource_call_static.test.w_compile_tf-aws.md | 5 +- .../valid/service.test.w_compile_tf-aws.md | 3 + .../sim_resource.test.w_compile_tf-aws.md | 9 ++- ...able_declarations.test.w_compile_tf-aws.md | 3 + .../static_members.test.w_compile_tf-aws.md | 5 +- .../std_containers.test.w_compile_tf-aws.md | 3 + .../valid/std_string.test.w_compile_tf-aws.md | 3 + .../valid/store.w_compile_tf-aws.md | 7 +- .../struct_from_json.test.w_compile_tf-aws.md | 25 +++--- .../valid/structs.test.w_compile_tf-aws.md | 5 +- .../valid/table.test.w_compile_tf-aws.md | 5 +- ...est_without_bring.test.w_compile_tf-aws.md | 3 + .../valid/this.test.w_compile_tf-aws.md | 5 +- .../valid/try_catch.test.w_compile_tf-aws.md | 3 + .../unused_lift.test.w_compile_tf-aws.md | 5 +- ...side_init_closure.test.w_compile_tf-aws.md | 5 +- .../while_loop_await.test.w_compile_tf-aws.md | 5 +- 80 files changed, 392 insertions(+), 165 deletions(-) diff --git a/tools/hangar/__snapshots__/test_corpus/valid/api_valid_path.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/api_valid_path.test.w_compile_tf-aws.md index 712527ac8e7..6d0cefb4dfd 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/api_valid_path.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/api_valid_path.test.w_compile_tf-aws.md @@ -551,11 +551,14 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; -const expect = $stdlib.expect; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + const expect = $stdlib.expect; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/assert.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/assert.test.w_compile_tf-aws.md index a8b74bcff60..0bf30e96224 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/assert.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/assert.test.w_compile_tf-aws.md @@ -66,6 +66,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/asynchronous_model_implicit_await_in_functions.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/asynchronous_model_implicit_await_in_functions.test.w_compile_tf-aws.md index e0374f97b56..9a42d2ce993 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/asynchronous_model_implicit_await_in_functions.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/asynchronous_model_implicit_await_in_functions.test.w_compile_tf-aws.md @@ -270,10 +270,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/bring_awscdk.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/bring_awscdk.test.w_compile_tf-aws.md index 6d00372de57..34967d4c7ed 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/bring_awscdk.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/bring_awscdk.test.w_compile_tf-aws.md @@ -43,10 +43,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cdk = require("aws-cdk-lib"); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cdk = require("aws-cdk-lib"); + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class CdkDockerImageFunction extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/bring_cdk8s.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/bring_cdk8s.test.w_compile_tf-aws.md index fb60c5bbf3e..f1ec194c0a5 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/bring_cdk8s.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/bring_cdk8s.test.w_compile_tf-aws.md @@ -29,11 +29,14 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cdk8s = require("cdk8s"); -const kplus = require("cdk8s-plus-27"); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cdk8s = require("cdk8s"); + const kplus = require("cdk8s-plus-27"); + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; const app = this.node.root.new("cdk8s.App", cdk8s.App, ); const chart = this.node.root.new("cdk8s.Chart", cdk8s.Chart, this, "Chart"); const deploy = ($scope => $scope.node.root.new("cdk8s-plus-27.Deployment", kplus.Deployment, $scope, "Deployment"))(chart); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/bring_cdktf.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/bring_cdktf.test.w_compile_tf-aws.md index 313b72c26fe..4d9372a3feb 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/bring_cdktf.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/bring_cdktf.test.w_compile_tf-aws.md @@ -60,11 +60,14 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const aws = require("@cdktf/provider-aws"); -const cdktf = require("cdktf"); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const aws = require("@cdktf/provider-aws"); + const cdktf = require("cdktf"); + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/bring_jsii.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/bring_jsii.test.w_compile_tf-aws.md index b03d29cef19..2c3cd6bb952 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/bring_jsii.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/bring_jsii.test.w_compile_tf-aws.md @@ -65,12 +65,15 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; -const stuff = require("jsii-code-samples"); -const jsii_fixture = require("jsii-fixture"); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + const stuff = require("jsii-code-samples"); + const jsii_fixture = require("jsii-fixture"); + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/bypass_return.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/bypass_return.test.w_compile_tf-aws.md index 356c05c83b2..0446241e7b4 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/bypass_return.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/bypass_return.test.w_compile_tf-aws.md @@ -32,6 +32,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; const simpleThrow = (() => { throw new Error("not implemented"); }); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/call_static_of_myself.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/call_static_of_myself.test.w_compile_tf-aws.md index 379872709cd..15929b94a08 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/call_static_of_myself.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/call_static_of_myself.test.w_compile_tf-aws.md @@ -103,6 +103,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); @@ -182,7 +185,8 @@ class $Root extends $stdlib.std.Resource { }); } } - const $Bar_1 = new Bar(this, "$Bar_1"); + if ($preflightTypesMap[1]) { throw new Error("Bar is already in type map"); } + $preflightTypesMap[1] = Bar; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -212,13 +216,13 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ - [$Bar_1, ["callThis"]], + [$helpers.nodeof(this).root.$preflightTypesMap[1]._singleton(this,"Bar_singleton_1"), ["callThis"]], [Bar, ["bar"]], [Foo, ["foo"]], [foo, ["callThis"]], ], "$inflight_init": [ - [$Bar_1, []], + [$helpers.nodeof(this).root.$preflightTypesMap[1]._singleton(this,"Bar_singleton_1"), []], [Bar, []], [Foo, []], [foo, []], diff --git a/tools/hangar/__snapshots__/test_corpus/valid/capture_mutables.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/capture_mutables.test.w_compile_tf-aws.md index 14947547926..8919d024e55 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/capture_mutables.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/capture_mutables.test.w_compile_tf-aws.md @@ -75,6 +75,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/capture_primitives.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/capture_primitives.test.w_compile_tf-aws.md index acdaed6230a..f7be7f815e7 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/capture_primitives.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/capture_primitives.test.w_compile_tf-aws.md @@ -169,10 +169,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/capture_resource_and_data.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/capture_resource_and_data.test.w_compile_tf-aws.md index 18954b6e717..842699b111f 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/capture_resource_and_data.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/capture_resource_and_data.test.w_compile_tf-aws.md @@ -79,10 +79,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/construct-base.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/construct-base.test.w_compile_tf-aws.md index 23a43eb2045..4ee8b0e98d6 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/construct-base.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/construct-base.test.w_compile_tf-aws.md @@ -55,12 +55,15 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; -const cx = require("constructs"); -const aws = require("@cdktf/provider-aws"); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + const cx = require("constructs"); + const aws = require("@cdktf/provider-aws"); + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class WingResource extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/container_types.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/container_types.test.w_compile_tf-aws.md index 34176ad7a2a..8c742a29072 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/container_types.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/container_types.test.w_compile_tf-aws.md @@ -63,10 +63,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; const bucket1 = this.node.root.new("@winglang/sdk.cloud.Bucket", cloud.Bucket, this, "bucket1"); const bucket2 = this.node.root.new("@winglang/sdk.cloud.Bucket", cloud.Bucket, this, "bucket2"); const bucket3 = this.node.root.new("@winglang/sdk.cloud.Bucket", cloud.Bucket, this, "bucket3"); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/custom_obj_id.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/custom_obj_id.test.w_compile_tf-aws.md index 20431cac6fb..eb7c3eb9ec5 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/custom_obj_id.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/custom_obj_id.test.w_compile_tf-aws.md @@ -46,6 +46,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/debug_env.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/debug_env.test.w_compile_tf-aws.md index 25341c9e579..3fbaa85efec 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/debug_env.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/debug_env.test.w_compile_tf-aws.md @@ -43,10 +43,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class A extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/double_reference.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/double_reference.test.w_compile_tf-aws.md index d6e7eeb4aac..64c6a92c3da 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/double_reference.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/double_reference.test.w_compile_tf-aws.md @@ -109,10 +109,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/doubler.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/doubler.test.w_compile_tf-aws.md index 14bf586b2ab..726d39bf6a8 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/doubler.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/doubler.test.w_compile_tf-aws.md @@ -253,10 +253,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Doubler extends $stdlib.std.Resource { constructor($scope, $id, func) { super($scope, $id); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/expressions_binary_operators.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/expressions_binary_operators.test.w_compile_tf-aws.md index 0ed26f1e9f0..ffdc25843ee 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/expressions_binary_operators.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/expressions_binary_operators.test.w_compile_tf-aws.md @@ -32,6 +32,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; const x = (-1); const y = (2 * x); const z = ((x + y) - 1); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/expressions_string_interpolation.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/expressions_string_interpolation.test.w_compile_tf-aws.md index cb0d2ed7a5f..82b8f2b6e5a 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/expressions_string_interpolation.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/expressions_string_interpolation.test.w_compile_tf-aws.md @@ -54,10 +54,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const expect = $stdlib.expect; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const expect = $stdlib.expect; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -86,9 +89,11 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$stdlib.core.toLiftableModuleType(expect.Util, "@winglang/sdk/expect", "Util"), ["equal"]], [number, []], ], "$inflight_init": [ + [$stdlib.core.toLiftableModuleType(expect.Util, "@winglang/sdk/expect", "Util"), []], [number, []], ], }); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/extern_implementation.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/extern_implementation.test.w_compile_tf-aws.md index 8c7d821d3a8..0826264c20b 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/extern_implementation.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/extern_implementation.test.w_compile_tf-aws.md @@ -237,10 +237,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/file_counter.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/file_counter.test.w_compile_tf-aws.md index 7cab4a39fc8..6254f3dc2aa 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/file_counter.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/file_counter.test.w_compile_tf-aws.md @@ -217,10 +217,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/function_type.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/function_type.test.w_compile_tf-aws.md index ca5805b236a..8705c913324 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/function_type.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/function_type.test.w_compile_tf-aws.md @@ -107,6 +107,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/hello.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/hello.test.w_compile_tf-aws.md index 27941b931ba..be309f48254 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/hello.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/hello.test.w_compile_tf-aws.md @@ -195,10 +195,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/impl_interface.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/impl_interface.test.w_compile_tf-aws.md index caf2cd8e6aa..e0d7bf011db 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/impl_interface.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/impl_interface.test.w_compile_tf-aws.md @@ -266,11 +266,14 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; -const jsii_fixture = require("jsii-fixture"); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + const jsii_fixture = require("jsii-fixture"); + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class A extends $stdlib.std.Resource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -626,6 +629,8 @@ class $Root extends $stdlib.std.Resource { }); } } + if ($preflightTypesMap[10]) { throw new Error("ImplInflightIfaceInInflightClass is already in type map"); } + $preflightTypesMap[10] = ImplInflightIfaceInInflightClass; class ImplInflightIfaceInPreflightClass extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/indexing.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/indexing.test.w_compile_tf-aws.md index 11d7a61fd58..b7d4b5afc7a 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/indexing.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/indexing.test.w_compile_tf-aws.md @@ -43,11 +43,14 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; -const expect = $stdlib.expect; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + const expect = $stdlib.expect; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class A extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight-subscribers.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight-subscribers.test.w_compile_tf-aws.md index 32e4f4a90e5..5f891725ddc 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight-subscribers.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight-subscribers.test.w_compile_tf-aws.md @@ -323,10 +323,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_as_struct_members.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_as_struct_members.test.w_compile_tf-aws.md index 8101901b733..e279c3089b9 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_as_struct_members.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_as_struct_members.test.w_compile_tf-aws.md @@ -88,6 +88,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); @@ -118,7 +121,8 @@ class $Root extends $stdlib.std.Resource { }); } } - const $Foo_0 = new Foo(this, "$Foo_0"); + if ($preflightTypesMap[0]) { throw new Error("Foo is already in type map"); } + $preflightTypesMap[0] = Foo; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -181,11 +185,11 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ - [$Foo_0, ["get"]], + [$helpers.nodeof(this).root.$preflightTypesMap[0]._singleton(this,"Foo_singleton_0"), ["get"]], [getBar, ["handle"]], ], "$inflight_init": [ - [$Foo_0, []], + [$helpers.nodeof(this).root.$preflightTypesMap[0]._singleton(this,"Foo_singleton_0"), []], [getBar, []], ], }); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_capture_preflight_object.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_capture_preflight_object.test.w_compile_tf-aws.md index 3cabd83f994..5bf185d8f18 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_capture_preflight_object.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_capture_preflight_object.test.w_compile_tf-aws.md @@ -1,7 +1,7 @@ # [inflight_class_capture_preflight_object.test.w](../../../../../examples/tests/valid/inflight_class_capture_preflight_object.test.w) | compile | tf-aws -## inflight.$Closure1-1.js -```js +## inflight.$Closure1-1.cjs +```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); module.exports = function({ $Foo }) { @@ -18,11 +18,11 @@ module.exports = function({ $Foo }) { } return $Closure1; } -//# sourceMappingURL=inflight.$Closure1-1.js.map +//# sourceMappingURL=inflight.$Closure1-1.cjs.map ``` -## inflight.$Closure2-1.js -```js +## inflight.$Closure2-1.cjs +```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); module.exports = function({ $Foo }) { @@ -38,11 +38,11 @@ module.exports = function({ $Foo }) { } return $Closure2; } -//# sourceMappingURL=inflight.$Closure2-1.js.map +//# sourceMappingURL=inflight.$Closure2-1.cjs.map ``` -## inflight.$Closure3-1.js -```js +## inflight.$Closure3-1.cjs +```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); module.exports = function({ $Foo }) { @@ -58,11 +58,11 @@ module.exports = function({ $Foo }) { } return $Closure3; } -//# sourceMappingURL=inflight.$Closure3-1.js.map +//# sourceMappingURL=inflight.$Closure3-1.cjs.map ``` -## inflight.$Closure4-1.js -```js +## inflight.$Closure4-1.cjs +```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); module.exports = function({ $getFoo }) { @@ -79,11 +79,11 @@ module.exports = function({ $getFoo }) { } return $Closure4; } -//# sourceMappingURL=inflight.$Closure4-1.js.map +//# sourceMappingURL=inflight.$Closure4-1.cjs.map ``` -## inflight.$Closure5-1.js -```js +## inflight.$Closure5-1.cjs +```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); module.exports = function({ $b }) { @@ -106,11 +106,11 @@ module.exports = function({ $b }) { } return $Closure5; } -//# sourceMappingURL=inflight.$Closure5-1.js.map +//# sourceMappingURL=inflight.$Closure5-1.cjs.map ``` -## inflight.Foo-1.js -```js +## inflight.Foo-1.cjs +```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); module.exports = function({ $b }) { @@ -125,7 +125,7 @@ module.exports = function({ $b }) { } return Foo; } -//# sourceMappingURL=inflight.Foo-1.js.map +//# sourceMappingURL=inflight.Foo-1.cjs.map ``` ## main.tf.json @@ -146,14 +146,14 @@ module.exports = function({ $b }) { }, "resource": { "aws_s3_bucket": { - "cloudBucket": { + "Bucket": { "//": { "metadata": { - "path": "root/Default/Default/cloud.Bucket/Default", - "uniqueId": "cloudBucket" + "path": "root/Default/Default/Bucket/Default", + "uniqueId": "Bucket" } }, - "bucket_prefix": "cloud-bucket-c87175e7-", + "bucket_prefix": "bucket-c88fdc5f-", "force_destroy": false } } @@ -170,21 +170,21 @@ const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; -<<<<<<< HEAD -const cloud = $stdlib.cloud; -======= const $extern = $helpers.createExternRequire(__dirname); ->>>>>>> main class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); } static _toInflightType() { return ` - require("${$helpers.normalPath(__dirname)}/inflight.Foo-1.js")({ + require("${$helpers.normalPath(__dirname)}/inflight.Foo-1.cjs")({ $b: ${$stdlib.core.liftObject(b)}, }) `; @@ -203,7 +203,7 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "uploadToBucket": [ - [b, ["get", "put"]], + [b, [].concat(["put"], ["get"])], ], "$inflight_init": [ [b, []], @@ -218,7 +218,8 @@ class $Root extends $stdlib.std.Resource { }); } } - const $Foo_0 = new Foo(this, "$Foo_0"); + if ($preflightTypesMap[0]) { throw new Error("Foo is already in type map"); } + $preflightTypesMap[0] = Foo; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -227,7 +228,7 @@ class $Root extends $stdlib.std.Resource { } static _toInflightType() { return ` - require("${$helpers.normalPath(__dirname)}/inflight.$Closure1-1.js")({ + require("${$helpers.normalPath(__dirname)}/inflight.$Closure1-1.cjs")({ $Foo: ${$stdlib.core.liftObject(Foo)}, }) `; @@ -246,11 +247,11 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ - [$Foo_0, ["uploadToBucket"]], + [$helpers.nodeof(this).root.$preflightTypesMap[0]._singleton(this,"Foo_singleton_0"), ["uploadToBucket"]], [Foo, []], ], "$inflight_init": [ - [$Foo_0, []], + [$helpers.nodeof(this).root.$preflightTypesMap[0]._singleton(this,"Foo_singleton_0"), []], [Foo, []], ], }); @@ -264,7 +265,7 @@ class $Root extends $stdlib.std.Resource { } static _toInflightType() { return ` - require("${$helpers.normalPath(__dirname)}/inflight.$Closure2-1.js")({ + require("${$helpers.normalPath(__dirname)}/inflight.$Closure2-1.cjs")({ $Foo: ${$stdlib.core.liftObject(Foo)}, }) `; @@ -299,7 +300,7 @@ class $Root extends $stdlib.std.Resource { } static _toInflightType() { return ` - require("${$helpers.normalPath(__dirname)}/inflight.$Closure3-1.js")({ + require("${$helpers.normalPath(__dirname)}/inflight.$Closure3-1.cjs")({ $Foo: ${$stdlib.core.liftObject(Foo)}, }) `; @@ -334,7 +335,7 @@ class $Root extends $stdlib.std.Resource { } static _toInflightType() { return ` - require("${$helpers.normalPath(__dirname)}/inflight.$Closure4-1.js")({ + require("${$helpers.normalPath(__dirname)}/inflight.$Closure4-1.cjs")({ $getFoo: ${$stdlib.core.liftObject(getFoo)}, }) `; @@ -353,11 +354,11 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ - [$Foo_0, ["uploadToBucket"]], + [$helpers.nodeof(this).root.$preflightTypesMap[0]._singleton(this,"Foo_singleton_0"), ["uploadToBucket"]], [getFoo, ["handle"]], ], "$inflight_init": [ - [$Foo_0, []], + [$helpers.nodeof(this).root.$preflightTypesMap[0]._singleton(this,"Foo_singleton_0"), []], [getFoo, []], ], }); @@ -371,7 +372,7 @@ class $Root extends $stdlib.std.Resource { } static _toInflightType() { return ` - require("${$helpers.normalPath(__dirname)}/inflight.$Closure5-1.js")({ + require("${$helpers.normalPath(__dirname)}/inflight.$Closure5-1.cjs")({ $b: ${$stdlib.core.liftObject(b)}, }) `; @@ -390,7 +391,7 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ - [b, ["get", "put"]], + [b, [].concat(["put"], ["get"])], ], "$inflight_init": [ [b, []], @@ -398,7 +399,7 @@ class $Root extends $stdlib.std.Resource { }); } } - const b = this.node.root.new("@winglang/sdk.cloud.Bucket", cloud.Bucket, this, "cloud.Bucket"); + const b = this.node.root.new("@winglang/sdk.cloud.Bucket", cloud.Bucket, this, "Bucket"); this.node.root.new("@winglang/sdk.std.Test", std.Test, this, "test:inflight class captures preflight resource", new $Closure1(this, "$Closure1")); this.node.root.new("@winglang/sdk.std.Test", std.Test, this, "test:inflight class type captures preflight resource", new $Closure2(this, "$Closure2")); const getFoo = new $Closure3(this, "$Closure3"); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_capture_preflight_object.test.w_test_sim.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_capture_preflight_object.test.w_test_sim.md index 72807c6dea2..61d42bf4f69 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_capture_preflight_object.test.w_test_sim.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_capture_preflight_object.test.w_test_sim.md @@ -2,20 +2,13 @@ ## stdout.log ```log -<<<<<<< HEAD pass ─ inflight_class_capture_preflight_object.test.wsim » root/env0/test:inflight class captures preflight resource pass ─ inflight_class_capture_preflight_object.test.wsim » root/env1/test:inflight class type captures preflight resource pass ─ inflight_class_capture_preflight_object.test.wsim » root/env2/test:inflight class qualified without explicit reference pass ─ inflight_class_capture_preflight_object.test.wsim » root/env3/test:inflight class defined inflight captures preflight object - - -Tests 4 passed (4) -======= -pass ─ inflight_class_capture_preflight_object.test.wsim (no tests) -Tests 1 passed (1) +Tests 4 passed (4) Snapshots 1 skipped ->>>>>>> main Test Files 1 passed (1) Duration ``` diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_inner_capture_mutable.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_inner_capture_mutable.test.w_compile_tf-aws.md index f00e099cee6..ecac8e8cda9 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_inner_capture_mutable.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_inner_capture_mutable.test.w_compile_tf-aws.md @@ -60,10 +60,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight_closure_as_super_param.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight_closure_as_super_param.test.w_compile_tf-aws.md index dd11ada8e03..d546de4b494 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight_closure_as_super_param.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight_closure_as_super_param.test.w_compile_tf-aws.md @@ -115,6 +115,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight_closure_autoid.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight_closure_autoid.test.w_compile_tf-aws.md index 6e531964898..b901b4daf03 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight_closure_autoid.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight_closure_autoid.test.w_compile_tf-aws.md @@ -74,6 +74,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure2 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight_concat.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight_concat.test.w_compile_tf-aws.md index 4432a818dc0..77dc2e682ee 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight_concat.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight_concat.test.w_compile_tf-aws.md @@ -47,10 +47,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class R extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight_init.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight_init.test.w_compile_tf-aws.md index 409b3840d07..d5fe6e510d1 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight_init.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight_init.test.w_compile_tf-aws.md @@ -193,10 +193,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const jsii_fixture = require("jsii-fixture"); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const jsii_fixture = require("jsii-fixture"); + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); @@ -232,7 +235,8 @@ class $Root extends $stdlib.std.Resource { }); } } - const $Foo_0 = new Foo(this, "$Foo_0"); + if ($preflightTypesMap[0]) { throw new Error("Foo is already in type map"); } + $preflightTypesMap[0] = Foo; class FooChild extends Foo { constructor($scope, $id, ) { super($scope, $id); @@ -265,7 +269,8 @@ class $Root extends $stdlib.std.Resource { }); } } - const $FooChild_1 = new FooChild(this, "$FooChild_1"); + if ($preflightTypesMap[1]) { throw new Error("FooChild is already in type map"); } + $preflightTypesMap[1] = FooChild; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -293,11 +298,11 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ - [$Foo_0, ["field1", "field2"]], + [$helpers.nodeof(this).root.$preflightTypesMap[0]._singleton(this,"Foo_singleton_0"), [].concat(["field1"], ["field2"])], [Foo, []], ], "$inflight_init": [ - [$Foo_0, []], + [$helpers.nodeof(this).root.$preflightTypesMap[0]._singleton(this,"Foo_singleton_0"), []], [Foo, []], ], }); @@ -330,11 +335,11 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ - [$FooChild_1, ["field1", "field2", "field3"]], + [$helpers.nodeof(this).root.$preflightTypesMap[1]._singleton(this,"FooChild_singleton_1"), [].concat(["field1"], ["field2"], ["field3"])], [FooChild, []], ], "$inflight_init": [ - [$FooChild_1, []], + [$helpers.nodeof(this).root.$preflightTypesMap[1]._singleton(this,"FooChild_singleton_1"), []], [FooChild, []], ], }); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inherit_stdlib_class.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inherit_stdlib_class.test.w_compile_tf-aws.md index 7c8e452ca07..2128b86f5ed 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inherit_stdlib_class.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inherit_stdlib_class.test.w_compile_tf-aws.md @@ -290,11 +290,14 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; -const http = $stdlib.http; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + const http = $stdlib.http; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class AnApi extends (this?.node?.root?.typeForFqn("@winglang/sdk.cloud.Api") ?? cloud.Api) { constructor($scope, $id, ) { super($scope, $id); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inheritance_class_inflight.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inheritance_class_inflight.test.w_compile_tf-aws.md index ffe5fb5b6a7..099d61cf87d 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inheritance_class_inflight.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inheritance_class_inflight.test.w_compile_tf-aws.md @@ -92,10 +92,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const expect = $stdlib.expect; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const expect = $stdlib.expect; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class FooBase extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); @@ -189,12 +192,8 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ -<<<<<<< HEAD [$stdlib.core.toLiftableModuleType(expect.Util, "@winglang/sdk/expect", "Util"), ["equal"]], - [foo, ["bang", "bug", "over_inflight"]], -======= [foo, [].concat(["bang"], ["bug"], ["over_inflight"])], ->>>>>>> main ], "$inflight_init": [ [$stdlib.core.toLiftableModuleType(expect.Util, "@winglang/sdk/expect", "Util"), []], diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inheritance_class_preflight.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inheritance_class_preflight.test.w_compile_tf-aws.md index fd16413a92a..9a4f9c0a3a2 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inheritance_class_preflight.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inheritance_class_preflight.test.w_compile_tf-aws.md @@ -58,10 +58,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const expect = $stdlib.expect; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const expect = $stdlib.expect; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class FooBase extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inheritance_interface.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inheritance_interface.test.w_compile_tf-aws.md index 7d55a61e604..5d2ed50f26b 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inheritance_interface.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inheritance_interface.test.w_compile_tf-aws.md @@ -43,10 +43,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const expect = $stdlib.expect; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const expect = $stdlib.expect; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Baz extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/intrinsics.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/intrinsics.test.w_compile_tf-aws.md index 8ac2e856142..61c12072f70 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/intrinsics.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/intrinsics.test.w_compile_tf-aws.md @@ -227,6 +227,7 @@ const $stdlib = require('@winglang/sdk'); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); +let $preflightTypesMap = {}; class Bar extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); @@ -261,7 +262,7 @@ class Bar extends $stdlib.std.Resource { }); } } -module.exports = { Bar }; +module.exports = { $preflightTypesMap, Bar }; //# sourceMappingURL=preflight.bar-1.cjs.map ``` @@ -275,14 +276,18 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const fs = $stdlib.fs; -const expect = $stdlib.expect; -const cloud = $stdlib.cloud; -const util = $stdlib.util; -const bar = require("./preflight.bar-1.cjs"); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const fs = $stdlib.fs; + const expect = $stdlib.expect; + const cloud = $stdlib.cloud; + const util = $stdlib.util; + const bar = require("./preflight.bar-1.cjs"); + Object.assign($preflightTypesMap, bar.$preflightTypesMap); + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Example extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/issue_2889.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/issue_2889.test.w_compile_tf-aws.md index aefd79c7f4d..ebde70383f4 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/issue_2889.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/issue_2889.test.w_compile_tf-aws.md @@ -278,11 +278,14 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; -const http = $stdlib.http; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + const http = $stdlib.http; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -310,7 +313,7 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ - [$stdlib.core.toLiftableModuleType(std.Json, "@winglang/sdk/std", "Json"), ["parse", "stringify"]], + [$stdlib.core.toLiftableModuleType(std.Json, "@winglang/sdk/std", "Json"), [].concat(["parse"], ["stringify"])], ], "$inflight_init": [ [$stdlib.core.toLiftableModuleType(std.Json, "@winglang/sdk/std", "Json"), []], diff --git a/tools/hangar/__snapshots__/test_corpus/valid/json.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/json.test.w_compile_tf-aws.md index e262672752b..716344cec0f 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/json.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/json.test.w_compile_tf-aws.md @@ -67,10 +67,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/lift_expr_with_this.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/lift_expr_with_this.test.w_compile_tf-aws.md index 458c3ebe66e..61e4ee2c724 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/lift_expr_with_this.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/lift_expr_with_this.test.w_compile_tf-aws.md @@ -67,6 +67,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/lift_parent_fields.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/lift_parent_fields.test.w_compile_tf-aws.md index 9854460a01c..ff6fac156b1 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/lift_parent_fields.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/lift_parent_fields.test.w_compile_tf-aws.md @@ -112,6 +112,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class A extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/lift_redefinition.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/lift_redefinition.test.w_compile_tf-aws.md index 008fd5cb20d..69ccb764d17 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/lift_redefinition.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/lift_redefinition.test.w_compile_tf-aws.md @@ -54,6 +54,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/lift_shared_resource.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/lift_shared_resource.test.w_compile_tf-aws.md index 5a6012b9365..40d14ca3ffb 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/lift_shared_resource.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/lift_shared_resource.test.w_compile_tf-aws.md @@ -306,11 +306,14 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; -const http = $stdlib.http; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + const http = $stdlib.http; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class MyBucket extends $stdlib.std.Resource { constructor($scope, $id, bucket) { super($scope, $id); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/lift_via_closure_explicit.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/lift_via_closure_explicit.test.w_compile_tf-aws.md index 55c83d2f17b..9ed995f0898 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/lift_via_closure_explicit.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/lift_via_closure_explicit.test.w_compile_tf-aws.md @@ -85,10 +85,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class MyClosure extends $stdlib.std.Resource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/lift_weird_order.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/lift_weird_order.test.w_compile_tf-aws.md index 38549ae6e98..10a17579195 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/lift_weird_order.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/lift_weird_order.test.w_compile_tf-aws.md @@ -87,6 +87,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class B extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/lift_with_phase_ind.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/lift_with_phase_ind.test.w_compile_tf-aws.md index d3dd8cab740..abd42661f3a 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/lift_with_phase_ind.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/lift_with_phase_ind.test.w_compile_tf-aws.md @@ -56,10 +56,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const math = $stdlib.math; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const math = $stdlib.math; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -88,20 +91,11 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ -<<<<<<< HEAD - [$stdlib.core.toLiftableModuleType(math.Util, "@winglang/sdk/math", "Util"), ["floor", "random"]], - [((arr, index) => { if (index < 0 || index >= arr.length) throw new Error("Index out of bounds"); return arr[index]; })(ar, 0), []], - [ar, ["at"]], - [ar.length, []], - ], - "$inflight_init": [ - [$stdlib.core.toLiftableModuleType(math.Util, "@winglang/sdk/math", "Util"), []], - [((arr, index) => { if (index < 0 || index >= arr.length) throw new Error("Index out of bounds"); return arr[index]; })(ar, 0), []], -======= + [$stdlib.core.toLiftableModuleType(math.Util, "@winglang/sdk/math", "Util"), [].concat(["floor"], ["random"])], [ar, [].concat(["at"], ["length"], ["copyMut"])], ], "$inflight_init": [ ->>>>>>> main + [$stdlib.core.toLiftableModuleType(math.Util, "@winglang/sdk/math", "Util"), []], [ar, []], ], }); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/map_entries.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/map_entries.test.w_compile_tf-aws.md index 2af554c8351..62907a2674b 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/map_entries.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/map_entries.test.w_compile_tf-aws.md @@ -119,6 +119,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/mut_container_types.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/mut_container_types.test.w_compile_tf-aws.md index c62dfd7a085..22ddc6779e2 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/mut_container_types.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/mut_container_types.test.w_compile_tf-aws.md @@ -63,10 +63,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; const bucket1 = this.node.root.new("@winglang/sdk.cloud.Bucket", cloud.Bucket, this, "bucket1"); const bucket2 = this.node.root.new("@winglang/sdk.cloud.Bucket", cloud.Bucket, this, "bucket2"); const bucket3 = this.node.root.new("@winglang/sdk.cloud.Bucket", cloud.Bucket, this, "bucket3"); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/mutation_after_class_init.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/mutation_after_class_init.test.w_compile_tf-aws.md index 7a62dc413ca..72aa15cbe89 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/mutation_after_class_init.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/mutation_after_class_init.test.w_compile_tf-aws.md @@ -340,11 +340,14 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; -const util = $stdlib.util; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + const util = $stdlib.util; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Queue extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/new_in_static_lib.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/new_in_static_lib.w_compile_tf-aws.md index 2600606fde2..9905f1aa986 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/new_in_static_lib.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/new_in_static_lib.w_compile_tf-aws.md @@ -35,6 +35,7 @@ const $stdlib = require('@winglang/sdk'); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); +let $preflightTypesMap = {}; class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); @@ -94,7 +95,7 @@ class LibClass extends $stdlib.std.Resource { }); } } -module.exports = { Foo, LibClass }; +module.exports = { $preflightTypesMap, Foo, LibClass }; //# sourceMappingURL=preflight.cjs.map ``` diff --git a/tools/hangar/__snapshots__/test_corpus/valid/on_lift.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/on_lift.test.w_compile_tf-aws.md index 5f90f066f13..aa3b0d81338 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/on_lift.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/on_lift.test.w_compile_tf-aws.md @@ -72,10 +72,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const util = $stdlib.util; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const util = $stdlib.util; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/optionals.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/optionals.test.w_compile_tf-aws.md index 0fe1fc6a2e6..7f22a91749c 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/optionals.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/optionals.test.w_compile_tf-aws.md @@ -124,11 +124,14 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; const Person = $stdlib.std.Struct._createJsonSchema({$id:"/Person",type:"object",properties:{age:{type:"number"},name:{type:"string"},},required:["age","name",]}); + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Super extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/parameters/simple/parameters.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/parameters/simple/parameters.test.w_compile_tf-aws.md index 3d38905013f..036b27644fb 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/parameters/simple/parameters.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/parameters/simple/parameters.test.w_compile_tf-aws.md @@ -32,7 +32,10 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; const MyParams = $stdlib.std.Struct._createJsonSchema({$id:"/MyParams",type:"object",properties:{foo:{type:"string"},meaningOfLife:{type:"number"},},required:["meaningOfLife",]}); + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; const app = $helpers.nodeof(this).app; const myParams = MyParams._fromJson((app.parameters.read({ schema: MyParams }))); { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/phase_independent_method_on_string.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/phase_independent_method_on_string.test.w_compile_tf-aws.md index 32663fe374b..47b74d18b42 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/phase_independent_method_on_string.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/phase_independent_method_on_string.test.w_compile_tf-aws.md @@ -137,11 +137,14 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; -const expect = $stdlib.expect; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + const expect = $stdlib.expect; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -172,11 +175,13 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$stdlib.core.toLiftableModuleType(expect.Util, "@winglang/sdk/expect", "Util"), [].concat(["equal"], ["notEqual"])], [api.url, [].concat(["startsWith"], ["length"])], [tokenLength, []], [urlRegex, ["test"]], ], "$inflight_init": [ + [$stdlib.core.toLiftableModuleType(expect.Util, "@winglang/sdk/expect", "Util"), []], [api.url, []], [tokenLength, []], [urlRegex, []], diff --git a/tools/hangar/__snapshots__/test_corpus/valid/primitive_methods.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/primitive_methods.test.w_compile_tf-aws.md index 441e37501dd..8659dd3c13b 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/primitive_methods.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/primitive_methods.test.w_compile_tf-aws.md @@ -32,6 +32,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; const dur = (std.Duration.fromSeconds(60)); const dur2 = (std.Duration.fromSeconds(600)); const f = ((d) => { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/print.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/print.test.w_compile_tf-aws.md index 562f60a538d..2aedf6c529d 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/print.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/print.test.w_compile_tf-aws.md @@ -71,10 +71,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/reassignment.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/reassignment.test.w_compile_tf-aws.md index e19b9812b63..6d5df9c4d4f 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/reassignment.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/reassignment.test.w_compile_tf-aws.md @@ -46,6 +46,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class R extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/redis.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/redis.test.w_compile_tf-aws.md index 02f36906f93..58a7344d1cd 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/redis.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/redis.test.w_compile_tf-aws.md @@ -682,12 +682,15 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; -const util = $stdlib.util; -const ex = $stdlib.ex; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + const util = $stdlib.util; + const ex = $stdlib.ex; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/resource.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/resource.test.w_compile_tf-aws.md index 657ae3d67f8..5b87acbee1f 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/resource.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/resource.test.w_compile_tf-aws.md @@ -709,11 +709,14 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; -const util = $stdlib.util; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + const util = $stdlib.util; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; const MyEnum = (function (tmp) { tmp["A"] = "A"; @@ -1055,9 +1058,11 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$stdlib.core.toLiftableModuleType(util.Util, "@winglang/sdk/util", "Util"), ["waitUntil"]], [bigOlPublisher, [].concat(["publish"], ["getObjectCount"])], ], "$inflight_init": [ + [$stdlib.core.toLiftableModuleType(util.Util, "@winglang/sdk/util", "Util"), []], [bigOlPublisher, []], ], }); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/resource_as_inflight_literal.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/resource_as_inflight_literal.test.w_compile_tf-aws.md index f4c393d508d..fb1cb5e73d6 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/resource_as_inflight_literal.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/resource_as_inflight_literal.test.w_compile_tf-aws.md @@ -175,10 +175,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/resource_call_static.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/resource_call_static.test.w_compile_tf-aws.md index 42248faa995..f50e516d74a 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/resource_call_static.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/resource_call_static.test.w_compile_tf-aws.md @@ -87,10 +87,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Another extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/service.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/service.test.w_compile_tf-aws.md index 1cbc516d9b3..323cbc41bc9 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/service.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/service.test.w_compile_tf-aws.md @@ -32,6 +32,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; } } const $PlatformManager = new $stdlib.platform.PlatformManager({platformPaths: $platforms}); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/sim_resource.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/sim_resource.test.w_compile_tf-aws.md index 0a5d8eb39a4..f1ca7078fcd 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/sim_resource.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/sim_resource.test.w_compile_tf-aws.md @@ -76,10 +76,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const sim = $stdlib.sim; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const sim = $stdlib.sim; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; const MyEnum = (function (tmp) { tmp["A"] = "A"; @@ -127,6 +130,7 @@ class $Root extends $stdlib.std.Resource { "methodWithJsons": [ ], "methodWithEnums": [ + [MyEnum, ["A"]], ], "methodWithArrays": [ ], @@ -139,10 +143,13 @@ class $Root extends $stdlib.std.Resource { "methodWithComplexTypes": [ ], "$inflight_init": [ + [MyEnum, []], ], }); } } + if ($preflightTypesMap[0]) { throw new Error("ResourceBackend is already in type map"); } + $preflightTypesMap[0] = ResourceBackend; } } const $PlatformManager = new $stdlib.platform.PlatformManager({platformPaths: $platforms}); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/statements_variable_declarations.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/statements_variable_declarations.test.w_compile_tf-aws.md index 78aaec16adc..17f18ec79d7 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/statements_variable_declarations.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/statements_variable_declarations.test.w_compile_tf-aws.md @@ -32,6 +32,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; const x = 2; const y = x; const id = 1; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/static_members.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/static_members.test.w_compile_tf-aws.md index eb12cc98e9c..2c7978b8bbc 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/static_members.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/static_members.test.w_compile_tf-aws.md @@ -76,10 +76,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/std_containers.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/std_containers.test.w_compile_tf-aws.md index b7b54c36a69..b546d0d78eb 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/std_containers.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/std_containers.test.w_compile_tf-aws.md @@ -76,6 +76,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Animal extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/std_string.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/std_string.test.w_compile_tf-aws.md index a2d9f9663d6..8642a2241bf 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/std_string.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/std_string.test.w_compile_tf-aws.md @@ -54,6 +54,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/store.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/store.w_compile_tf-aws.md index 5afb35fc2ee..377d4b78ffe 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/store.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/store.w_compile_tf-aws.md @@ -59,7 +59,9 @@ const $stdlib = require('@winglang/sdk'); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); +let $preflightTypesMap = {}; const file3 = require("./preflight.empty-1.cjs"); +Object.assign($preflightTypesMap, file3.$preflightTypesMap); const math = $stdlib.math; const cloud = $stdlib.cloud; const Color = @@ -169,7 +171,7 @@ class Store extends $stdlib.std.Resource { }); } } -module.exports = { Util, Store, Color }; +module.exports = { $preflightTypesMap, Util, Store, Color }; //# sourceMappingURL=preflight.cjs.map ``` @@ -180,7 +182,8 @@ const $stdlib = require('@winglang/sdk'); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -module.exports = { }; +let $preflightTypesMap = {}; +module.exports = { $preflightTypesMap, }; //# sourceMappingURL=preflight.empty-1.cjs.map ``` diff --git a/tools/hangar/__snapshots__/test_corpus/valid/struct_from_json.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/struct_from_json.test.w_compile_tf-aws.md index 46bb3d9a3b4..b6976ae517b 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/struct_from_json.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/struct_from_json.test.w_compile_tf-aws.md @@ -177,12 +177,16 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; -const externalStructs = require("./preflight.structs-1.cjs"); -const otherExternalStructs = require("./preflight.structs2-2.cjs"); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + const externalStructs = require("./preflight.structs-1.cjs"); + Object.assign($preflightTypesMap, externalStructs.$preflightTypesMap); + const otherExternalStructs = require("./preflight.structs2-2.cjs"); + Object.assign($preflightTypesMap, otherExternalStructs.$preflightTypesMap); const Bar = $stdlib.std.Struct._createJsonSchema({$id:"/Bar",type:"object",properties:{b:{type:"number"},f:{type:"string"},},required:["b","f",]}); const Foo = $stdlib.std.Struct._createJsonSchema({$id:"/Foo",type:"object",properties:{f:{type:"string"},},required:["f",]}); const Foosible = $stdlib.std.Struct._createJsonSchema({$id:"/Foosible",type:"object",properties:{f:{type:"string"},},required:[]}); @@ -190,6 +194,7 @@ class $Root extends $stdlib.std.Resource { const Student = $stdlib.std.Struct._createJsonSchema({$id:"/Student",type:"object",properties:{additionalData:{type:["object","string","boolean","number","array"]},advisor:{type:"object",properties:{dob:{type:"object",properties:{day:{type:"number"},month:{type:"number"},year:{type:"number"},},required:["day","month","year",]},employeeID:{type:"string"},firstName:{type:"string"},lastName:{type:"string"},},required:["dob","employeeID","firstName","lastName",]},coursesTaken:{type:"array",items:{type:"object",properties:{course:{type:"object",properties:{credits:{type:"number"},name:{type:"string"},},required:["credits","name",]},dateTaken:{type:"object",properties:{day:{type:"number"},month:{type:"number"},year:{type:"number"},},required:["day","month","year",]},grade:{type:"string"},},required:["course","dateTaken","grade",]}},dob:{type:"object",properties:{day:{type:"number"},month:{type:"number"},year:{type:"number"},},required:["day","month","year",]},enrolled:{type:"boolean"},enrolledCourses:{type:"array",uniqueItems:true,items:{type:"object",properties:{credits:{type:"number"},name:{type:"string"},},required:["credits","name",]}},firstName:{type:"string"},lastName:{type:"string"},schoolId:{type:"string"},},required:["dob","enrolled","firstName","lastName","schoolId",]}); const cloud_BucketProps = $stdlib.std.Struct._createJsonSchema({$id:"/BucketProps",type:"object",properties:{public:{type:"boolean"},},required:[]}); const externalStructs_MyOtherStruct = $stdlib.std.Struct._createJsonSchema({$id:"/MyOtherStruct",type:"object",properties:{data:{type:"object",properties:{val:{type:"number"},},required:["val",]},},required:["data",]}); + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -332,23 +337,15 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ -<<<<<<< HEAD [$stdlib.core.toLiftableModuleType(std.Json, "@winglang/sdk/std", "Json"), ["stringify"]], - [(schema.asStr()), []], [MyStruct, ["schema"]], -======= ->>>>>>> main [expectedSchema, []], [jMyStruct, []], [schema, ["asStr"]], ], "$inflight_init": [ -<<<<<<< HEAD [$stdlib.core.toLiftableModuleType(std.Json, "@winglang/sdk/std", "Json"), []], - [(schema.asStr()), []], [MyStruct, []], -======= ->>>>>>> main [expectedSchema, []], [jMyStruct, []], [schema, []], @@ -538,7 +535,8 @@ const $stdlib = require('@winglang/sdk'); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -module.exports = { }; +let $preflightTypesMap = {}; +module.exports = { $preflightTypesMap, }; //# sourceMappingURL=preflight.structs-1.cjs.map ``` @@ -549,6 +547,7 @@ const $stdlib = require('@winglang/sdk'); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); +let $preflightTypesMap = {}; const SomeStruct = $stdlib.std.Struct._createJsonSchema({$id:"/SomeStruct",type:"object",properties:{foo:{type:"string"},},required:["foo",]}); class UsesStructInImportedFile extends $stdlib.std.Resource { constructor($scope, $id, ) { @@ -579,7 +578,7 @@ class UsesStructInImportedFile extends $stdlib.std.Resource { }); } } -module.exports = { UsesStructInImportedFile }; +module.exports = { $preflightTypesMap, UsesStructInImportedFile }; //# sourceMappingURL=preflight.structs2-2.cjs.map ``` diff --git a/tools/hangar/__snapshots__/test_corpus/valid/structs.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/structs.test.w_compile_tf-aws.md index ba53b64c40d..d573bd26e7a 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/structs.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/structs.test.w_compile_tf-aws.md @@ -68,10 +68,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const expect = $stdlib.expect; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const expect = $stdlib.expect; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { constructor($scope, $id, b) { super($scope, $id); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/table.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/table.test.w_compile_tf-aws.md index 57b28e91c18..31ca4eb0899 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/table.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/table.test.w_compile_tf-aws.md @@ -53,10 +53,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const ex = $stdlib.ex; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const ex = $stdlib.ex; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; const t = this.node.root.new("@winglang/sdk.ex.Table", ex.Table, this, "Table", { name: "simple-table", primaryKey: "id", columns: ({["id"]: ex.ColumnType.STRING, ["name"]: ex.ColumnType.STRING, ["age"]: ex.ColumnType.NUMBER}) }); } } diff --git a/tools/hangar/__snapshots__/test_corpus/valid/test_without_bring.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/test_without_bring.test.w_compile_tf-aws.md index 48e551a1e6e..ca582329c48 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/test_without_bring.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/test_without_bring.test.w_compile_tf-aws.md @@ -52,6 +52,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/this.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/this.test.w_compile_tf-aws.md index 283abc28bf8..ab26b401d8e 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/this.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/this.test.w_compile_tf-aws.md @@ -29,10 +29,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const expect = $stdlib.expect; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const expect = $stdlib.expect; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; const path = this.node.path; for (const c of this.node.children) { console.log(c.node.path); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/try_catch.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/try_catch.test.w_compile_tf-aws.md index 95648e798ba..6a7c7a83760 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/try_catch.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/try_catch.test.w_compile_tf-aws.md @@ -32,6 +32,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; let x = ""; try { throw new Error("hello"); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/unused_lift.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/unused_lift.test.w_compile_tf-aws.md index b235736da4c..09f41ecd8e4 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/unused_lift.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/unused_lift.test.w_compile_tf-aws.md @@ -121,10 +121,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/use_inflight_method_inside_init_closure.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/use_inflight_method_inside_init_closure.test.w_compile_tf-aws.md index f374ccee292..46957357cdc 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/use_inflight_method_inside_init_closure.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/use_inflight_method_inside_init_closure.test.w_compile_tf-aws.md @@ -171,10 +171,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/while_loop_await.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/while_loop_await.test.w_compile_tf-aws.md index 5baaa695c11..880b333792b 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/while_loop_await.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/while_loop_await.test.w_compile_tf-aws.md @@ -190,10 +190,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { From e9f49fe267a6c4ab2f676955a636b160973216eb Mon Sep 17 00:00:00 2001 From: "monada-bot[bot]" Date: Thu, 13 Jun 2024 10:14:23 +0000 Subject: [PATCH 43/78] chore: self mutation (e2e-2of2.diff) Signed-off-by: monada-bot[bot] --- tools/hangar/__snapshots__/invalid.ts.snap | 14 ------- .../anon_function.test.w_compile_tf-aws.md | 3 ++ .../valid/api.test.w_compile_tf-aws.md | 5 ++- .../api_cors_custom.test.w_compile_tf-aws.md | 15 +++++--- .../api_cors_default.test.w_compile_tf-aws.md | 15 +++++--- .../test_corpus/valid/baz.w_compile_tf-aws.md | 3 +- .../bring_alias.test.w_compile_tf-aws.md | 7 +++- ..._extend_non_entry.test.w_compile_tf-aws.md | 9 ++++- .../bring_local.test.w_compile_tf-aws.md | 28 ++++++++++---- .../bring_local_dir.test.w_compile_tf-aws.md | 35 ++++++++++------- ...cal_normalization.test.w_compile_tf-aws.md | 23 ++++++++--- .../bring_projen.test.w_compile_tf-aws.md | 5 ++- ...ring_wing_library.test.w_compile_tf-aws.md | 38 ++++++++++++------- .../bucket_keys.test.w_compile_tf-aws.md | 5 ++- ...inflight_variants.test.w_compile_tf-aws.md | 3 ++ ...apture_containers.test.w_compile_tf-aws.md | 5 ++- ...capture_in_binary.test.w_compile_tf-aws.md | 5 ++- ...gable_class_field.test.w_compile_tf-aws.md | 7 +++- ...ture_reassignable.test.w_compile_tf-aws.md | 5 ++- ..._with_no_inflight.test.w_compile_tf-aws.md | 5 ++- .../capture_tokens.test.w_compile_tf-aws.md | 5 ++- .../valid/captures.test.w_compile_tf-aws.md | 5 ++- .../valid/casting.test.w_compile_tf-aws.md | 9 +++-- .../valid/class.test.w_compile_tf-aws.md | 19 +++++----- .../closure_class.test.w_compile_tf-aws.md | 3 ++ .../deep_equality.test.w_compile_tf-aws.md | 5 +++ .../valid/enums.test.w_compile_tf-aws.md | 7 +++- ...ift_qualification.test.w_compile_tf-aws.md | 5 ++- .../extend_non_entrypoint.w_compile_tf-aws.md | 3 +- .../valid/for_loop.test.w_compile_tf-aws.md | 5 ++- .../forward_decl.test.w_compile_tf-aws.md | 3 ++ ...ptional_arguments.test.w_compile_tf-aws.md | 3 ++ ..._returns_function.test.w_compile_tf-aws.md | 5 ++- ...ariadic_arguments.test.w_compile_tf-aws.md | 5 ++- ...entical_inflights.test.w_compile_tf-aws.md | 3 ++ .../implicit_std.test.w_compile_tf-aws.md | 3 ++ ...n_scope_construct.test.w_compile_tf-aws.md | 5 ++- .../valid/inference.test.w_compile_tf-aws.md | 5 ++- ...ht_capture_static.test.w_compile_tf-aws.md | 8 +++- ...ass_capture_const.test.w_compile_tf-aws.md | 12 ++++-- ...class_definitions.test.w_compile_tf-aws.md | 21 +++++----- ..._inflight_closure.test.w_compile_tf-aws.md | 5 ++- ...t_class_modifiers.test.w_compile_tf-aws.md | 6 ++- ..._inflight_closure.test.w_compile_tf-aws.md | 12 ++++-- ..._interace_handler.test.w_compile_tf-aws.md | 8 +++- ...lass_without_init.test.w_compile_tf-aws.md | 8 +++- ...preflight_closure.test.w_compile_tf-aws.md | 3 ++ ...handler_singleton.test.w_compile_tf-aws.md | 17 +++++++-- ...calling_inflights.test.w_compile_tf-aws.md | 5 ++- .../valid/interface.test.w_compile_tf-aws.md | 3 ++ .../json_bucket.test.w_compile_tf-aws.md | 5 ++- .../json_static.test.w_compile_tf-aws.md | 7 ++-- ...ing_interpolation.test.w_compile_tf-aws.md | 3 ++ ...losure_collection.test.w_compile_tf-aws.md | 5 ++- ..._object_issue6501.test.w_compile_tf-aws.md | 11 +++++- .../valid/lift_this.test.w_compile_tf-aws.md | 5 ++- .../lift_via_closure.test.w_compile_tf-aws.md | 5 ++- .../new_in_static.test.w_compile_tf-aws.md | 15 +++++--- .../valid/new_jsii.test.w_compile_tf-aws.md | 5 ++- .../valid/nil.test.w_compile_tf-aws.md | 5 ++- .../parameters.test.w_compile_tf-aws.md | 3 ++ ...resource_captures.test.w_compile_tf-aws.md | 5 ++- ..._captures_globals.test.w_compile_tf-aws.md | 9 ++++- .../valid/shadowing.test.w_compile_tf-aws.md | 5 ++- .../statements_if.test.w_compile_tf-aws.md | 5 ++- .../valid/stringify.test.w_compile_tf-aws.md | 3 ++ .../valid/super_call.test.w_compile_tf-aws.md | 17 ++++++--- .../symbol_shadow.test.w_compile_tf-aws.md | 5 ++- .../test_bucket.test.w_compile_tf-aws.md | 5 ++- .../to_inflight.test.w_compile_tf-aws.md | 5 ++- .../website_with_api.test.w_compile_tf-aws.md | 15 +++++--- .../valid/while.test.w_compile_tf-aws.md | 3 ++ 72 files changed, 419 insertions(+), 168 deletions(-) diff --git a/tools/hangar/__snapshots__/invalid.ts.snap b/tools/hangar/__snapshots__/invalid.ts.snap index 88d90bf3025..a894bf95671 100644 --- a/tools/hangar/__snapshots__/invalid.ts.snap +++ b/tools/hangar/__snapshots__/invalid.ts.snap @@ -2571,13 +2571,6 @@ error: Cannot create preflight class \\"PreflightClass\\" in inflight phase | ^^^^^^^^^^^^^^^^^^^^ -error: Cannot qualify access to a lifted type \\"PreflightClass\\" (see https://github.com/winglang/wing/issues/76 for more details) - --> ../../../examples/tests/invalid/inflight_class_created_in_preflight.test.w:19:7 - | -19 | new PreflightClass(); - | ^^^^^^^^^^^^^^ - - Tests 1 failed (1) Snapshots 1 skipped @@ -3922,13 +3915,6 @@ exports[`resource_inflight.test.w 1`] = ` | ^^^^^^^^^^^^^^^^^^ -error: Cannot qualify access to a lifted type \\"Bucket\\" (see https://github.com/winglang/wing/issues/76 for more details) - --> ../../../examples/tests/invalid/resource_inflight.test.w:4:7 - | -4 | new cloud.Bucket(); // Should fail because we can't create resources inflight - | ^^^^^^^^^^^^ - - Tests 1 failed (1) Snapshots 1 skipped diff --git a/tools/hangar/__snapshots__/test_corpus/valid/anon_function.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/anon_function.test.w_compile_tf-aws.md index 870b3b37f1d..9acbf209fcd 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/anon_function.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/anon_function.test.w_compile_tf-aws.md @@ -55,6 +55,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/api.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/api.test.w_compile_tf-aws.md index d5bfda64839..aa1c46d1442 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/api.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/api.test.w_compile_tf-aws.md @@ -477,10 +477,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/api_cors_custom.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/api_cors_custom.test.w_compile_tf-aws.md index 5959041d4be..b763d5c4415 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/api_cors_custom.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/api_cors_custom.test.w_compile_tf-aws.md @@ -333,13 +333,16 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; -const ex = $stdlib.ex; -const http = $stdlib.http; -const expect = $stdlib.expect; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + const ex = $stdlib.ex; + const http = $stdlib.http; + const expect = $stdlib.expect; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -401,7 +404,7 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ - [$stdlib.core.toLiftableModuleType(expect.Util, "@winglang/sdk/expect", "Util"), ["equal", "nil"]], + [$stdlib.core.toLiftableModuleType(expect.Util, "@winglang/sdk/expect", "Util"), [].concat(["equal"], ["nil"])], [$stdlib.core.toLiftableModuleType(http.Util, "@winglang/sdk/http", "Util"), ["get"]], [api.url, []], ], @@ -443,7 +446,7 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ - [$stdlib.core.toLiftableModuleType(expect.Util, "@winglang/sdk/expect", "Util"), ["equal", "nil"]], + [$stdlib.core.toLiftableModuleType(expect.Util, "@winglang/sdk/expect", "Util"), [].concat(["equal"], ["nil"])], [$stdlib.core.toLiftableModuleType(http.HttpMethod, "@winglang/sdk/http", "HttpMethod"), ["OPTIONS"]], [$stdlib.core.toLiftableModuleType(http.Util, "@winglang/sdk/http", "Util"), ["fetch"]], [api.url, []], diff --git a/tools/hangar/__snapshots__/test_corpus/valid/api_cors_default.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/api_cors_default.test.w_compile_tf-aws.md index a3f083a4f27..77f388a4dd6 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/api_cors_default.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/api_cors_default.test.w_compile_tf-aws.md @@ -308,13 +308,16 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; -const ex = $stdlib.ex; -const http = $stdlib.http; -const expect = $stdlib.expect; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + const ex = $stdlib.ex; + const http = $stdlib.http; + const expect = $stdlib.expect; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -376,7 +379,7 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ - [$stdlib.core.toLiftableModuleType(expect.Util, "@winglang/sdk/expect", "Util"), ["equal", "nil"]], + [$stdlib.core.toLiftableModuleType(expect.Util, "@winglang/sdk/expect", "Util"), [].concat(["equal"], ["nil"])], [$stdlib.core.toLiftableModuleType(http.Util, "@winglang/sdk/http", "Util"), ["get"]], [apiDefaultCors.url, []], ], @@ -418,7 +421,7 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ - [$stdlib.core.toLiftableModuleType(expect.Util, "@winglang/sdk/expect", "Util"), ["equal", "nil"]], + [$stdlib.core.toLiftableModuleType(expect.Util, "@winglang/sdk/expect", "Util"), [].concat(["equal"], ["nil"])], [$stdlib.core.toLiftableModuleType(http.HttpMethod, "@winglang/sdk/http", "HttpMethod"), ["OPTIONS"]], [$stdlib.core.toLiftableModuleType(http.Util, "@winglang/sdk/http", "Util"), ["fetch"]], [apiDefaultCors.url, []], diff --git a/tools/hangar/__snapshots__/test_corpus/valid/baz.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/baz.w_compile_tf-aws.md index 806f0755f05..0bef77200bc 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/baz.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/baz.w_compile_tf-aws.md @@ -21,6 +21,7 @@ const $stdlib = require('@winglang/sdk'); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); +let $preflightTypesMap = {}; class Baz extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); @@ -52,7 +53,7 @@ class Baz extends $stdlib.std.Resource { }); } } -module.exports = { Baz }; +module.exports = { $preflightTypesMap, Baz }; //# sourceMappingURL=preflight.cjs.map ``` diff --git a/tools/hangar/__snapshots__/test_corpus/valid/bring_alias.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/bring_alias.test.w_compile_tf-aws.md index 2ddcec22ea9..5d861328240 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/bring_alias.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/bring_alias.test.w_compile_tf-aws.md @@ -29,11 +29,14 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const stdFs = $stdlib.fs; -const stdFs2 = $stdlib.fs; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const stdFs = $stdlib.fs; + const stdFs2 = $stdlib.fs; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; $helpers.assert($helpers.eq((stdFs.Util.dirname("/")), "/"), "stdFs.dirname(\"/\") == \"/\""); $helpers.assert($helpers.eq((stdFs2.Util.dirname("/")), "/"), "stdFs2.dirname(\"/\") == \"/\""); } diff --git a/tools/hangar/__snapshots__/test_corpus/valid/bring_extend_non_entry.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/bring_extend_non_entry.test.w_compile_tf-aws.md index 4c65ccbc197..08321f3d3dd 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/bring_extend_non_entry.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/bring_extend_non_entry.test.w_compile_tf-aws.md @@ -44,10 +44,14 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const lib = require("./preflight.extendnonentrypoint-1.cjs"); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const lib = require("./preflight.extendnonentrypoint-1.cjs"); + Object.assign($preflightTypesMap, lib.$preflightTypesMap); + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; const f = new lib.Foo(this, "Foo"); } } @@ -64,6 +68,7 @@ const $stdlib = require('@winglang/sdk'); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); +let $preflightTypesMap = {}; const cdk8s = require("cdk8s"); class Foo extends (this?.node?.root?.typeForFqn("cdk8s.Chart") ?? cdk8s.Chart) { constructor($scope, $id, ) { @@ -94,7 +99,7 @@ class Foo extends (this?.node?.root?.typeForFqn("cdk8s.Chart") ?? cdk8s.Chart) { }); } } -module.exports = { Foo }; +module.exports = { $preflightTypesMap, Foo }; //# sourceMappingURL=preflight.extendnonentrypoint-1.cjs.map ``` diff --git a/tools/hangar/__snapshots__/test_corpus/valid/bring_local.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/bring_local.test.w_compile_tf-aws.md index 57561d5972f..247bb29336c 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/bring_local.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/bring_local.test.w_compile_tf-aws.md @@ -298,14 +298,20 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const file1 = require("./preflight.store-2.cjs"); -const file2 = require("./preflight.subfile-3.cjs"); -const file3 = require("./preflight.empty-1.cjs"); -const math = $stdlib.math; -const expect = $stdlib.expect; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const file1 = require("./preflight.store-2.cjs"); + Object.assign($preflightTypesMap, file1.$preflightTypesMap); + const file2 = require("./preflight.subfile-3.cjs"); + Object.assign($preflightTypesMap, file2.$preflightTypesMap); + const file3 = require("./preflight.empty-1.cjs"); + Object.assign($preflightTypesMap, file3.$preflightTypesMap); + const math = $stdlib.math; + const expect = $stdlib.expect; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -369,9 +375,11 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$stdlib.core.toLiftableModuleType(expect.Util, "@winglang/sdk/expect", "Util"), ["equal"]], [$stdlib.core.toLiftableModuleType(file2.Q, "", "Q"), ["greet"]], ], "$inflight_init": [ + [$stdlib.core.toLiftableModuleType(expect.Util, "@winglang/sdk/expect", "Util"), []], [$stdlib.core.toLiftableModuleType(file2.Q, "", "Q"), []], ], }); @@ -460,7 +468,8 @@ const $stdlib = require('@winglang/sdk'); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -module.exports = { }; +let $preflightTypesMap = {}; +module.exports = { $preflightTypesMap, }; //# sourceMappingURL=preflight.empty-1.cjs.map ``` @@ -471,7 +480,9 @@ const $stdlib = require('@winglang/sdk'); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); +let $preflightTypesMap = {}; const file3 = require("./preflight.empty-1.cjs"); +Object.assign($preflightTypesMap, file3.$preflightTypesMap); const math = $stdlib.math; const cloud = $stdlib.cloud; const Color = @@ -581,7 +592,7 @@ class Store extends $stdlib.std.Resource { }); } } -module.exports = { Util, Store, Color }; +module.exports = { $preflightTypesMap, Util, Store, Color }; //# sourceMappingURL=preflight.store-2.cjs.map ``` @@ -592,6 +603,7 @@ const $stdlib = require('@winglang/sdk'); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); +let $preflightTypesMap = {}; const math = $stdlib.math; class Q extends $stdlib.std.Resource { constructor($scope, $id, ) { @@ -630,7 +642,7 @@ class Q extends $stdlib.std.Resource { }); } } -module.exports = { Q }; +module.exports = { $preflightTypesMap, Q }; //# sourceMappingURL=preflight.subfile-3.cjs.map ``` diff --git a/tools/hangar/__snapshots__/test_corpus/valid/bring_local_dir.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/bring_local_dir.test.w_compile_tf-aws.md index 60c18b17f6a..82239172082 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/bring_local_dir.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/bring_local_dir.test.w_compile_tf-aws.md @@ -85,11 +85,16 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const w = require("./preflight.widget-1.cjs"); -const subdir = require("./preflight.subdir2-5.cjs"); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const w = require("./preflight.widget-1.cjs"); + Object.assign($preflightTypesMap, w.$preflightTypesMap); + const subdir = require("./preflight.subdir2-5.cjs"); + Object.assign($preflightTypesMap, subdir.$preflightTypesMap); + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; const widget1 = new w.Widget(this, "widget1"); $helpers.assert($helpers.eq((widget1.compute()), 42), "widget1.compute() == 42"); const foo = new subdir.Foo(this, "Foo"); @@ -114,7 +119,9 @@ const $stdlib = require('@winglang/sdk'); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); +let $preflightTypesMap = {}; const blah = require("./preflight.inner-2.cjs"); +Object.assign($preflightTypesMap, blah.$preflightTypesMap); const cloud = $stdlib.cloud; const util = $stdlib.util; class Foo extends $stdlib.std.Resource { @@ -151,7 +158,7 @@ class Foo extends $stdlib.std.Resource { }); } } -module.exports = { Foo }; +module.exports = { $preflightTypesMap, Foo }; //# sourceMappingURL=preflight.file1-3.cjs.map ``` @@ -162,6 +169,7 @@ const $stdlib = require('@winglang/sdk'); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); +let $preflightTypesMap = {}; const util = $stdlib.util; class Bar extends $stdlib.std.Resource { constructor($scope, $id, ) { @@ -223,7 +231,7 @@ class Foo extends $stdlib.std.Resource { }); } } -module.exports = { Bar }; +module.exports = { $preflightTypesMap, Bar }; //# sourceMappingURL=preflight.file2-4.cjs.map ``` @@ -234,9 +242,9 @@ const $stdlib = require('@winglang/sdk'); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -module.exports = { - ...require("./preflight.widget-1.cjs"), -}; +let $preflightTypesMap = {}; +Object.assign(module.exports, $helpers.bringJs(`${__dirname}/preflight.widget-1.cjs`, "$preflightTypesMap", $preflightTypesMap)); +module.exports = { ...module.exports, $preflightTypesMap }; //# sourceMappingURL=preflight.inner-2.cjs.map ``` @@ -247,11 +255,11 @@ const $stdlib = require('@winglang/sdk'); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -module.exports = { - get inner() { return require("./preflight.inner-2.cjs") }, - ...require("./preflight.file2-4.cjs"), - ...require("./preflight.file1-3.cjs"), -}; +let $preflightTypesMap = {}; +Object.assign(module.exports, { get inner() { return $helpers.bringJs(`${__dirname}/preflight.inner-2.cjs`, "$preflightTypesMap", $preflightTypesMap); } }); +Object.assign(module.exports, $helpers.bringJs(`${__dirname}/preflight.file2-4.cjs`, "$preflightTypesMap", $preflightTypesMap)); +Object.assign(module.exports, $helpers.bringJs(`${__dirname}/preflight.file1-3.cjs`, "$preflightTypesMap", $preflightTypesMap)); +module.exports = { ...module.exports, $preflightTypesMap }; //# sourceMappingURL=preflight.subdir2-5.cjs.map ``` @@ -262,6 +270,7 @@ const $stdlib = require('@winglang/sdk'); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); +let $preflightTypesMap = {}; class Widget extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); @@ -296,7 +305,7 @@ class Widget extends $stdlib.std.Resource { }); } } -module.exports = { Widget }; +module.exports = { $preflightTypesMap, Widget }; //# sourceMappingURL=preflight.widget-1.cjs.map ``` diff --git a/tools/hangar/__snapshots__/test_corpus/valid/bring_local_normalization.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/bring_local_normalization.test.w_compile_tf-aws.md index 9a8d4a73c93..cd23b19159d 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/bring_local_normalization.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/bring_local_normalization.test.w_compile_tf-aws.md @@ -68,6 +68,7 @@ const $stdlib = require('@winglang/sdk'); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); +let $preflightTypesMap = {}; class Bar extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); @@ -102,7 +103,7 @@ class Bar extends $stdlib.std.Resource { }); } } -module.exports = { Bar }; +module.exports = { $preflightTypesMap, Bar }; //# sourceMappingURL=preflight.bar-1.cjs.map ``` @@ -113,6 +114,7 @@ const $stdlib = require('@winglang/sdk'); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); +let $preflightTypesMap = {}; class Baz extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); @@ -144,7 +146,7 @@ class Baz extends $stdlib.std.Resource { }); } } -module.exports = { Baz }; +module.exports = { $preflightTypesMap, Baz }; //# sourceMappingURL=preflight.baz-2.cjs.map ``` @@ -158,12 +160,18 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const foo = require("./preflight.foo-3.cjs"); -const bar = require("./preflight.bar-1.cjs"); -const baz = require("./preflight.baz-2.cjs"); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const foo = require("./preflight.foo-3.cjs"); + Object.assign($preflightTypesMap, foo.$preflightTypesMap); + const bar = require("./preflight.bar-1.cjs"); + Object.assign($preflightTypesMap, bar.$preflightTypesMap); + const baz = require("./preflight.baz-2.cjs"); + Object.assign($preflightTypesMap, baz.$preflightTypesMap); + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; $helpers.assert($helpers.eq((foo.Foo.foo(this)), "foo"), "foo.Foo.foo() == \"foo\""); $helpers.assert($helpers.eq((foo.Foo.bar(this)), "bar"), "foo.Foo.bar() == \"bar\""); $helpers.assert($helpers.eq((foo.Foo.baz(this)), "baz"), "foo.Foo.baz() == \"baz\""); @@ -184,8 +192,11 @@ const $stdlib = require('@winglang/sdk'); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); +let $preflightTypesMap = {}; const bar = require("./preflight.bar-1.cjs"); +Object.assign($preflightTypesMap, bar.$preflightTypesMap); const baz = require("./preflight.baz-2.cjs"); +Object.assign($preflightTypesMap, baz.$preflightTypesMap); class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); @@ -223,7 +234,7 @@ class Foo extends $stdlib.std.Resource { }); } } -module.exports = { Foo }; +module.exports = { $preflightTypesMap, Foo }; //# sourceMappingURL=preflight.foo-3.cjs.map ``` diff --git a/tools/hangar/__snapshots__/test_corpus/valid/bring_projen.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/bring_projen.test.w_compile_tf-aws.md index 2ac6ea6ecac..71fc383a671 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/bring_projen.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/bring_projen.test.w_compile_tf-aws.md @@ -29,10 +29,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const projen = require("projen"); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const projen = require("projen"); + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; $helpers.assert($helpers.neq(projen.LogLevel.OFF, projen.LogLevel.VERBOSE), "projen.LogLevel.OFF != projen.LogLevel.VERBOSE"); } } diff --git a/tools/hangar/__snapshots__/test_corpus/valid/bring_wing_library.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/bring_wing_library.test.w_compile_tf-aws.md index b7fc78e23b0..0fb30a163d7 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/bring_wing_library.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/bring_wing_library.test.w_compile_tf-aws.md @@ -108,12 +108,18 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const fixture = require("./preflight.testfixture-5.cjs"); -const testfixture = require("./preflight.testfixture-5.cjs"); -const testfixture2 = require("./preflight.testfixture-5.cjs"); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const fixture = require("./preflight.testfixture-5.cjs"); + Object.assign($preflightTypesMap, fixture.$preflightTypesMap); + const testfixture = require("./preflight.testfixture-5.cjs"); + Object.assign($preflightTypesMap, testfixture.$preflightTypesMap); + const testfixture2 = require("./preflight.testfixture-5.cjs"); + Object.assign($preflightTypesMap, testfixture2.$preflightTypesMap); + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -170,6 +176,7 @@ const $stdlib = require('@winglang/sdk'); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); +let $preflightTypesMap = {}; const FavoriteNumbers = (function (tmp) { tmp["SEVEN"] = "SEVEN"; @@ -177,7 +184,7 @@ const FavoriteNumbers = return tmp; })({}) ; -module.exports = { FavoriteNumbers }; +module.exports = { $preflightTypesMap, FavoriteNumbers }; //# sourceMappingURL=preflight.enums-1.cjs.map ``` @@ -188,8 +195,10 @@ const $stdlib = require('@winglang/sdk'); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); +let $preflightTypesMap = {}; const cloud = $stdlib.cloud; const myutil = require("./preflight.util-2.cjs"); +Object.assign($preflightTypesMap, myutil.$preflightTypesMap); class Store extends $stdlib.std.Resource { constructor($scope, $id, options) { super($scope, $id); @@ -243,7 +252,7 @@ class Store extends $stdlib.std.Resource { }); } } -module.exports = { Store }; +module.exports = { $preflightTypesMap, Store }; //# sourceMappingURL=preflight.store-3.cjs.map ``` @@ -254,9 +263,9 @@ const $stdlib = require('@winglang/sdk'); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -module.exports = { - ...require("./preflight.util-2.cjs"), -}; +let $preflightTypesMap = {}; +Object.assign(module.exports, $helpers.bringJs(`${__dirname}/preflight.util-2.cjs`, "$preflightTypesMap", $preflightTypesMap)); +module.exports = { ...module.exports, $preflightTypesMap }; //# sourceMappingURL=preflight.subdir-4.cjs.map ``` @@ -267,11 +276,11 @@ const $stdlib = require('@winglang/sdk'); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -module.exports = { - get subdir() { return require("./preflight.subdir-4.cjs") }, - ...require("./preflight.store-3.cjs"), - ...require("./preflight.enums-1.cjs"), -}; +let $preflightTypesMap = {}; +Object.assign(module.exports, { get subdir() { return $helpers.bringJs(`${__dirname}/preflight.subdir-4.cjs`, "$preflightTypesMap", $preflightTypesMap); } }); +Object.assign(module.exports, $helpers.bringJs(`${__dirname}/preflight.store-3.cjs`, "$preflightTypesMap", $preflightTypesMap)); +Object.assign(module.exports, $helpers.bringJs(`${__dirname}/preflight.enums-1.cjs`, "$preflightTypesMap", $preflightTypesMap)); +module.exports = { ...module.exports, $preflightTypesMap }; //# sourceMappingURL=preflight.testfixture-5.cjs.map ``` @@ -282,6 +291,7 @@ const $stdlib = require('@winglang/sdk'); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); +let $preflightTypesMap = {}; class Util extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); @@ -318,7 +328,7 @@ class Util extends $stdlib.std.Resource { }); } } -module.exports = { Util }; +module.exports = { $preflightTypesMap, Util }; //# sourceMappingURL=preflight.util-2.cjs.map ``` diff --git a/tools/hangar/__snapshots__/test_corpus/valid/bucket_keys.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/bucket_keys.test.w_compile_tf-aws.md index 78bf0995b95..834155632e5 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/bucket_keys.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/bucket_keys.test.w_compile_tf-aws.md @@ -73,10 +73,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/calling_inflight_variants.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/calling_inflight_variants.test.w_compile_tf-aws.md index 695224e3999..2c2a5a2730b 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/calling_inflight_variants.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/calling_inflight_variants.test.w_compile_tf-aws.md @@ -114,6 +114,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/capture_containers.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/capture_containers.test.w_compile_tf-aws.md index f7477a1faef..826e1f56382 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/capture_containers.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/capture_containers.test.w_compile_tf-aws.md @@ -57,10 +57,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/capture_in_binary.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/capture_in_binary.test.w_compile_tf-aws.md index 91071782782..3b9763f9c72 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/capture_in_binary.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/capture_in_binary.test.w_compile_tf-aws.md @@ -65,10 +65,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/capture_reassigable_class_field.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/capture_reassigable_class_field.test.w_compile_tf-aws.md index a02baadf06c..8ffac63415f 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/capture_reassigable_class_field.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/capture_reassigable_class_field.test.w_compile_tf-aws.md @@ -154,11 +154,14 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; -const util = $stdlib.util; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + const util = $stdlib.util; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class KeyValueStore extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/capture_reassignable.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/capture_reassignable.test.w_compile_tf-aws.md index 45dfc0c4221..956c80c929a 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/capture_reassignable.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/capture_reassignable.test.w_compile_tf-aws.md @@ -69,10 +69,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/capture_resource_with_no_inflight.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/capture_resource_with_no_inflight.test.w_compile_tf-aws.md index d763246da9a..6f0efec4a0c 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/capture_resource_with_no_inflight.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/capture_resource_with_no_inflight.test.w_compile_tf-aws.md @@ -91,10 +91,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class A extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/capture_tokens.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/capture_tokens.test.w_compile_tf-aws.md index 12ec3390d08..fd71731868a 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/capture_tokens.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/capture_tokens.test.w_compile_tf-aws.md @@ -228,10 +228,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class MyResource extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/captures.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/captures.test.w_compile_tf-aws.md index 01ee869a182..ce125dc8d21 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/captures.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/captures.test.w_compile_tf-aws.md @@ -649,10 +649,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/casting.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/casting.test.w_compile_tf-aws.md index b07df3480fe..18a5f93fcbe 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/casting.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/casting.test.w_compile_tf-aws.md @@ -48,12 +48,15 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; -const util = $stdlib.util; -const aws = require("@cdktf/provider-aws"); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + const util = $stdlib.util; + const aws = require("@cdktf/provider-aws"); + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; const b = this.node.root.new("@winglang/sdk.cloud.Bucket", cloud.Bucket, this, "Bucket"); if ($helpers.eq((util.Util.env("WING_TARGET")), "tf-aws")) { const s3Bucket = (b.node.findChild("Default")); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/class.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/class.test.w_compile_tf-aws.md index 1d0faffe411..bd8f09c2008 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/class.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/class.test.w_compile_tf-aws.md @@ -529,10 +529,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class C1 extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); @@ -1154,7 +1157,8 @@ class $Root extends $stdlib.std.Resource { }); } } - const $A_12 = new A(this, "$A_12"); + if ($preflightTypesMap[19]) { throw new Error("A is already in type map"); } + $preflightTypesMap[19] = A; class B extends A { constructor($scope, $id, ) { super($scope, $id); @@ -1184,12 +1188,9 @@ class $Root extends $stdlib.std.Resource { }); } } -<<<<<<< HEAD - const $B_13 = new B(this, "$B_13"); - class $Closure4 extends $stdlib.std.AutoIdResource { -======= + if ($preflightTypesMap[20]) { throw new Error("B is already in type map"); } + $preflightTypesMap[20] = B; class $Closure5 extends $stdlib.std.AutoIdResource { ->>>>>>> main _id = $stdlib.core.closureId(); constructor($scope, $id, ) { super($scope, $id); @@ -1216,11 +1217,11 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ - [$B_13, ["sound"]], + [$helpers.nodeof(this).root.$preflightTypesMap[20]._singleton(this,"B_singleton_20"), ["sound"]], [B, []], ], "$inflight_init": [ - [$B_13, []], + [$helpers.nodeof(this).root.$preflightTypesMap[20]._singleton(this,"B_singleton_20"), []], [B, []], ], }); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/closure_class.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/closure_class.test.w_compile_tf-aws.md index a979018aad0..5b0238a159a 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/closure_class.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/closure_class.test.w_compile_tf-aws.md @@ -76,6 +76,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class MyClosure extends $stdlib.std.Resource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/deep_equality.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/deep_equality.test.w_compile_tf-aws.md index 812670d01cf..a74c11bf3b0 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/deep_equality.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/deep_equality.test.w_compile_tf-aws.md @@ -307,6 +307,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -501,8 +504,10 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$stdlib.core.toLiftableModuleType(std.Json, "@winglang/sdk/std", "Json"), ["values"]], ], "$inflight_init": [ + [$stdlib.core.toLiftableModuleType(std.Json, "@winglang/sdk/std", "Json"), []], ], }); } diff --git a/tools/hangar/__snapshots__/test_corpus/valid/enums.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/enums.test.w_compile_tf-aws.md index d30a7a3aaec..287bf7d8cfb 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/enums.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/enums.test.w_compile_tf-aws.md @@ -75,6 +75,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; const SomeEnum = (function (tmp) { tmp["ONE"] = "ONE"; @@ -118,7 +121,7 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ - [SomeEnum, ["ONE", "TWO"]], + [SomeEnum, [].concat(["ONE"], ["TWO"])], [one, []], [two, []], ], @@ -157,8 +160,10 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [SomeEnum, [].concat(["ONE"], ["TWO"], ["THREE"])], ], "$inflight_init": [ + [SomeEnum, []], ], }); } diff --git a/tools/hangar/__snapshots__/test_corpus/valid/explicit_lift_qualification.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/explicit_lift_qualification.test.w_compile_tf-aws.md index ba3a676f207..87013158485 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/explicit_lift_qualification.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/explicit_lift_qualification.test.w_compile_tf-aws.md @@ -214,10 +214,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/extend_non_entrypoint.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/extend_non_entrypoint.w_compile_tf-aws.md index 794ec04a576..8bf44dfdc83 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/extend_non_entrypoint.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/extend_non_entrypoint.w_compile_tf-aws.md @@ -22,6 +22,7 @@ const $stdlib = require('@winglang/sdk'); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); +let $preflightTypesMap = {}; const cdk8s = require("cdk8s"); class Foo extends (this?.node?.root?.typeForFqn("cdk8s.Chart") ?? cdk8s.Chart) { constructor($scope, $id, ) { @@ -52,7 +53,7 @@ class Foo extends (this?.node?.root?.typeForFqn("cdk8s.Chart") ?? cdk8s.Chart) { }); } } -module.exports = { Foo }; +module.exports = { $preflightTypesMap, Foo }; //# sourceMappingURL=preflight.cjs.map ``` diff --git a/tools/hangar/__snapshots__/test_corpus/valid/for_loop.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/for_loop.test.w_compile_tf-aws.md index 133f07c0354..90c26c479c3 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/for_loop.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/for_loop.test.w_compile_tf-aws.md @@ -178,10 +178,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/forward_decl.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/forward_decl.test.w_compile_tf-aws.md index f942377bb06..b571dd9b296 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/forward_decl.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/forward_decl.test.w_compile_tf-aws.md @@ -46,6 +46,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class R extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/function_optional_arguments.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/function_optional_arguments.test.w_compile_tf-aws.md index 1c62e45a42f..6e9235e9ebf 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/function_optional_arguments.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/function_optional_arguments.test.w_compile_tf-aws.md @@ -46,6 +46,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/function_returns_function.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/function_returns_function.test.w_compile_tf-aws.md index 9d84ab99e3f..e07fb939c6c 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/function_returns_function.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/function_returns_function.test.w_compile_tf-aws.md @@ -57,10 +57,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/function_variadic_arguments.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/function_variadic_arguments.test.w_compile_tf-aws.md index 9bf1fe73cf0..0d2bcd716e3 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/function_variadic_arguments.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/function_variadic_arguments.test.w_compile_tf-aws.md @@ -92,10 +92,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class A extends $stdlib.std.Resource { constructor($scope, $id, msg) { super($scope, $id); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/identical_inflights.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/identical_inflights.test.w_compile_tf-aws.md index a354c770c40..1d7b36a016c 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/identical_inflights.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/identical_inflights.test.w_compile_tf-aws.md @@ -70,6 +70,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/implicit_std.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/implicit_std.test.w_compile_tf-aws.md index 3086f935883..faab0b83ca0 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/implicit_std.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/implicit_std.test.w_compile_tf-aws.md @@ -32,6 +32,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; const d = (std.Duration.fromMinutes(5)); const n = ((args) => { if (isNaN(args)) {throw new Error("unable to parse \"" + args + "\" as a number")}; return Number(args) })("12"); $helpers.assert($helpers.eq(d.seconds, (5 * 60)), "d.seconds == 5 * 60"); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/in_scope_construct.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/in_scope_construct.test.w_compile_tf-aws.md index 8ae55982b3c..eacbcf08a5e 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/in_scope_construct.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/in_scope_construct.test.w_compile_tf-aws.md @@ -43,10 +43,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const c = require("constructs"); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const c = require("constructs"); + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class MyClass extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inference.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inference.test.w_compile_tf-aws.md index ed9ebd76926..352a554bd50 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inference.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inference.test.w_compile_tf-aws.md @@ -254,10 +254,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight_capture_static.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight_capture_static.test.w_compile_tf-aws.md index 2c497481b5a..e0b5a62dcc6 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight_capture_static.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight_capture_static.test.w_compile_tf-aws.md @@ -155,10 +155,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const util = $stdlib.util; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const util = $stdlib.util; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Preflight extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); @@ -227,7 +230,8 @@ class $Root extends $stdlib.std.Resource { }); } } - const $OuterInflight_1 = new OuterInflight(this, "$OuterInflight_1"); + if ($preflightTypesMap[1]) { throw new Error("OuterInflight is already in type map"); } + $preflightTypesMap[1] = OuterInflight; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_capture_const.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_capture_const.test.w_compile_tf-aws.md index fda6f25bca4..09ab5eeb98c 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_capture_const.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_capture_const.test.w_compile_tf-aws.md @@ -65,10 +65,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); @@ -102,7 +105,8 @@ class $Root extends $stdlib.std.Resource { }); } } - const $Foo_0 = new Foo(this, "$Foo_0"); + if ($preflightTypesMap[0]) { throw new Error("Foo is already in type map"); } + $preflightTypesMap[0] = Foo; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -131,12 +135,12 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ - [$Foo_0, ["getValue"]], + [$helpers.nodeof(this).root.$preflightTypesMap[0]._singleton(this,"Foo_singleton_0"), ["getValue"]], [Foo, []], [myConst, []], ], "$inflight_init": [ - [$Foo_0, []], + [$helpers.nodeof(this).root.$preflightTypesMap[0]._singleton(this,"Foo_singleton_0"), []], [Foo, []], [myConst, []], ], diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_definitions.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_definitions.test.w_compile_tf-aws.md index c013b087143..da914c7dadf 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_definitions.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_definitions.test.w_compile_tf-aws.md @@ -182,6 +182,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class A extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); @@ -245,7 +248,8 @@ class $Root extends $stdlib.std.Resource { }); } } - const $B_1 = new B(this, "$B_1"); + if ($preflightTypesMap[1]) { throw new Error("B is already in type map"); } + $preflightTypesMap[1] = B; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -344,11 +348,8 @@ class $Root extends $stdlib.std.Resource { }); } } -<<<<<<< HEAD - const $F_7 = new F(this, "$F_7"); - const __parent_this_2 = this; -======= ->>>>>>> main + if ($preflightTypesMap[7]) { throw new Error("F is already in type map"); } + $preflightTypesMap[7] = F; class $Closure2 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -376,11 +377,11 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ - [$F_7, ["foo"]], + [$helpers.nodeof(this).root.$preflightTypesMap[7]._singleton(this,"F_singleton_7"), ["foo"]], [F, ["foo"]], ], "$inflight_init": [ - [$F_7, []], + [$helpers.nodeof(this).root.$preflightTypesMap[7]._singleton(this,"F_singleton_7"), []], [F, []], ], }); @@ -451,7 +452,7 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ - [$B_1, ["foo"]], + [$helpers.nodeof(this).root.$preflightTypesMap[1]._singleton(this,"B_singleton_1"), ["foo"]], [B, []], [a, ["goo"]], [d, ["callInner"]], @@ -459,7 +460,7 @@ class $Root extends $stdlib.std.Resource { [innerD, ["handle"]], ], "$inflight_init": [ - [$B_1, []], + [$helpers.nodeof(this).root.$preflightTypesMap[1]._singleton(this,"B_singleton_1"), []], [B, []], [a, []], [d, []], diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_inside_inflight_closure.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_inside_inflight_closure.test.w_compile_tf-aws.md index a4590c97062..4c71fc2d803 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_inside_inflight_closure.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_inside_inflight_closure.test.w_compile_tf-aws.md @@ -240,10 +240,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class PreflightClass extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_modifiers.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_modifiers.test.w_compile_tf-aws.md index 67e9e621292..7e344980f01 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_modifiers.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_modifiers.test.w_compile_tf-aws.md @@ -51,6 +51,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class C extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); @@ -84,7 +87,8 @@ class $Root extends $stdlib.std.Resource { }); } } - const $C_0 = new C(this, "$C_0"); + if ($preflightTypesMap[0]) { throw new Error("C is already in type map"); } + $preflightTypesMap[0] = C; } } const $PlatformManager = new $stdlib.platform.PlatformManager({platformPaths: $platforms}); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_outside_inflight_closure.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_outside_inflight_closure.test.w_compile_tf-aws.md index 40b36eb2b8e..f38ba917abc 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_outside_inflight_closure.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_outside_inflight_closure.test.w_compile_tf-aws.md @@ -71,10 +71,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class BinaryOperation extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); @@ -111,7 +114,8 @@ class $Root extends $stdlib.std.Resource { }); } } - const $BinaryOperation_0 = new BinaryOperation(this, "$BinaryOperation_0"); + if ($preflightTypesMap[0]) { throw new Error("BinaryOperation is already in type map"); } + $preflightTypesMap[0] = BinaryOperation; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -139,11 +143,11 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ - [$BinaryOperation_0, ["add"]], + [$helpers.nodeof(this).root.$preflightTypesMap[0]._singleton(this,"BinaryOperation_singleton_0"), ["add"]], [BinaryOperation, []], ], "$inflight_init": [ - [$BinaryOperation_0, []], + [$helpers.nodeof(this).root.$preflightTypesMap[0]._singleton(this,"BinaryOperation_singleton_0"), []], [BinaryOperation, []], ], }); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_structural_interace_handler.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_structural_interace_handler.test.w_compile_tf-aws.md index e9d9f0eff05..9b7b109ab09 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_structural_interace_handler.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_structural_interace_handler.test.w_compile_tf-aws.md @@ -75,10 +75,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class NotGoo extends $stdlib.std.Resource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -110,7 +113,8 @@ class $Root extends $stdlib.std.Resource { }); } } - const $NotGoo_0 = new NotGoo(this, "$NotGoo_0"); + if ($preflightTypesMap[0]) { throw new Error("NotGoo is already in type map"); } + $preflightTypesMap[0] = NotGoo; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_without_init.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_without_init.test.w_compile_tf-aws.md index d7feec803cb..0978d2094df 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_without_init.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_without_init.test.w_compile_tf-aws.md @@ -61,10 +61,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); @@ -93,7 +96,8 @@ class $Root extends $stdlib.std.Resource { }); } } - const $Foo_0 = new Foo(this, "$Foo_0"); + if ($preflightTypesMap[0]) { throw new Error("Foo is already in type map"); } + $preflightTypesMap[0] = Foo; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight_closure_inside_preflight_closure.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight_closure_inside_preflight_closure.test.w_compile_tf-aws.md index cb6d209f39c..be4a110b28c 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight_closure_inside_preflight_closure.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight_closure_inside_preflight_closure.test.w_compile_tf-aws.md @@ -65,6 +65,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight_handler_singleton.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight_handler_singleton.test.w_compile_tf-aws.md index 12f4cc33be3..87055bb700c 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight_handler_singleton.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight_handler_singleton.test.w_compile_tf-aws.md @@ -435,12 +435,15 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; -const expect = $stdlib.expect; -const util = $stdlib.util; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + const expect = $stdlib.expect; + const util = $stdlib.util; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); @@ -618,9 +621,13 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$stdlib.core.toLiftableModuleType(std.Duration, "@winglang/sdk/std", "Duration"), ["fromSeconds"]], + [$stdlib.core.toLiftableModuleType(util.Util, "@winglang/sdk/util", "Util"), ["sleep"]], [foo, [].concat(["inc"], ["get"])], ], "$inflight_init": [ + [$stdlib.core.toLiftableModuleType(std.Duration, "@winglang/sdk/std", "Duration"), []], + [$stdlib.core.toLiftableModuleType(util.Util, "@winglang/sdk/util", "Util"), []], [foo, []], ], }); @@ -655,9 +662,13 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$stdlib.core.toLiftableModuleType(std.Duration, "@winglang/sdk/std", "Duration"), ["fromSeconds"]], + [$stdlib.core.toLiftableModuleType(util.Util, "@winglang/sdk/util", "Util"), ["sleep"]], [fn3, [].concat(["invokeAsync"], ["invoke"])], ], "$inflight_init": [ + [$stdlib.core.toLiftableModuleType(std.Duration, "@winglang/sdk/std", "Duration"), []], + [$stdlib.core.toLiftableModuleType(util.Util, "@winglang/sdk/util", "Util"), []], [fn3, []], ], }); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflights_calling_inflights.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflights_calling_inflights.test.w_compile_tf-aws.md index ef201514841..4754a338f30 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflights_calling_inflights.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflights_calling_inflights.test.w_compile_tf-aws.md @@ -273,10 +273,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/interface.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/interface.test.w_compile_tf-aws.md index 2df8723afdf..5594d473900 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/interface.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/interface.test.w_compile_tf-aws.md @@ -60,6 +60,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class C extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/json_bucket.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/json_bucket.test.w_compile_tf-aws.md index 180a6a15dbe..93bf3789abb 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/json_bucket.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/json_bucket.test.w_compile_tf-aws.md @@ -188,10 +188,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/json_static.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/json_static.test.w_compile_tf-aws.md index 039855d73db..86beb686cd9 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/json_static.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/json_static.test.w_compile_tf-aws.md @@ -72,10 +72,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -140,10 +143,8 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ - [$stdlib.core.toLiftableModuleType(std.Json, "@winglang/sdk/std", "Json"), ["has"]], ], "$inflight_init": [ - [$stdlib.core.toLiftableModuleType(std.Json, "@winglang/sdk/std", "Json"), []], ], }); } diff --git a/tools/hangar/__snapshots__/test_corpus/valid/json_string_interpolation.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/json_string_interpolation.test.w_compile_tf-aws.md index 7dfc3aa272d..c6a0bf5c71b 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/json_string_interpolation.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/json_string_interpolation.test.w_compile_tf-aws.md @@ -32,6 +32,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; const obj = ({"strValue": "test", "numValue": 1}); const notStringifyStrValue = String.raw({ raw: ["string: ", ""] }, JSON.stringify(((obj, args) => { if (obj[args] === undefined) throw new Error(`Json property "${args}" does not exist`); return obj[args] })(obj, "strValue"))); $helpers.assert($helpers.eq(notStringifyStrValue, "string: \"test\""), "notStringifyStrValue == \"string: \\\"test\\\"\""); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/lift_inflight_closure_collection.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/lift_inflight_closure_collection.test.w_compile_tf-aws.md index 18db0e302fc..2d4181c8702 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/lift_inflight_closure_collection.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/lift_inflight_closure_collection.test.w_compile_tf-aws.md @@ -638,10 +638,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/lift_inflight_closure_returning_object_issue6501.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/lift_inflight_closure_returning_object_issue6501.test.w_compile_tf-aws.md index 0e22d0f29a0..9b1705a1863 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/lift_inflight_closure_returning_object_issue6501.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/lift_inflight_closure_returning_object_issue6501.test.w_compile_tf-aws.md @@ -141,10 +141,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); @@ -175,6 +178,8 @@ class $Root extends $stdlib.std.Resource { }); } } + if ($preflightTypesMap[0]) { throw new Error("Foo is already in type map"); } + $preflightTypesMap[0] = Foo; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -202,8 +207,10 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [Foo, []], ], "$inflight_init": [ + [Foo, []], ], }); } @@ -235,9 +242,11 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ + [$helpers.nodeof(this).root.$preflightTypesMap[0]._singleton(this,"Foo_singleton_0"), ["do"]], [foo, ["handle"]], ], "$inflight_init": [ + [$helpers.nodeof(this).root.$preflightTypesMap[0]._singleton(this,"Foo_singleton_0"), []], [foo, []], ], }); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/lift_this.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/lift_this.test.w_compile_tf-aws.md index 29ee35eb5f1..453d213e4bb 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/lift_this.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/lift_this.test.w_compile_tf-aws.md @@ -73,10 +73,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const util = $stdlib.util; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const util = $stdlib.util; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/lift_via_closure.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/lift_via_closure.test.w_compile_tf-aws.md index e36aa1d5837..fd0d2987317 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/lift_via_closure.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/lift_via_closure.test.w_compile_tf-aws.md @@ -146,10 +146,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/new_in_static.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/new_in_static.test.w_compile_tf-aws.md index 16866ffa5cc..ee2ef2e88d1 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/new_in_static.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/new_in_static.test.w_compile_tf-aws.md @@ -175,13 +175,17 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; -const c = require("constructs"); -const jsii_fixture = require("jsii-fixture"); -const new_in_static_lib = require("./preflight.newinstaticlib-1.cjs"); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + const c = require("constructs"); + const jsii_fixture = require("jsii-fixture"); + const new_in_static_lib = require("./preflight.newinstaticlib-1.cjs"); + Object.assign($preflightTypesMap, new_in_static_lib.$preflightTypesMap); + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class MyClass extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); @@ -359,6 +363,7 @@ const $stdlib = require('@winglang/sdk'); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); +let $preflightTypesMap = {}; class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); @@ -418,7 +423,7 @@ class LibClass extends $stdlib.std.Resource { }); } } -module.exports = { Foo, LibClass }; +module.exports = { $preflightTypesMap, Foo, LibClass }; //# sourceMappingURL=preflight.newinstaticlib-1.cjs.map ``` diff --git a/tools/hangar/__snapshots__/test_corpus/valid/new_jsii.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/new_jsii.test.w_compile_tf-aws.md index aeee02c5419..7289e3471ef 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/new_jsii.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/new_jsii.test.w_compile_tf-aws.md @@ -57,10 +57,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class CustomScope extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/nil.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/nil.test.w_compile_tf-aws.md index 7a58f2cd9c0..9c44215ef3f 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/nil.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/nil.test.w_compile_tf-aws.md @@ -105,10 +105,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/parameters/nested/parameters.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/parameters/nested/parameters.test.w_compile_tf-aws.md index 811e2fa2337..e85e8869d5e 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/parameters/nested/parameters.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/parameters/nested/parameters.test.w_compile_tf-aws.md @@ -32,7 +32,10 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; const MyParams = $stdlib.std.Struct._createJsonSchema({$id:"/MyParams",type:"object",properties:{houses:{type:"array",items:{type:"object",properties:{address:{type:"string"},residents:{type:"array",items:{type:"object",properties:{age:{type:"number"},name:{type:"string"},},required:["age","name",]}},},required:["address","residents",]}},},required:["houses",]}); + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; const app = $helpers.nodeof(this).app; const myParams = MyParams._fromJson((app.parameters.read({ schema: MyParams }))); $helpers.assert($helpers.eq(myParams.houses.length, 2), "myParams.houses.length == 2"); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/resource_captures.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/resource_captures.test.w_compile_tf-aws.md index 1a3e83f0e53..216dbf81b42 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/resource_captures.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/resource_captures.test.w_compile_tf-aws.md @@ -241,10 +241,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class First extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/resource_captures_globals.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/resource_captures_globals.test.w_compile_tf-aws.md index 81a9d2c67bd..b7f23945706 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/resource_captures_globals.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/resource_captures_globals.test.w_compile_tf-aws.md @@ -363,11 +363,14 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; -const util = $stdlib.util; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + const util = $stdlib.util; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class First extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); @@ -518,6 +521,7 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "myPut": [ + [$stdlib.core.toLiftableModuleType(util.Util, "@winglang/sdk/util", "Util"), ["waitUntil"]], [Another, ["myStaticMethod"]], [globalAnother, ["myMethod"]], [globalAnother.first.myResource, ["put"]], @@ -533,6 +537,7 @@ class $Root extends $stdlib.std.Resource { [this.localTopic, ["publish"]], ], "$inflight_init": [ + [$stdlib.core.toLiftableModuleType(util.Util, "@winglang/sdk/util", "Util"), []], [Another, []], [globalAnother, []], [globalAnother.first.myResource, []], diff --git a/tools/hangar/__snapshots__/test_corpus/valid/shadowing.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/shadowing.test.w_compile_tf-aws.md index c1a060431ee..506a1be33dc 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/shadowing.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/shadowing.test.w_compile_tf-aws.md @@ -81,10 +81,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/statements_if.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/statements_if.test.w_compile_tf-aws.md index d4d62ba28dc..dec920f973b 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/statements_if.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/statements_if.test.w_compile_tf-aws.md @@ -68,10 +68,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/stringify.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/stringify.test.w_compile_tf-aws.md index 20a9e71037f..852d721ae89 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/stringify.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/stringify.test.w_compile_tf-aws.md @@ -32,6 +32,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; const MyEnum = (function (tmp) { tmp["A"] = "A"; diff --git a/tools/hangar/__snapshots__/test_corpus/valid/super_call.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/super_call.test.w_compile_tf-aws.md index 29c98c6c1c5..d8ac0c5a67f 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/super_call.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/super_call.test.w_compile_tf-aws.md @@ -224,11 +224,14 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const expect = $stdlib.expect; -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const expect = $stdlib.expect; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class A extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); @@ -413,7 +416,8 @@ class $Root extends $stdlib.std.Resource { }); } } - const $InflightA_5 = new InflightA(this, "$InflightA_5"); + if ($preflightTypesMap[5]) { throw new Error("InflightA is already in type map"); } + $preflightTypesMap[5] = InflightA; class InflightB extends InflightA { constructor($scope, $id, ) { super($scope, $id); @@ -445,7 +449,8 @@ class $Root extends $stdlib.std.Resource { }); } } - const $InflightB_6 = new InflightB(this, "$InflightB_6"); + if ($preflightTypesMap[6]) { throw new Error("InflightB is already in type map"); } + $preflightTypesMap[6] = InflightB; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -474,12 +479,12 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ - [$InflightB_6, ["description"]], + [$helpers.nodeof(this).root.$preflightTypesMap[6]._singleton(this,"InflightB_singleton_6"), ["description"]], [$stdlib.core.toLiftableModuleType(expect.Util, "@winglang/sdk/expect", "Util"), ["equal"]], [InflightB, []], ], "$inflight_init": [ - [$InflightB_6, []], + [$helpers.nodeof(this).root.$preflightTypesMap[6]._singleton(this,"InflightB_singleton_6"), []], [$stdlib.core.toLiftableModuleType(expect.Util, "@winglang/sdk/expect", "Util"), []], [InflightB, []], ], diff --git a/tools/hangar/__snapshots__/test_corpus/valid/symbol_shadow.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/symbol_shadow.test.w_compile_tf-aws.md index 7ec26fa5fea..c522f4950e2 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/symbol_shadow.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/symbol_shadow.test.w_compile_tf-aws.md @@ -124,10 +124,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class A extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/test_bucket.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/test_bucket.test.w_compile_tf-aws.md index 036ebaba3e5..a3f7c3f2568 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/test_bucket.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/test_bucket.test.w_compile_tf-aws.md @@ -86,10 +86,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/to_inflight.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/to_inflight.test.w_compile_tf-aws.md index 4e535330401..af5e331fab1 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/to_inflight.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/to_inflight.test.w_compile_tf-aws.md @@ -63,10 +63,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/website_with_api.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/website_with_api.test.w_compile_tf-aws.md index 72811933d54..56e3124c029 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/website_with_api.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/website_with_api.test.w_compile_tf-aws.md @@ -629,13 +629,16 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; -const ex = $stdlib.ex; -const http = $stdlib.http; -const expect = $stdlib.expect; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + const ex = $stdlib.ex; + const http = $stdlib.http; + const expect = $stdlib.expect; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -702,7 +705,7 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ - [$stdlib.core.toLiftableModuleType(std.Json, "@winglang/sdk/std", "Json"), ["parse", "stringify"]], + [$stdlib.core.toLiftableModuleType(std.Json, "@winglang/sdk/std", "Json"), [].concat(["parse"], ["stringify"])], [usersTable, ["insert"]], ], "$inflight_init": [ @@ -742,7 +745,7 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ - [$stdlib.core.toLiftableModuleType(expect.Util, "@winglang/sdk/expect", "Util"), ["equal", "nil"]], + [$stdlib.core.toLiftableModuleType(expect.Util, "@winglang/sdk/expect", "Util"), [].concat(["equal"], ["nil"])], [$stdlib.core.toLiftableModuleType(http.HttpMethod, "@winglang/sdk/http", "HttpMethod"), ["GET"]], [$stdlib.core.toLiftableModuleType(http.Util, "@winglang/sdk/http", "Util"), ["fetch"]], [api.url, []], diff --git a/tools/hangar/__snapshots__/test_corpus/valid/while.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/while.test.w_compile_tf-aws.md index da069f993dc..4e4e79d83bc 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/while.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/while.test.w_compile_tf-aws.md @@ -32,6 +32,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; while (false) { const x = 1; } From 2a7fc0e9ee0799cbf64f9cb32de3dd36b568466c Mon Sep 17 00:00:00 2001 From: Yoav Steinberg Date: Thu, 13 Jun 2024 14:26:53 +0300 Subject: [PATCH 44/78] lint --- libs/wingsdk/src/core/lifting.ts | 5 +---- libs/wingsdk/src/helpers.ts | 25 ++++++++++++++++--------- libs/wingsdk/src/std/resource.ts | 12 ++++++------ 3 files changed, 23 insertions(+), 19 deletions(-) diff --git a/libs/wingsdk/src/core/lifting.ts b/libs/wingsdk/src/core/lifting.ts index 539b33fc8de..41d2bb7fad0 100644 --- a/libs/wingsdk/src/core/lifting.ts +++ b/libs/wingsdk/src/core/lifting.ts @@ -265,10 +265,7 @@ export function collectLifts( } else if (typeof obj === "object" && obj._liftMap !== undefined) { matrix = parseMatrix(obj._liftMap ?? {}); matrixCache.set(obj, matrix); - } else if ( - typeof obj === "function" && - obj._liftTypeMap !== undefined - ) { + } else if (typeof obj === "function" && obj._liftTypeMap !== undefined) { matrix = parseMatrix(obj._liftTypeMap ?? {}); matrixCache.set(obj, matrix); } else { diff --git a/libs/wingsdk/src/helpers.ts b/libs/wingsdk/src/helpers.ts index 27cd2116880..a4d20f9d9cd 100644 --- a/libs/wingsdk/src/helpers.ts +++ b/libs/wingsdk/src/helpers.ts @@ -167,13 +167,20 @@ export function resolveDirname( return normalPath(path.resolve(outdir, relativeSourceDir)); } -export function bringJs(moduleFile: string, preflightTypesObjectName: string, outPreflightTypesObject: Object): Object { - return Object.fromEntries(Object.entries(require(moduleFile)).filter(([k, v]) => { - // If this is the preflight types array then update the input object and skip it - if (k === preflightTypesObjectName) { - Object.assign(outPreflightTypesObject, v); - return false; - } - return true; - })); +export function bringJs( + moduleFile: string, + preflightTypesObjectName: string, + outPreflightTypesObject: Object +): Object { + /* eslint-disable @typescript-eslint/no-require-imports */ + return Object.fromEntries( + Object.entries(require(moduleFile)).filter(([k, v]) => { + // If this is the preflight types array then update the input object and skip it + if (k === preflightTypesObjectName) { + Object.assign(outPreflightTypesObject, v); + return false; + } + return true; + }) + ); } diff --git a/libs/wingsdk/src/std/resource.ts b/libs/wingsdk/src/std/resource.ts index ce7431261af..d5e66fa3ec9 100644 --- a/libs/wingsdk/src/std/resource.ts +++ b/libs/wingsdk/src/std/resource.ts @@ -154,7 +154,7 @@ export abstract class Resource extends Construct implements IResource { * This helper function is used to create a single dummy instance of `inflight class`es * defined in preflight code. This instances are needed to create a lift qualification * map for such classes. - * + * * @internal */ public static _singleton(scope: Construct, id: string): Resource { @@ -263,11 +263,11 @@ function addConnectionsFromLiftMap( } /** -* A resource that has an automatically generated id. -* Used by the Wing compiler to generate unique ids for auto generated resources -* from inflight function closures. -* @noinflight -*/ + * A resource that has an automatically generated id. + * Used by the Wing compiler to generate unique ids for auto generated resources + * from inflight function closures. + * @noinflight + */ export abstract class AutoIdResource extends Resource { constructor(scope: Construct, idPrefix: string = "") { const id = App.of(scope).makeId(scope, idPrefix ? `${idPrefix}_` : ""); From 76ac1a1ef7f7f4a1a78d3669eb823de93d1e1b34 Mon Sep 17 00:00:00 2001 From: "monada-bot[bot]" Date: Thu, 13 Jun 2024 11:40:04 +0000 Subject: [PATCH 45/78] chore: self mutation (build.diff) Signed-off-by: monada-bot[bot] --- apps/wing/src/commands/pack.test.ts | 1 + .../src/dtsify/snapshots/declarations.snap | 9 ++--- .../wingc/src/dtsify/snapshots/optionals.snap | 9 ++--- ...methods_and_properties_on_collections.snap | 3 ++ .../access_property_on_primitive.snap | 3 ++ ...rty_on_value_returned_from_collection.snap | 3 ++ .../allow_type_def_before_super.snap | 3 ++ .../base_class_captures_inflight.snap | 3 ++ .../base_class_captures_preflight.snap | 3 ++ .../snapshots/base_class_lift_indirect.snap | 5 ++- .../base_class_with_fields_inflight.snap | 3 ++ .../base_class_with_fields_preflight.snap | 3 ++ .../base_class_with_lifted_field_object.snap | 5 ++- .../base_class_with_lifted_fields.snap | 3 ++ libs/wingc/src/jsify/snapshots/builtins.snap | 3 ++ ..._static_inflight_from_static_inflight.snap | 6 +++- .../calls_methods_on_preflight_object.snap | 5 ++- ...pture_from_inside_an_inflight_closure.snap | 5 ++- ...entifier_closure_from_preflight_scope.snap | 3 ++ ...pture_identifier_from_preflight_scope.snap | 3 ++ ...from_preflight_scope_with_method_call.snap | 3 ++ ...om_preflight_scope_with_nested_object.snap | 5 ++- ...er_from_preflight_scope_with_property.snap | 3 ++ .../snapshots/capture_in_keyword_args.snap | 5 ++- .../capture_object_with_this_in_name.snap | 5 ++- .../src/jsify/snapshots/capture_token.snap | 5 ++- ...type_inflight_class_sibling_from_init.snap | 3 ++ ...pe_inflight_class_sibling_from_method.snap | 3 ++ ...e_new_inflight_class_inner_no_capture.snap | 3 ++ ...capture_type_new_inflight_class_outer.snap | 6 +++- .../snapshots/capture_type_static_method.snap | 3 ++ ...ure_type_static_method_inflight_class.snap | 6 +++- .../capture_var_from_method_inflight.snap | 3 ++ ...ht_class_extends_outer_inflight_class.snap | 6 +++- .../src/jsify/snapshots/closure_field.snap | 5 ++- .../src/jsify/snapshots/entrypoint_this.snap | 3 ++ .../wingc/src/jsify/snapshots/enum_value.snap | 5 ++- .../free_inflight_obj_from_inflight.snap | 3 ++ .../free_preflight_object_from_preflight.snap | 3 ++ .../jsify/snapshots/func_returns_func.snap | 3 ++ .../src/jsify/snapshots/identify_field.snap | 5 ++- .../implicit_lift_inflight_init.snap | 5 ++- .../src/jsify/snapshots/indirect_capture.snap | 5 ++- ..._extends_both_inside_inflight_closure.snap | 3 ++ ...inflight_class_extends_inflight_class.snap | 9 +++-- .../jsify/snapshots/inflight_constructor.snap | 3 ++ .../src/jsify/snapshots/inflight_field.snap | 3 ++ .../inflight_field_from_inflight.snap | 3 ++ .../inflight_field_from_inflight_class.snap | 6 +++- .../snapshots/inline_inflight_class.snap | 5 ++- .../src/jsify/snapshots/json_object.snap | 3 ++ ...ary_preflight_and_inflight_expression.snap | 3 ++ .../lift_binary_preflight_expression.snap | 3 ++ ...lift_element_from_collection_as_field.snap | 5 ++- ...ft_element_from_collection_of_objects.snap | 5 ++- .../snapshots/lift_inflight_closure.snap | 3 ++ .../lift_inside_preflight_method.snap | 5 ++- .../jsify/snapshots/lift_self_reference.snap | 3 ++ .../src/jsify/snapshots/lift_string.snap | 3 ++ libs/wingc/src/jsify/snapshots/lift_this.snap | 3 ++ .../jsify/snapshots/lift_var_with_this.snap | 3 ++ .../src/jsify/snapshots/lift_via_closure.snap | 5 ++- .../lift_via_closure_class_explicit.snap | 5 ++- .../namespaced_static_from_inflight.snap | 5 ++- ...ed_inflight_after_preflight_operation.snap | 5 ++- .../snapshots/nested_preflight_operation.snap | 5 ++- .../jsify/snapshots/new_inflight_object.snap | 6 +++- .../snapshots/no_capture_inside_methods.snap | 3 ++ ...apture_of_identifier_from_inner_scope.snap | 3 ++ ...capture_of_identifier_from_same_scope.snap | 3 ++ ...no_capture_shadow_inside_inner_scopes.snap | 3 ++ .../no_lift_shadow_inside_inner_scopes.snap | 3 ++ ...eflight_class_extends_preflight_class.snap | 3 ++ .../jsify/snapshots/preflight_collection.snap | 3 ++ ...light_collection_of_preflight_objects.snap | 5 ++- ...eflight_nested_object_with_operations.snap | 5 ++- .../src/jsify/snapshots/preflight_object.snap | 3 ++ .../preflight_object_through_property.snap | 5 ++- .../preflight_object_with_operations.snap | 5 ++- ...ject_with_operations_multiple_methods.snap | 5 ++- .../snapshots/preflight_value_field.snap | 3 ++ ...ht_type_refrencing_preflight_instance.snap | 33 +++++++++++-------- .../jsify/snapshots/read_primitive_value.snap | 3 ++ .../snapshots/reassign_captured_variable.snap | 3 ++ ...eassigned_captured_variable_preflight.snap | 3 ++ .../src/jsify/snapshots/ref_std_macro.snap | 3 ++ .../reference_from_static_inflight.snap | 3 ++ .../snapshots/reference_inflight_class.snap | 6 +++- .../snapshots/reference_inflight_field.snap | 3 ++ .../reference_inflight_from_inflight.snap | 6 +++- .../reference_lift_of_collection.snap | 3 ++ .../snapshots/reference_preflight_field.snap | 3 ++ ...eflight_field_call_independent_method.snap | 3 ++ .../snapshots/reference_preflight_fields.snap | 5 ++- ..._variable_with_this_in_the_expression.snap | 5 ++- ...preflight_object_from_static_inflight.snap | 5 ++- .../snapshots/reference_static_inflight.snap | 3 ++ ...ght_which_references_preflight_object.snap | 5 ++- .../static_external_inflight_class.snap | 6 +++- .../static_external_preflight_class.snap | 3 ++ .../snapshots/static_inflight_operation.snap | 5 ++- .../static_local_inflight_class.snap | 3 ++ .../jsify/snapshots/static_on_std_type.snap | 3 ++ .../jsify/snapshots/transitive_reference.snap | 5 ++- ...ansitive_reference_via_inflight_class.snap | 12 ++++--- .../transitive_reference_via_static.snap | 5 ++- .../jsify/snapshots/two_identical_lifts.snap | 5 ++- .../jsify/snapshots/use_util_functions.snap | 5 ++- .../var_inflight_field_from_inflight.snap | 3 ++ libs/wingc/src/jsify/snapshots/wait_util.snap | 5 ++- 110 files changed, 412 insertions(+), 74 deletions(-) diff --git a/apps/wing/src/commands/pack.test.ts b/apps/wing/src/commands/pack.test.ts index 3bc815e0143..d424bb258ba 100644 --- a/apps/wing/src/commands/pack.test.ts +++ b/apps/wing/src/commands/pack.test.ts @@ -200,6 +200,7 @@ describe("wing pack", () => { expect(mod).toBeDefined(); expect(Object.keys(mod).sort()).toMatchInlineSnapshot(` [ + "$preflightTypesMap", "FavoriteNumbers", "Store", "default", diff --git a/libs/wingc/src/dtsify/snapshots/declarations.snap b/libs/wingc/src/dtsify/snapshots/declarations.snap index 8258cf4043b..325c1371e32 100644 --- a/libs/wingc/src/dtsify/snapshots/declarations.snap +++ b/libs/wingc/src/dtsify/snapshots/declarations.snap @@ -80,9 +80,9 @@ const $stdlib = require('@winglang/sdk'); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -module.exports = { - ...require("./preflight.lib-1.cjs"), -}; +let $preflightTypesMap = {}; +Object.assign(module.exports, $helpers.bringJs(`${__dirname}/preflight.lib-1.cjs`, "$preflightTypesMap", $preflightTypesMap)); +module.exports = { ...module.exports, $preflightTypesMap }; //# sourceMappingURL=preflight.cjs.map ``` @@ -100,6 +100,7 @@ const $stdlib = require('@winglang/sdk'); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); +let $preflightTypesMap = {}; class ParentClass extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); @@ -169,7 +170,7 @@ class Child extends ParentClass { }); } } -module.exports = { ParentClass, Child }; +module.exports = { $preflightTypesMap, ParentClass, Child }; //# sourceMappingURL=preflight.lib-1.cjs.map ``` diff --git a/libs/wingc/src/dtsify/snapshots/optionals.snap b/libs/wingc/src/dtsify/snapshots/optionals.snap index deac88efa6f..61888773f92 100644 --- a/libs/wingc/src/dtsify/snapshots/optionals.snap +++ b/libs/wingc/src/dtsify/snapshots/optionals.snap @@ -46,9 +46,9 @@ const $stdlib = require('@winglang/sdk'); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -module.exports = { - ...require("./preflight.lib-1.cjs"), -}; +let $preflightTypesMap = {}; +Object.assign(module.exports, $helpers.bringJs(`${__dirname}/preflight.lib-1.cjs`, "$preflightTypesMap", $preflightTypesMap)); +module.exports = { ...module.exports, $preflightTypesMap }; //# sourceMappingURL=preflight.cjs.map ``` @@ -66,6 +66,7 @@ const $stdlib = require('@winglang/sdk'); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); +let $preflightTypesMap = {}; class ParentClass extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); @@ -96,7 +97,7 @@ class ParentClass extends $stdlib.std.Resource { }); } } -module.exports = { ParentClass }; +module.exports = { $preflightTypesMap, ParentClass }; //# sourceMappingURL=preflight.lib-1.cjs.map ``` diff --git a/libs/wingc/src/jsify/snapshots/access_methods_and_properties_on_collections.snap b/libs/wingc/src/jsify/snapshots/access_methods_and_properties_on_collections.snap index ebc433dcb62..c396742c435 100644 --- a/libs/wingc/src/jsify/snapshots/access_methods_and_properties_on_collections.snap +++ b/libs/wingc/src/jsify/snapshots/access_methods_and_properties_on_collections.snap @@ -51,6 +51,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/access_property_on_primitive.snap b/libs/wingc/src/jsify/snapshots/access_property_on_primitive.snap index b5771fcc0b9..d093b8b3e3f 100644 --- a/libs/wingc/src/jsify/snapshots/access_property_on_primitive.snap +++ b/libs/wingc/src/jsify/snapshots/access_property_on_primitive.snap @@ -48,6 +48,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/access_property_on_value_returned_from_collection.snap b/libs/wingc/src/jsify/snapshots/access_property_on_value_returned_from_collection.snap index fdce5f92022..3a47440282e 100644 --- a/libs/wingc/src/jsify/snapshots/access_property_on_value_returned_from_collection.snap +++ b/libs/wingc/src/jsify/snapshots/access_property_on_value_returned_from_collection.snap @@ -48,6 +48,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/allow_type_def_before_super.snap b/libs/wingc/src/jsify/snapshots/allow_type_def_before_super.snap index bd00d29aa47..afc28743af5 100644 --- a/libs/wingc/src/jsify/snapshots/allow_type_def_before_super.snap +++ b/libs/wingc/src/jsify/snapshots/allow_type_def_before_super.snap @@ -77,6 +77,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { constructor($scope, $id, x) { super($scope, $id); diff --git a/libs/wingc/src/jsify/snapshots/base_class_captures_inflight.snap b/libs/wingc/src/jsify/snapshots/base_class_captures_inflight.snap index c996859fb2d..ca2c6cc48fd 100644 --- a/libs/wingc/src/jsify/snapshots/base_class_captures_inflight.snap +++ b/libs/wingc/src/jsify/snapshots/base_class_captures_inflight.snap @@ -72,6 +72,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Base extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/libs/wingc/src/jsify/snapshots/base_class_captures_preflight.snap b/libs/wingc/src/jsify/snapshots/base_class_captures_preflight.snap index 989c402998a..53de74f2c34 100644 --- a/libs/wingc/src/jsify/snapshots/base_class_captures_preflight.snap +++ b/libs/wingc/src/jsify/snapshots/base_class_captures_preflight.snap @@ -66,6 +66,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Base extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/libs/wingc/src/jsify/snapshots/base_class_lift_indirect.snap b/libs/wingc/src/jsify/snapshots/base_class_lift_indirect.snap index a1098a4325a..945f43e89f4 100644 --- a/libs/wingc/src/jsify/snapshots/base_class_lift_indirect.snap +++ b/libs/wingc/src/jsify/snapshots/base_class_lift_indirect.snap @@ -77,10 +77,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Base extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/libs/wingc/src/jsify/snapshots/base_class_with_fields_inflight.snap b/libs/wingc/src/jsify/snapshots/base_class_with_fields_inflight.snap index 1bcabfc5528..188a438eafd 100644 --- a/libs/wingc/src/jsify/snapshots/base_class_with_fields_inflight.snap +++ b/libs/wingc/src/jsify/snapshots/base_class_with_fields_inflight.snap @@ -81,6 +81,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Base extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/libs/wingc/src/jsify/snapshots/base_class_with_fields_preflight.snap b/libs/wingc/src/jsify/snapshots/base_class_with_fields_preflight.snap index c5faa235839..e055ea9023c 100644 --- a/libs/wingc/src/jsify/snapshots/base_class_with_fields_preflight.snap +++ b/libs/wingc/src/jsify/snapshots/base_class_with_fields_preflight.snap @@ -71,6 +71,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Base extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/libs/wingc/src/jsify/snapshots/base_class_with_lifted_field_object.snap b/libs/wingc/src/jsify/snapshots/base_class_with_lifted_field_object.snap index e2a2891ef78..70cc6660dad 100644 --- a/libs/wingc/src/jsify/snapshots/base_class_with_lifted_field_object.snap +++ b/libs/wingc/src/jsify/snapshots/base_class_with_lifted_field_object.snap @@ -68,10 +68,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Base extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/libs/wingc/src/jsify/snapshots/base_class_with_lifted_fields.snap b/libs/wingc/src/jsify/snapshots/base_class_with_lifted_fields.snap index 7793850313b..eef16a40a7e 100644 --- a/libs/wingc/src/jsify/snapshots/base_class_with_lifted_fields.snap +++ b/libs/wingc/src/jsify/snapshots/base_class_with_lifted_fields.snap @@ -71,6 +71,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Base extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/libs/wingc/src/jsify/snapshots/builtins.snap b/libs/wingc/src/jsify/snapshots/builtins.snap index 53008dfdff0..c27f7a970b4 100644 --- a/libs/wingc/src/jsify/snapshots/builtins.snap +++ b/libs/wingc/src/jsify/snapshots/builtins.snap @@ -46,6 +46,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/call_static_inflight_from_static_inflight.snap b/libs/wingc/src/jsify/snapshots/call_static_inflight_from_static_inflight.snap index 045ae7ab574..9226085eb2c 100644 --- a/libs/wingc/src/jsify/snapshots/call_static_inflight_from_static_inflight.snap +++ b/libs/wingc/src/jsify/snapshots/call_static_inflight_from_static_inflight.snap @@ -65,6 +65,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class A extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); @@ -136,7 +139,8 @@ class $Root extends $stdlib.std.Resource { }); } } - const $B_1 = new B(this, "$B_1"); + if ($preflightTypesMap[22]) { throw new Error("B is already in type map"); } + $preflightTypesMap[22] = B; } } const $PlatformManager = new $stdlib.platform.PlatformManager({platformPaths: $platforms}); diff --git a/libs/wingc/src/jsify/snapshots/calls_methods_on_preflight_object.snap b/libs/wingc/src/jsify/snapshots/calls_methods_on_preflight_object.snap index e34ef9d6acd..4bf1644e044 100644 --- a/libs/wingc/src/jsify/snapshots/calls_methods_on_preflight_object.snap +++ b/libs/wingc/src/jsify/snapshots/calls_methods_on_preflight_object.snap @@ -48,10 +48,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/capture_from_inside_an_inflight_closure.snap b/libs/wingc/src/jsify/snapshots/capture_from_inside_an_inflight_closure.snap index 09e9197b655..f3d25d6bb08 100644 --- a/libs/wingc/src/jsify/snapshots/capture_from_inside_an_inflight_closure.snap +++ b/libs/wingc/src/jsify/snapshots/capture_from_inside_an_inflight_closure.snap @@ -48,10 +48,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const util = $stdlib.util; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const util = $stdlib.util; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/capture_identifier_closure_from_preflight_scope.snap b/libs/wingc/src/jsify/snapshots/capture_identifier_closure_from_preflight_scope.snap index 855df068e77..f699bc23896 100644 --- a/libs/wingc/src/jsify/snapshots/capture_identifier_closure_from_preflight_scope.snap +++ b/libs/wingc/src/jsify/snapshots/capture_identifier_closure_from_preflight_scope.snap @@ -67,6 +67,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/capture_identifier_from_preflight_scope.snap b/libs/wingc/src/jsify/snapshots/capture_identifier_from_preflight_scope.snap index 7fc9b80532b..79c6953004d 100644 --- a/libs/wingc/src/jsify/snapshots/capture_identifier_from_preflight_scope.snap +++ b/libs/wingc/src/jsify/snapshots/capture_identifier_from_preflight_scope.snap @@ -47,6 +47,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/capture_identifier_from_preflight_scope_with_method_call.snap b/libs/wingc/src/jsify/snapshots/capture_identifier_from_preflight_scope_with_method_call.snap index 13cc38e59bb..b2f07c217a5 100644 --- a/libs/wingc/src/jsify/snapshots/capture_identifier_from_preflight_scope_with_method_call.snap +++ b/libs/wingc/src/jsify/snapshots/capture_identifier_from_preflight_scope_with_method_call.snap @@ -68,6 +68,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/libs/wingc/src/jsify/snapshots/capture_identifier_from_preflight_scope_with_nested_object.snap b/libs/wingc/src/jsify/snapshots/capture_identifier_from_preflight_scope_with_nested_object.snap index b5fbf73536b..0ec257d3e11 100644 --- a/libs/wingc/src/jsify/snapshots/capture_identifier_from_preflight_scope_with_nested_object.snap +++ b/libs/wingc/src/jsify/snapshots/capture_identifier_from_preflight_scope_with_nested_object.snap @@ -68,10 +68,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/libs/wingc/src/jsify/snapshots/capture_identifier_from_preflight_scope_with_property.snap b/libs/wingc/src/jsify/snapshots/capture_identifier_from_preflight_scope_with_property.snap index a758b92f8cc..9a5ef810928 100644 --- a/libs/wingc/src/jsify/snapshots/capture_identifier_from_preflight_scope_with_property.snap +++ b/libs/wingc/src/jsify/snapshots/capture_identifier_from_preflight_scope_with_property.snap @@ -47,6 +47,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/capture_in_keyword_args.snap b/libs/wingc/src/jsify/snapshots/capture_in_keyword_args.snap index 1b89a1195de..0d9c3a3923e 100644 --- a/libs/wingc/src/jsify/snapshots/capture_in_keyword_args.snap +++ b/libs/wingc/src/jsify/snapshots/capture_in_keyword_args.snap @@ -49,10 +49,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const util = $stdlib.util; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const util = $stdlib.util; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/capture_object_with_this_in_name.snap b/libs/wingc/src/jsify/snapshots/capture_object_with_this_in_name.snap index e08d93d3d5f..af034f5f15a 100644 --- a/libs/wingc/src/jsify/snapshots/capture_object_with_this_in_name.snap +++ b/libs/wingc/src/jsify/snapshots/capture_object_with_this_in_name.snap @@ -45,10 +45,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/capture_token.snap b/libs/wingc/src/jsify/snapshots/capture_token.snap index 7d280541b37..b4e6974caca 100644 --- a/libs/wingc/src/jsify/snapshots/capture_token.snap +++ b/libs/wingc/src/jsify/snapshots/capture_token.snap @@ -44,10 +44,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/capture_type_inflight_class_sibling_from_init.snap b/libs/wingc/src/jsify/snapshots/capture_type_inflight_class_sibling_from_init.snap index e33734b441e..0a05c2e625e 100644 --- a/libs/wingc/src/jsify/snapshots/capture_type_inflight_class_sibling_from_init.snap +++ b/libs/wingc/src/jsify/snapshots/capture_type_inflight_class_sibling_from_init.snap @@ -71,6 +71,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/capture_type_inflight_class_sibling_from_method.snap b/libs/wingc/src/jsify/snapshots/capture_type_inflight_class_sibling_from_method.snap index 47fb417fa00..979744061a1 100644 --- a/libs/wingc/src/jsify/snapshots/capture_type_inflight_class_sibling_from_method.snap +++ b/libs/wingc/src/jsify/snapshots/capture_type_inflight_class_sibling_from_method.snap @@ -57,6 +57,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/capture_type_new_inflight_class_inner_no_capture.snap b/libs/wingc/src/jsify/snapshots/capture_type_new_inflight_class_inner_no_capture.snap index b0d4cbe8f02..af7adb56121 100644 --- a/libs/wingc/src/jsify/snapshots/capture_type_new_inflight_class_inner_no_capture.snap +++ b/libs/wingc/src/jsify/snapshots/capture_type_new_inflight_class_inner_no_capture.snap @@ -49,6 +49,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/capture_type_new_inflight_class_outer.snap b/libs/wingc/src/jsify/snapshots/capture_type_new_inflight_class_outer.snap index 31b6fc9408d..c8229643dc1 100644 --- a/libs/wingc/src/jsify/snapshots/capture_type_new_inflight_class_outer.snap +++ b/libs/wingc/src/jsify/snapshots/capture_type_new_inflight_class_outer.snap @@ -61,6 +61,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); @@ -89,7 +92,8 @@ class $Root extends $stdlib.std.Resource { }); } } - const $Foo_0 = new Foo(this, "$Foo_0"); + if ($preflightTypesMap[45]) { throw new Error("Foo is already in type map"); } + $preflightTypesMap[45] = Foo; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/capture_type_static_method.snap b/libs/wingc/src/jsify/snapshots/capture_type_static_method.snap index b6277673600..3cfdfa00daa 100644 --- a/libs/wingc/src/jsify/snapshots/capture_type_static_method.snap +++ b/libs/wingc/src/jsify/snapshots/capture_type_static_method.snap @@ -68,6 +68,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/libs/wingc/src/jsify/snapshots/capture_type_static_method_inflight_class.snap b/libs/wingc/src/jsify/snapshots/capture_type_static_method_inflight_class.snap index 0e38d7f2621..d4ee2863513 100644 --- a/libs/wingc/src/jsify/snapshots/capture_type_static_method_inflight_class.snap +++ b/libs/wingc/src/jsify/snapshots/capture_type_static_method_inflight_class.snap @@ -66,6 +66,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); @@ -100,7 +103,8 @@ class $Root extends $stdlib.std.Resource { }); } } - const $Foo_0 = new Foo(this, "$Foo_0"); + if ($preflightTypesMap[51]) { throw new Error("Foo is already in type map"); } + $preflightTypesMap[51] = Foo; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/capture_var_from_method_inflight.snap b/libs/wingc/src/jsify/snapshots/capture_var_from_method_inflight.snap index 9254bf82239..12e633ae877 100644 --- a/libs/wingc/src/jsify/snapshots/capture_var_from_method_inflight.snap +++ b/libs/wingc/src/jsify/snapshots/capture_var_from_method_inflight.snap @@ -54,6 +54,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/closed_inflight_class_extends_outer_inflight_class.snap b/libs/wingc/src/jsify/snapshots/closed_inflight_class_extends_outer_inflight_class.snap index a48cb14397c..1cc30b10a23 100644 --- a/libs/wingc/src/jsify/snapshots/closed_inflight_class_extends_outer_inflight_class.snap +++ b/libs/wingc/src/jsify/snapshots/closed_inflight_class_extends_outer_inflight_class.snap @@ -64,6 +64,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Base extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); @@ -92,7 +95,8 @@ class $Root extends $stdlib.std.Resource { }); } } - const $Base_0 = new Base(this, "$Base_0"); + if ($preflightTypesMap[55]) { throw new Error("Base is already in type map"); } + $preflightTypesMap[55] = Base; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/closure_field.snap b/libs/wingc/src/jsify/snapshots/closure_field.snap index 22d34a6d686..cb2ea648ef7 100644 --- a/libs/wingc/src/jsify/snapshots/closure_field.snap +++ b/libs/wingc/src/jsify/snapshots/closure_field.snap @@ -106,10 +106,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class MyResource extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/libs/wingc/src/jsify/snapshots/entrypoint_this.snap b/libs/wingc/src/jsify/snapshots/entrypoint_this.snap index b61f8369c14..5e03a620b84 100644 --- a/libs/wingc/src/jsify/snapshots/entrypoint_this.snap +++ b/libs/wingc/src/jsify/snapshots/entrypoint_this.snap @@ -23,6 +23,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; this; } } diff --git a/libs/wingc/src/jsify/snapshots/enum_value.snap b/libs/wingc/src/jsify/snapshots/enum_value.snap index f75db3059e0..759fb0f233f 100644 --- a/libs/wingc/src/jsify/snapshots/enum_value.snap +++ b/libs/wingc/src/jsify/snapshots/enum_value.snap @@ -51,6 +51,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; const MyEnum = (function (tmp) { tmp["B"] = "B"; @@ -86,7 +89,7 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ - [MyEnum, ["B", "C"]], + [MyEnum, [].concat(["B"], ["C"])], [x, []], ], "$inflight_init": [ diff --git a/libs/wingc/src/jsify/snapshots/free_inflight_obj_from_inflight.snap b/libs/wingc/src/jsify/snapshots/free_inflight_obj_from_inflight.snap index 5257f8a3c70..9b476ad3879 100644 --- a/libs/wingc/src/jsify/snapshots/free_inflight_obj_from_inflight.snap +++ b/libs/wingc/src/jsify/snapshots/free_inflight_obj_from_inflight.snap @@ -59,6 +59,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/free_preflight_object_from_preflight.snap b/libs/wingc/src/jsify/snapshots/free_preflight_object_from_preflight.snap index 15ebf279878..24507645cfb 100644 --- a/libs/wingc/src/jsify/snapshots/free_preflight_object_from_preflight.snap +++ b/libs/wingc/src/jsify/snapshots/free_preflight_object_from_preflight.snap @@ -42,6 +42,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class A extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/libs/wingc/src/jsify/snapshots/func_returns_func.snap b/libs/wingc/src/jsify/snapshots/func_returns_func.snap index 2b8e67d67c0..8bb3df26820 100644 --- a/libs/wingc/src/jsify/snapshots/func_returns_func.snap +++ b/libs/wingc/src/jsify/snapshots/func_returns_func.snap @@ -56,6 +56,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/identify_field.snap b/libs/wingc/src/jsify/snapshots/identify_field.snap index 8cdc9ae7a00..bb5fcb10c79 100644 --- a/libs/wingc/src/jsify/snapshots/identify_field.snap +++ b/libs/wingc/src/jsify/snapshots/identify_field.snap @@ -48,10 +48,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class A extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/libs/wingc/src/jsify/snapshots/implicit_lift_inflight_init.snap b/libs/wingc/src/jsify/snapshots/implicit_lift_inflight_init.snap index ede8b4806e1..2df0dbd74bc 100644 --- a/libs/wingc/src/jsify/snapshots/implicit_lift_inflight_init.snap +++ b/libs/wingc/src/jsify/snapshots/implicit_lift_inflight_init.snap @@ -66,10 +66,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/libs/wingc/src/jsify/snapshots/indirect_capture.snap b/libs/wingc/src/jsify/snapshots/indirect_capture.snap index 15a89bd9a55..8d67de04315 100644 --- a/libs/wingc/src/jsify/snapshots/indirect_capture.snap +++ b/libs/wingc/src/jsify/snapshots/indirect_capture.snap @@ -81,10 +81,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Capture extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/libs/wingc/src/jsify/snapshots/inflight_class_extends_both_inside_inflight_closure.snap b/libs/wingc/src/jsify/snapshots/inflight_class_extends_both_inside_inflight_closure.snap index c496a96fb04..da1e9d8141b 100644 --- a/libs/wingc/src/jsify/snapshots/inflight_class_extends_both_inside_inflight_closure.snap +++ b/libs/wingc/src/jsify/snapshots/inflight_class_extends_both_inside_inflight_closure.snap @@ -50,6 +50,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/inflight_class_extends_inflight_class.snap b/libs/wingc/src/jsify/snapshots/inflight_class_extends_inflight_class.snap index 4cb68b6ce46..677c637979a 100644 --- a/libs/wingc/src/jsify/snapshots/inflight_class_extends_inflight_class.snap +++ b/libs/wingc/src/jsify/snapshots/inflight_class_extends_inflight_class.snap @@ -50,6 +50,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class A extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); @@ -78,7 +81,8 @@ class $Root extends $stdlib.std.Resource { }); } } - const $A_0 = new A(this, "$A_0"); + if ($preflightTypesMap[89]) { throw new Error("A is already in type map"); } + $preflightTypesMap[89] = A; class B extends A { constructor($scope, $id, ) { super($scope, $id); @@ -108,7 +112,8 @@ class $Root extends $stdlib.std.Resource { }); } } - const $B_1 = new B(this, "$B_1"); + if ($preflightTypesMap[90]) { throw new Error("B is already in type map"); } + $preflightTypesMap[90] = B; } } const $PlatformManager = new $stdlib.platform.PlatformManager({platformPaths: $platforms}); diff --git a/libs/wingc/src/jsify/snapshots/inflight_constructor.snap b/libs/wingc/src/jsify/snapshots/inflight_constructor.snap index 80faa3b1138..1e355d4b666 100644 --- a/libs/wingc/src/jsify/snapshots/inflight_constructor.snap +++ b/libs/wingc/src/jsify/snapshots/inflight_constructor.snap @@ -54,6 +54,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/libs/wingc/src/jsify/snapshots/inflight_field.snap b/libs/wingc/src/jsify/snapshots/inflight_field.snap index 0cfde3b80c0..44c9860c391 100644 --- a/libs/wingc/src/jsify/snapshots/inflight_field.snap +++ b/libs/wingc/src/jsify/snapshots/inflight_field.snap @@ -53,6 +53,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class A extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/libs/wingc/src/jsify/snapshots/inflight_field_from_inflight.snap b/libs/wingc/src/jsify/snapshots/inflight_field_from_inflight.snap index f300ef416e6..168eb48e6e2 100644 --- a/libs/wingc/src/jsify/snapshots/inflight_field_from_inflight.snap +++ b/libs/wingc/src/jsify/snapshots/inflight_field_from_inflight.snap @@ -52,6 +52,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class MyType extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/libs/wingc/src/jsify/snapshots/inflight_field_from_inflight_class.snap b/libs/wingc/src/jsify/snapshots/inflight_field_from_inflight_class.snap index 6aa89d2fa29..4fc845ba25c 100644 --- a/libs/wingc/src/jsify/snapshots/inflight_field_from_inflight_class.snap +++ b/libs/wingc/src/jsify/snapshots/inflight_field_from_inflight_class.snap @@ -51,6 +51,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class MyType extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); @@ -85,7 +88,8 @@ class $Root extends $stdlib.std.Resource { }); } } - const $MyType_0 = new MyType(this, "$MyType_0"); + if ($preflightTypesMap[93]) { throw new Error("MyType is already in type map"); } + $preflightTypesMap[93] = MyType; } } const $PlatformManager = new $stdlib.platform.PlatformManager({platformPaths: $platforms}); diff --git a/libs/wingc/src/jsify/snapshots/inline_inflight_class.snap b/libs/wingc/src/jsify/snapshots/inline_inflight_class.snap index 2a44a3b8b81..40650349c5e 100644 --- a/libs/wingc/src/jsify/snapshots/inline_inflight_class.snap +++ b/libs/wingc/src/jsify/snapshots/inline_inflight_class.snap @@ -69,10 +69,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/libs/wingc/src/jsify/snapshots/json_object.snap b/libs/wingc/src/jsify/snapshots/json_object.snap index b5390d65dc6..e95b6a0cd8f 100644 --- a/libs/wingc/src/jsify/snapshots/json_object.snap +++ b/libs/wingc/src/jsify/snapshots/json_object.snap @@ -48,6 +48,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/lift_binary_preflight_and_inflight_expression.snap b/libs/wingc/src/jsify/snapshots/lift_binary_preflight_and_inflight_expression.snap index b61054c3b05..093f1c00f6a 100644 --- a/libs/wingc/src/jsify/snapshots/lift_binary_preflight_and_inflight_expression.snap +++ b/libs/wingc/src/jsify/snapshots/lift_binary_preflight_and_inflight_expression.snap @@ -49,6 +49,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/lift_binary_preflight_expression.snap b/libs/wingc/src/jsify/snapshots/lift_binary_preflight_expression.snap index 229498fdb1d..d845e175d9f 100644 --- a/libs/wingc/src/jsify/snapshots/lift_binary_preflight_expression.snap +++ b/libs/wingc/src/jsify/snapshots/lift_binary_preflight_expression.snap @@ -48,6 +48,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/lift_element_from_collection_as_field.snap b/libs/wingc/src/jsify/snapshots/lift_element_from_collection_as_field.snap index c047a224ca7..a4f169e0d4f 100644 --- a/libs/wingc/src/jsify/snapshots/lift_element_from_collection_as_field.snap +++ b/libs/wingc/src/jsify/snapshots/lift_element_from_collection_as_field.snap @@ -49,10 +49,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/libs/wingc/src/jsify/snapshots/lift_element_from_collection_of_objects.snap b/libs/wingc/src/jsify/snapshots/lift_element_from_collection_of_objects.snap index 3cbfadf715d..7be2754fb37 100644 --- a/libs/wingc/src/jsify/snapshots/lift_element_from_collection_of_objects.snap +++ b/libs/wingc/src/jsify/snapshots/lift_element_from_collection_of_objects.snap @@ -46,10 +46,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/lift_inflight_closure.snap b/libs/wingc/src/jsify/snapshots/lift_inflight_closure.snap index 28b88a5ba27..9d50a7be1d5 100644 --- a/libs/wingc/src/jsify/snapshots/lift_inflight_closure.snap +++ b/libs/wingc/src/jsify/snapshots/lift_inflight_closure.snap @@ -68,6 +68,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/lift_inside_preflight_method.snap b/libs/wingc/src/jsify/snapshots/lift_inside_preflight_method.snap index 4e5080a5db6..e8d95f5729a 100644 --- a/libs/wingc/src/jsify/snapshots/lift_inside_preflight_method.snap +++ b/libs/wingc/src/jsify/snapshots/lift_inside_preflight_method.snap @@ -70,10 +70,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/libs/wingc/src/jsify/snapshots/lift_self_reference.snap b/libs/wingc/src/jsify/snapshots/lift_self_reference.snap index a7b5c6332a4..a6390026b34 100644 --- a/libs/wingc/src/jsify/snapshots/lift_self_reference.snap +++ b/libs/wingc/src/jsify/snapshots/lift_self_reference.snap @@ -49,6 +49,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/libs/wingc/src/jsify/snapshots/lift_string.snap b/libs/wingc/src/jsify/snapshots/lift_string.snap index 72b030f22ac..6822e8fce9e 100644 --- a/libs/wingc/src/jsify/snapshots/lift_string.snap +++ b/libs/wingc/src/jsify/snapshots/lift_string.snap @@ -47,6 +47,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/lift_this.snap b/libs/wingc/src/jsify/snapshots/lift_this.snap index 6ab8730b88c..cf64779fc21 100644 --- a/libs/wingc/src/jsify/snapshots/lift_this.snap +++ b/libs/wingc/src/jsify/snapshots/lift_this.snap @@ -85,6 +85,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/libs/wingc/src/jsify/snapshots/lift_var_with_this.snap b/libs/wingc/src/jsify/snapshots/lift_var_with_this.snap index 1274cd10e3a..e9e961e1cf7 100644 --- a/libs/wingc/src/jsify/snapshots/lift_var_with_this.snap +++ b/libs/wingc/src/jsify/snapshots/lift_var_with_this.snap @@ -68,6 +68,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/libs/wingc/src/jsify/snapshots/lift_via_closure.snap b/libs/wingc/src/jsify/snapshots/lift_via_closure.snap index c2031ed3b27..e022d28e821 100644 --- a/libs/wingc/src/jsify/snapshots/lift_via_closure.snap +++ b/libs/wingc/src/jsify/snapshots/lift_via_closure.snap @@ -72,10 +72,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/lift_via_closure_class_explicit.snap b/libs/wingc/src/jsify/snapshots/lift_via_closure_class_explicit.snap index 460441dd0a4..8fbf308b920 100644 --- a/libs/wingc/src/jsify/snapshots/lift_via_closure_class_explicit.snap +++ b/libs/wingc/src/jsify/snapshots/lift_via_closure_class_explicit.snap @@ -87,10 +87,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class MyClosure extends $stdlib.std.Resource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/namespaced_static_from_inflight.snap b/libs/wingc/src/jsify/snapshots/namespaced_static_from_inflight.snap index 4c6c79d738d..0d641dd4434 100644 --- a/libs/wingc/src/jsify/snapshots/namespaced_static_from_inflight.snap +++ b/libs/wingc/src/jsify/snapshots/namespaced_static_from_inflight.snap @@ -44,10 +44,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const util = $stdlib.util; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const util = $stdlib.util; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/nested_inflight_after_preflight_operation.snap b/libs/wingc/src/jsify/snapshots/nested_inflight_after_preflight_operation.snap index 2c771b0b1f7..88c3a32572e 100644 --- a/libs/wingc/src/jsify/snapshots/nested_inflight_after_preflight_operation.snap +++ b/libs/wingc/src/jsify/snapshots/nested_inflight_after_preflight_operation.snap @@ -71,10 +71,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class YourType extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/libs/wingc/src/jsify/snapshots/nested_preflight_operation.snap b/libs/wingc/src/jsify/snapshots/nested_preflight_operation.snap index 91257bfd431..016fb850a22 100644 --- a/libs/wingc/src/jsify/snapshots/nested_preflight_operation.snap +++ b/libs/wingc/src/jsify/snapshots/nested_preflight_operation.snap @@ -89,10 +89,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class YourType extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/libs/wingc/src/jsify/snapshots/new_inflight_object.snap b/libs/wingc/src/jsify/snapshots/new_inflight_object.snap index ecd1eef27bf..3b2623b6e27 100644 --- a/libs/wingc/src/jsify/snapshots/new_inflight_object.snap +++ b/libs/wingc/src/jsify/snapshots/new_inflight_object.snap @@ -61,6 +61,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); @@ -89,7 +92,8 @@ class $Root extends $stdlib.std.Resource { }); } } - const $Foo_0 = new Foo(this, "$Foo_0"); + if ($preflightTypesMap[119]) { throw new Error("Foo is already in type map"); } + $preflightTypesMap[119] = Foo; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/no_capture_inside_methods.snap b/libs/wingc/src/jsify/snapshots/no_capture_inside_methods.snap index c053dcae157..e61472625e7 100644 --- a/libs/wingc/src/jsify/snapshots/no_capture_inside_methods.snap +++ b/libs/wingc/src/jsify/snapshots/no_capture_inside_methods.snap @@ -52,6 +52,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/no_capture_of_identifier_from_inner_scope.snap b/libs/wingc/src/jsify/snapshots/no_capture_of_identifier_from_inner_scope.snap index d3992988748..37f163fc6d2 100644 --- a/libs/wingc/src/jsify/snapshots/no_capture_of_identifier_from_inner_scope.snap +++ b/libs/wingc/src/jsify/snapshots/no_capture_of_identifier_from_inner_scope.snap @@ -52,6 +52,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/no_capture_of_identifier_from_same_scope.snap b/libs/wingc/src/jsify/snapshots/no_capture_of_identifier_from_same_scope.snap index 8c96fb27ae5..37d68e92fbf 100644 --- a/libs/wingc/src/jsify/snapshots/no_capture_of_identifier_from_same_scope.snap +++ b/libs/wingc/src/jsify/snapshots/no_capture_of_identifier_from_same_scope.snap @@ -48,6 +48,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/no_capture_shadow_inside_inner_scopes.snap b/libs/wingc/src/jsify/snapshots/no_capture_shadow_inside_inner_scopes.snap index 54db26e1554..e5a833fbf3d 100644 --- a/libs/wingc/src/jsify/snapshots/no_capture_shadow_inside_inner_scopes.snap +++ b/libs/wingc/src/jsify/snapshots/no_capture_shadow_inside_inner_scopes.snap @@ -60,6 +60,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/no_lift_shadow_inside_inner_scopes.snap b/libs/wingc/src/jsify/snapshots/no_lift_shadow_inside_inner_scopes.snap index 5b6c9f12da8..8cf87f1c99b 100644 --- a/libs/wingc/src/jsify/snapshots/no_lift_shadow_inside_inner_scopes.snap +++ b/libs/wingc/src/jsify/snapshots/no_lift_shadow_inside_inner_scopes.snap @@ -58,6 +58,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/preflight_class_extends_preflight_class.snap b/libs/wingc/src/jsify/snapshots/preflight_class_extends_preflight_class.snap index f8df6a1e343..6f8b36e738e 100644 --- a/libs/wingc/src/jsify/snapshots/preflight_class_extends_preflight_class.snap +++ b/libs/wingc/src/jsify/snapshots/preflight_class_extends_preflight_class.snap @@ -55,6 +55,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Base extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/libs/wingc/src/jsify/snapshots/preflight_collection.snap b/libs/wingc/src/jsify/snapshots/preflight_collection.snap index a2e0f01dcee..3323d0b5213 100644 --- a/libs/wingc/src/jsify/snapshots/preflight_collection.snap +++ b/libs/wingc/src/jsify/snapshots/preflight_collection.snap @@ -49,6 +49,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/preflight_collection_of_preflight_objects.snap b/libs/wingc/src/jsify/snapshots/preflight_collection_of_preflight_objects.snap index ccbf4ba8352..3c7d184510c 100644 --- a/libs/wingc/src/jsify/snapshots/preflight_collection_of_preflight_objects.snap +++ b/libs/wingc/src/jsify/snapshots/preflight_collection_of_preflight_objects.snap @@ -50,10 +50,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/preflight_nested_object_with_operations.snap b/libs/wingc/src/jsify/snapshots/preflight_nested_object_with_operations.snap index d1f4f50769d..24b2d65c6cc 100644 --- a/libs/wingc/src/jsify/snapshots/preflight_nested_object_with_operations.snap +++ b/libs/wingc/src/jsify/snapshots/preflight_nested_object_with_operations.snap @@ -68,10 +68,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class A extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/libs/wingc/src/jsify/snapshots/preflight_object.snap b/libs/wingc/src/jsify/snapshots/preflight_object.snap index c7d6b9c02a2..a9bbc073db2 100644 --- a/libs/wingc/src/jsify/snapshots/preflight_object.snap +++ b/libs/wingc/src/jsify/snapshots/preflight_object.snap @@ -72,6 +72,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class A extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/libs/wingc/src/jsify/snapshots/preflight_object_through_property.snap b/libs/wingc/src/jsify/snapshots/preflight_object_through_property.snap index 73ae66c5d8a..9408fa25143 100644 --- a/libs/wingc/src/jsify/snapshots/preflight_object_through_property.snap +++ b/libs/wingc/src/jsify/snapshots/preflight_object_through_property.snap @@ -69,10 +69,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class MyType extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/libs/wingc/src/jsify/snapshots/preflight_object_with_operations.snap b/libs/wingc/src/jsify/snapshots/preflight_object_with_operations.snap index 3118c933228..ccfc374b9c7 100644 --- a/libs/wingc/src/jsify/snapshots/preflight_object_with_operations.snap +++ b/libs/wingc/src/jsify/snapshots/preflight_object_with_operations.snap @@ -47,10 +47,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/preflight_object_with_operations_multiple_methods.snap b/libs/wingc/src/jsify/snapshots/preflight_object_with_operations_multiple_methods.snap index 30684d0011d..1151652abb0 100644 --- a/libs/wingc/src/jsify/snapshots/preflight_object_with_operations_multiple_methods.snap +++ b/libs/wingc/src/jsify/snapshots/preflight_object_with_operations_multiple_methods.snap @@ -52,10 +52,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/libs/wingc/src/jsify/snapshots/preflight_value_field.snap b/libs/wingc/src/jsify/snapshots/preflight_value_field.snap index 9a150a8c71d..506fe835563 100644 --- a/libs/wingc/src/jsify/snapshots/preflight_value_field.snap +++ b/libs/wingc/src/jsify/snapshots/preflight_value_field.snap @@ -77,6 +77,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class MyType extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/libs/wingc/src/jsify/snapshots/qualify_inflight_type_refrencing_preflight_instance.snap b/libs/wingc/src/jsify/snapshots/qualify_inflight_type_refrencing_preflight_instance.snap index 39252dbd0ff..81fbf9cf5f8 100644 --- a/libs/wingc/src/jsify/snapshots/qualify_inflight_type_refrencing_preflight_instance.snap +++ b/libs/wingc/src/jsify/snapshots/qualify_inflight_type_refrencing_preflight_instance.snap @@ -23,7 +23,7 @@ source: libs/wingc/src/jsify/tests.rs ``` -## inflight.$Closure1-1.js +## inflight.$Closure1-1.cjs ```js "use strict"; @@ -42,10 +42,10 @@ module.exports = function({ $InflightC }) { } return $Closure1; } -//# sourceMappingURL=inflight.$Closure1-1.js.map +//# sourceMappingURL=inflight.$Closure1-1.cjs.map ``` -## inflight.InflightC-1.js +## inflight.InflightC-1.cjs ```js "use strict"; @@ -58,10 +58,10 @@ module.exports = function({ $pc }) { } return InflightC; } -//# sourceMappingURL=inflight.InflightC-1.js.map +//# sourceMappingURL=inflight.InflightC-1.cjs.map ``` -## inflight.PreflightC-1.js +## inflight.PreflightC-1.cjs ```js "use strict"; @@ -75,10 +75,10 @@ module.exports = function({ }) { } return PreflightC; } -//# sourceMappingURL=inflight.PreflightC-1.js.map +//# sourceMappingURL=inflight.PreflightC-1.cjs.map ``` -## preflight.js +## preflight.cjs ```js "use strict"; @@ -88,16 +88,20 @@ const $outdir = process.env.WING_SYNTH_DIR ?? "."; const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; +const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class PreflightC extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); } static _toInflightType() { return ` - require("${$helpers.normalPath(__dirname)}/inflight.PreflightC-1.js")({ + require("${$helpers.normalPath(__dirname)}/inflight.PreflightC-1.cjs")({ }) `; } @@ -127,7 +131,7 @@ class $Root extends $stdlib.std.Resource { } static _toInflightType() { return ` - require("${$helpers.normalPath(__dirname)}/inflight.InflightC-1.js")({ + require("${$helpers.normalPath(__dirname)}/inflight.InflightC-1.cjs")({ $pc: ${$stdlib.core.liftObject(pc)}, }) `; @@ -154,7 +158,8 @@ class $Root extends $stdlib.std.Resource { }); } } - const $InflightC_1 = new InflightC(this, "$InflightC_1"); + if ($preflightTypesMap[145]) { throw new Error("InflightC is already in type map"); } + $preflightTypesMap[145] = InflightC; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -163,7 +168,7 @@ class $Root extends $stdlib.std.Resource { } static _toInflightType() { return ` - require("${$helpers.normalPath(__dirname)}/inflight.$Closure1-1.js")({ + require("${$helpers.normalPath(__dirname)}/inflight.$Closure1-1.cjs")({ $InflightC: ${$stdlib.core.liftObject(InflightC)}, }) `; @@ -182,11 +187,11 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ - [$InflightC_1, ["foo"]], + [$helpers.nodeof(this).root.$preflightTypesMap[145]._singleton(this,"InflightC_singleton_145"), ["foo"]], [InflightC, []], ], "$inflight_init": [ - [$InflightC_1, []], + [$helpers.nodeof(this).root.$preflightTypesMap[145]._singleton(this,"InflightC_singleton_145"), []], [InflightC, []], ], }); @@ -199,6 +204,6 @@ class $Root extends $stdlib.std.Resource { const $PlatformManager = new $stdlib.platform.PlatformManager({platformPaths: $platforms}); const $APP = $PlatformManager.createApp({ outdir: $outdir, name: "main", rootConstruct: $Root, isTestEnvironment: $wing_is_test, entrypointDir: process.env['WING_SOURCE_DIR'], rootId: process.env['WING_ROOT_ID'] }); $APP.synth(); -//# sourceMappingURL=preflight.js.map +//# sourceMappingURL=preflight.cjs.map ``` diff --git a/libs/wingc/src/jsify/snapshots/read_primitive_value.snap b/libs/wingc/src/jsify/snapshots/read_primitive_value.snap index 774da98ff7f..db2b0b6ac0f 100644 --- a/libs/wingc/src/jsify/snapshots/read_primitive_value.snap +++ b/libs/wingc/src/jsify/snapshots/read_primitive_value.snap @@ -48,6 +48,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/reassign_captured_variable.snap b/libs/wingc/src/jsify/snapshots/reassign_captured_variable.snap index cdab8211e67..2cd0be9082c 100644 --- a/libs/wingc/src/jsify/snapshots/reassign_captured_variable.snap +++ b/libs/wingc/src/jsify/snapshots/reassign_captured_variable.snap @@ -57,6 +57,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/reassigned_captured_variable_preflight.snap b/libs/wingc/src/jsify/snapshots/reassigned_captured_variable_preflight.snap index bbde03ffe57..0d37b640455 100644 --- a/libs/wingc/src/jsify/snapshots/reassigned_captured_variable_preflight.snap +++ b/libs/wingc/src/jsify/snapshots/reassigned_captured_variable_preflight.snap @@ -26,6 +26,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; let i = 10; (() => { i = 12; diff --git a/libs/wingc/src/jsify/snapshots/ref_std_macro.snap b/libs/wingc/src/jsify/snapshots/ref_std_macro.snap index d421e6a3c7d..3156b19bcd9 100644 --- a/libs/wingc/src/jsify/snapshots/ref_std_macro.snap +++ b/libs/wingc/src/jsify/snapshots/ref_std_macro.snap @@ -48,6 +48,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/reference_from_static_inflight.snap b/libs/wingc/src/jsify/snapshots/reference_from_static_inflight.snap index b4e479c49bf..4d446e7d47b 100644 --- a/libs/wingc/src/jsify/snapshots/reference_from_static_inflight.snap +++ b/libs/wingc/src/jsify/snapshots/reference_from_static_inflight.snap @@ -47,6 +47,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class MyType extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/libs/wingc/src/jsify/snapshots/reference_inflight_class.snap b/libs/wingc/src/jsify/snapshots/reference_inflight_class.snap index b08af197219..1983b1e044b 100644 --- a/libs/wingc/src/jsify/snapshots/reference_inflight_class.snap +++ b/libs/wingc/src/jsify/snapshots/reference_inflight_class.snap @@ -66,6 +66,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); @@ -100,7 +103,8 @@ class $Root extends $stdlib.std.Resource { }); } } - const $Foo_0 = new Foo(this, "$Foo_0"); + if ($preflightTypesMap[150]) { throw new Error("Foo is already in type map"); } + $preflightTypesMap[150] = Foo; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/reference_inflight_field.snap b/libs/wingc/src/jsify/snapshots/reference_inflight_field.snap index 28ee4f47cc6..6444a8083db 100644 --- a/libs/wingc/src/jsify/snapshots/reference_inflight_field.snap +++ b/libs/wingc/src/jsify/snapshots/reference_inflight_field.snap @@ -54,6 +54,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/libs/wingc/src/jsify/snapshots/reference_inflight_from_inflight.snap b/libs/wingc/src/jsify/snapshots/reference_inflight_from_inflight.snap index 2d0178ab8f2..1629efec7a4 100644 --- a/libs/wingc/src/jsify/snapshots/reference_inflight_from_inflight.snap +++ b/libs/wingc/src/jsify/snapshots/reference_inflight_from_inflight.snap @@ -78,6 +78,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); @@ -111,7 +114,8 @@ class $Root extends $stdlib.std.Resource { }); } } - const $Foo_0 = new Foo(this, "$Foo_0"); + if ($preflightTypesMap[153]) { throw new Error("Foo is already in type map"); } + $preflightTypesMap[153] = Foo; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/reference_lift_of_collection.snap b/libs/wingc/src/jsify/snapshots/reference_lift_of_collection.snap index 4baa0e5b574..b478fce8fab 100644 --- a/libs/wingc/src/jsify/snapshots/reference_lift_of_collection.snap +++ b/libs/wingc/src/jsify/snapshots/reference_lift_of_collection.snap @@ -48,6 +48,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/reference_preflight_field.snap b/libs/wingc/src/jsify/snapshots/reference_preflight_field.snap index 6d418fe4b67..328f3d3829f 100644 --- a/libs/wingc/src/jsify/snapshots/reference_preflight_field.snap +++ b/libs/wingc/src/jsify/snapshots/reference_preflight_field.snap @@ -52,6 +52,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/libs/wingc/src/jsify/snapshots/reference_preflight_field_call_independent_method.snap b/libs/wingc/src/jsify/snapshots/reference_preflight_field_call_independent_method.snap index 17388473e70..69384186b30 100644 --- a/libs/wingc/src/jsify/snapshots/reference_preflight_field_call_independent_method.snap +++ b/libs/wingc/src/jsify/snapshots/reference_preflight_field_call_independent_method.snap @@ -52,6 +52,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/libs/wingc/src/jsify/snapshots/reference_preflight_fields.snap b/libs/wingc/src/jsify/snapshots/reference_preflight_fields.snap index cabd4783e02..27863adcafe 100644 --- a/libs/wingc/src/jsify/snapshots/reference_preflight_fields.snap +++ b/libs/wingc/src/jsify/snapshots/reference_preflight_fields.snap @@ -65,10 +65,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class MyType extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/libs/wingc/src/jsify/snapshots/reference_preflight_free_variable_with_this_in_the_expression.snap b/libs/wingc/src/jsify/snapshots/reference_preflight_free_variable_with_this_in_the_expression.snap index f7b74ca97e8..7630bff1ae1 100644 --- a/libs/wingc/src/jsify/snapshots/reference_preflight_free_variable_with_this_in_the_expression.snap +++ b/libs/wingc/src/jsify/snapshots/reference_preflight_free_variable_with_this_in_the_expression.snap @@ -52,10 +52,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/libs/wingc/src/jsify/snapshots/reference_preflight_object_from_static_inflight.snap b/libs/wingc/src/jsify/snapshots/reference_preflight_object_from_static_inflight.snap index bee06339319..efc8fc0eed4 100644 --- a/libs/wingc/src/jsify/snapshots/reference_preflight_object_from_static_inflight.snap +++ b/libs/wingc/src/jsify/snapshots/reference_preflight_object_from_static_inflight.snap @@ -46,10 +46,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class MyType extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/libs/wingc/src/jsify/snapshots/reference_static_inflight.snap b/libs/wingc/src/jsify/snapshots/reference_static_inflight.snap index 39e5714deae..8b105fd7f38 100644 --- a/libs/wingc/src/jsify/snapshots/reference_static_inflight.snap +++ b/libs/wingc/src/jsify/snapshots/reference_static_inflight.snap @@ -68,6 +68,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class MyType extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/libs/wingc/src/jsify/snapshots/reference_static_inflight_which_references_preflight_object.snap b/libs/wingc/src/jsify/snapshots/reference_static_inflight_which_references_preflight_object.snap index 5fe4ab94cc7..c79a04b67f9 100644 --- a/libs/wingc/src/jsify/snapshots/reference_static_inflight_which_references_preflight_object.snap +++ b/libs/wingc/src/jsify/snapshots/reference_static_inflight_which_references_preflight_object.snap @@ -73,10 +73,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class MyType extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/libs/wingc/src/jsify/snapshots/static_external_inflight_class.snap b/libs/wingc/src/jsify/snapshots/static_external_inflight_class.snap index 765b9f9c40b..1b0ef8e70f6 100644 --- a/libs/wingc/src/jsify/snapshots/static_external_inflight_class.snap +++ b/libs/wingc/src/jsify/snapshots/static_external_inflight_class.snap @@ -77,6 +77,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class A extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); @@ -111,7 +114,8 @@ class $Root extends $stdlib.std.Resource { }); } } - const $A_0 = new A(this, "$A_0"); + if ($preflightTypesMap[164]) { throw new Error("A is already in type map"); } + $preflightTypesMap[164] = A; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/static_external_preflight_class.snap b/libs/wingc/src/jsify/snapshots/static_external_preflight_class.snap index 6bdecac309e..1fbad7370de 100644 --- a/libs/wingc/src/jsify/snapshots/static_external_preflight_class.snap +++ b/libs/wingc/src/jsify/snapshots/static_external_preflight_class.snap @@ -76,6 +76,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class A extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/libs/wingc/src/jsify/snapshots/static_inflight_operation.snap b/libs/wingc/src/jsify/snapshots/static_inflight_operation.snap index a3afeeb210c..562280f0c7d 100644 --- a/libs/wingc/src/jsify/snapshots/static_inflight_operation.snap +++ b/libs/wingc/src/jsify/snapshots/static_inflight_operation.snap @@ -70,10 +70,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class A extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/libs/wingc/src/jsify/snapshots/static_local_inflight_class.snap b/libs/wingc/src/jsify/snapshots/static_local_inflight_class.snap index ddd7d0bbc12..e93803cd00f 100644 --- a/libs/wingc/src/jsify/snapshots/static_local_inflight_class.snap +++ b/libs/wingc/src/jsify/snapshots/static_local_inflight_class.snap @@ -68,6 +68,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/static_on_std_type.snap b/libs/wingc/src/jsify/snapshots/static_on_std_type.snap index e557b9ccb81..a8ddfb7e07e 100644 --- a/libs/wingc/src/jsify/snapshots/static_on_std_type.snap +++ b/libs/wingc/src/jsify/snapshots/static_on_std_type.snap @@ -48,6 +48,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/transitive_reference.snap b/libs/wingc/src/jsify/snapshots/transitive_reference.snap index 847626e2f23..ae54a46416d 100644 --- a/libs/wingc/src/jsify/snapshots/transitive_reference.snap +++ b/libs/wingc/src/jsify/snapshots/transitive_reference.snap @@ -88,10 +88,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class MyType extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/libs/wingc/src/jsify/snapshots/transitive_reference_via_inflight_class.snap b/libs/wingc/src/jsify/snapshots/transitive_reference_via_inflight_class.snap index b6cdbc5ad15..b32096c8259 100644 --- a/libs/wingc/src/jsify/snapshots/transitive_reference_via_inflight_class.snap +++ b/libs/wingc/src/jsify/snapshots/transitive_reference_via_inflight_class.snap @@ -71,10 +71,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class MyInflightClass extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); @@ -108,7 +111,8 @@ class $Root extends $stdlib.std.Resource { }); } } - const $MyInflightClass_0 = new MyInflightClass(this, "$MyInflightClass_0"); + if ($preflightTypesMap[180]) { throw new Error("MyInflightClass is already in type map"); } + $preflightTypesMap[180] = MyInflightClass; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -136,11 +140,11 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ - [$MyInflightClass_0, ["putInBucket"]], + [$helpers.nodeof(this).root.$preflightTypesMap[180]._singleton(this,"MyInflightClass_singleton_180"), ["putInBucket"]], [MyInflightClass, []], ], "$inflight_init": [ - [$MyInflightClass_0, []], + [$helpers.nodeof(this).root.$preflightTypesMap[180]._singleton(this,"MyInflightClass_singleton_180"), []], [MyInflightClass, []], ], }); diff --git a/libs/wingc/src/jsify/snapshots/transitive_reference_via_static.snap b/libs/wingc/src/jsify/snapshots/transitive_reference_via_static.snap index 6360ecad233..1b0e1405a7e 100644 --- a/libs/wingc/src/jsify/snapshots/transitive_reference_via_static.snap +++ b/libs/wingc/src/jsify/snapshots/transitive_reference_via_static.snap @@ -96,10 +96,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class MyType extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/libs/wingc/src/jsify/snapshots/two_identical_lifts.snap b/libs/wingc/src/jsify/snapshots/two_identical_lifts.snap index bc7e393332e..ae17e2d8048 100644 --- a/libs/wingc/src/jsify/snapshots/two_identical_lifts.snap +++ b/libs/wingc/src/jsify/snapshots/two_identical_lifts.snap @@ -53,10 +53,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const cloud = $stdlib.cloud; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const cloud = $stdlib.cloud; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/use_util_functions.snap b/libs/wingc/src/jsify/snapshots/use_util_functions.snap index 9689b11fc30..6df9d47b4ac 100644 --- a/libs/wingc/src/jsify/snapshots/use_util_functions.snap +++ b/libs/wingc/src/jsify/snapshots/use_util_functions.snap @@ -43,10 +43,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const util = $stdlib.util; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const util = $stdlib.util; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/var_inflight_field_from_inflight.snap b/libs/wingc/src/jsify/snapshots/var_inflight_field_from_inflight.snap index d0e74b4002d..4b1282f2b4b 100644 --- a/libs/wingc/src/jsify/snapshots/var_inflight_field_from_inflight.snap +++ b/libs/wingc/src/jsify/snapshots/var_inflight_field_from_inflight.snap @@ -54,6 +54,9 @@ const $extern = $helpers.createExternRequire(__dirname); class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class MyType extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/libs/wingc/src/jsify/snapshots/wait_util.snap b/libs/wingc/src/jsify/snapshots/wait_util.snap index 27f00d0271a..baae474a327 100644 --- a/libs/wingc/src/jsify/snapshots/wait_util.snap +++ b/libs/wingc/src/jsify/snapshots/wait_util.snap @@ -50,10 +50,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const util = $stdlib.util; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const util = $stdlib.util; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { From 6783e2fbd57a0a91fe32bd95bc9c32908497b185 Mon Sep 17 00:00:00 2001 From: Yoav Steinberg Date: Thu, 13 Jun 2024 14:55:05 +0300 Subject: [PATCH 46/78] tests --- .../valid/inflight_class_capture_preflight_object.test.w | 9 ++++++++- examples/tests/valid/subdir2/inflight_class.w | 5 +++++ 2 files changed, 13 insertions(+), 1 deletion(-) create mode 100644 examples/tests/valid/subdir2/inflight_class.w diff --git a/examples/tests/valid/inflight_class_capture_preflight_object.test.w b/examples/tests/valid/inflight_class_capture_preflight_object.test.w index eaedad92c3a..e23242ddb45 100644 --- a/examples/tests/valid/inflight_class_capture_preflight_object.test.w +++ b/examples/tests/valid/inflight_class_capture_preflight_object.test.w @@ -1,4 +1,5 @@ bring cloud; +bring "./subdir2" as subdir; let b = new cloud.Bucket(); @@ -9,7 +10,8 @@ inflight class Foo { } static pub fooStatic() { - b.list(); + b.put("a", "b"); + assert(b.list() == ["a"]); } } @@ -45,3 +47,8 @@ test "inflight class defined inflight captures preflight object" { let f = new Foo2(); f.uploadToBucket(); } + +test "bring inflight class from subdir" { + let x = new subdir.InflightClass(); + assert(x.method() == "What did you expect?"); +} diff --git a/examples/tests/valid/subdir2/inflight_class.w b/examples/tests/valid/subdir2/inflight_class.w new file mode 100644 index 00000000000..bdf37243fe0 --- /dev/null +++ b/examples/tests/valid/subdir2/inflight_class.w @@ -0,0 +1,5 @@ +pub inflight class InflightClass { + pub method(): str { + return "What did you expect?"; + } +} \ No newline at end of file From 4747daac1b3d67e93154aca62690e264683dff88 Mon Sep 17 00:00:00 2001 From: Yoav Steinberg Date: Thu, 13 Jun 2024 15:27:17 +0300 Subject: [PATCH 47/78] cleanup --- libs/wingc/src/ast.rs | 19 +------------------ libs/wingc/src/closure_transform.rs | 2 +- libs/wingc/src/fold.rs | 1 - libs/wingc/src/parser.rs | 6 ++---- 4 files changed, 4 insertions(+), 24 deletions(-) diff --git a/libs/wingc/src/ast.rs b/libs/wingc/src/ast.rs index 814eb5a44a3..dacd44ce302 100644 --- a/libs/wingc/src/ast.rs +++ b/libs/wingc/src/ast.rs @@ -710,29 +710,12 @@ pub struct Expr { pub kind: ExprKind, /// The span of the expression. pub span: WingSpan, - /// The expression is a callee in a call expression - pub is_callee: bool, } impl Expr { pub fn new(kind: ExprKind, span: WingSpan) -> Self { let id = EXPR_COUNTER.fetch_add(1, Ordering::SeqCst); - Self { - id, - kind, - is_callee: false, - span, - } - } - - pub fn new_callee(kind: ExprKind, span: WingSpan) -> Self { - let id = EXPR_COUNTER.fetch_add(1, Ordering::SeqCst); - Self { - id, - kind, - is_callee: true, - span, - } + Self { id, kind, span } } pub fn as_static_string(&self) -> Option<&str> { diff --git a/libs/wingc/src/closure_transform.rs b/libs/wingc/src/closure_transform.rs index d03e94dc012..6d85628ecac 100644 --- a/libs/wingc/src/closure_transform.rs +++ b/libs/wingc/src/closure_transform.rs @@ -186,7 +186,7 @@ impl Fold for ClosureTransformer { // ``` let std_display_of_this = Expr::new( ExprKind::Call { - callee: CalleeKind::Expr(Box::new(Expr::new_callee( + callee: CalleeKind::Expr(Box::new(Expr::new( ExprKind::Reference(Reference::Identifier(Symbol::new( "nodeof", WingSpan::for_file(file_id), diff --git a/libs/wingc/src/fold.rs b/libs/wingc/src/fold.rs index f94c756f682..5881d7487a3 100644 --- a/libs/wingc/src/fold.rs +++ b/libs/wingc/src/fold.rs @@ -400,7 +400,6 @@ where id: node.id, kind, span: node.span, - is_callee: node.is_callee, } } diff --git a/libs/wingc/src/parser.rs b/libs/wingc/src/parser.rs index 37023672a02..04b1fb8cbda 100644 --- a/libs/wingc/src/parser.rs +++ b/libs/wingc/src/parser.rs @@ -537,7 +537,7 @@ impl<'s> Parser<'s> { // represent duration literals as the AST equivalent of `duration.fromSeconds(value)` Ok(Expr::new( ExprKind::Call { - callee: CalleeKind::Expr(Box::new(Expr::new_callee( + callee: CalleeKind::Expr(Box::new(Expr::new( ExprKind::Reference(Reference::InstanceMember { object: Box::new(Expr::new( ExprKind::Reference(Reference::Identifier(Symbol { @@ -2309,9 +2309,7 @@ impl<'s> Parser<'s> { let callee = if caller_node.kind() == "super_call" { CalleeKind::SuperCall(self.node_symbol(&caller_node.child_by_field_name("method").unwrap())?) } else { - let mut callee_expr = self.build_expression(&caller_node, phase)?; - callee_expr.is_callee = true; - CalleeKind::Expr(Box::new(callee_expr)) + CalleeKind::Expr(Box::new(self.build_expression(&caller_node, phase)?)) }; Ok(Expr::new( ExprKind::Call { From 7e6b6ce0f44f90deaed81a0c804cc9f93933b0f0 Mon Sep 17 00:00:00 2001 From: "monada-bot[bot]" Date: Thu, 13 Jun 2024 12:41:14 +0000 Subject: [PATCH 48/78] chore: self mutation (build.diff) Signed-off-by: monada-bot[bot] --- .../call_static_inflight_from_static_inflight.snap | 4 ++-- .../snapshots/capture_type_new_inflight_class_outer.snap | 4 ++-- .../snapshots/inflight_field_from_inflight_class.snap | 4 ++-- ...alify_inflight_type_refrencing_preflight_instance.snap | 8 ++++---- .../jsify/snapshots/reference_inflight_from_inflight.snap | 4 ++-- .../jsify/snapshots/static_external_inflight_class.snap | 4 ++-- 6 files changed, 14 insertions(+), 14 deletions(-) diff --git a/libs/wingc/src/jsify/snapshots/call_static_inflight_from_static_inflight.snap b/libs/wingc/src/jsify/snapshots/call_static_inflight_from_static_inflight.snap index 9226085eb2c..2036add1c87 100644 --- a/libs/wingc/src/jsify/snapshots/call_static_inflight_from_static_inflight.snap +++ b/libs/wingc/src/jsify/snapshots/call_static_inflight_from_static_inflight.snap @@ -139,8 +139,8 @@ class $Root extends $stdlib.std.Resource { }); } } - if ($preflightTypesMap[22]) { throw new Error("B is already in type map"); } - $preflightTypesMap[22] = B; + if ($preflightTypesMap[24]) { throw new Error("B is already in type map"); } + $preflightTypesMap[24] = B; } } const $PlatformManager = new $stdlib.platform.PlatformManager({platformPaths: $platforms}); diff --git a/libs/wingc/src/jsify/snapshots/capture_type_new_inflight_class_outer.snap b/libs/wingc/src/jsify/snapshots/capture_type_new_inflight_class_outer.snap index c8229643dc1..56ba03ea5bf 100644 --- a/libs/wingc/src/jsify/snapshots/capture_type_new_inflight_class_outer.snap +++ b/libs/wingc/src/jsify/snapshots/capture_type_new_inflight_class_outer.snap @@ -92,8 +92,8 @@ class $Root extends $stdlib.std.Resource { }); } } - if ($preflightTypesMap[45]) { throw new Error("Foo is already in type map"); } - $preflightTypesMap[45] = Foo; + if ($preflightTypesMap[47]) { throw new Error("Foo is already in type map"); } + $preflightTypesMap[47] = Foo; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/inflight_field_from_inflight_class.snap b/libs/wingc/src/jsify/snapshots/inflight_field_from_inflight_class.snap index 4fc845ba25c..f2407f1702d 100644 --- a/libs/wingc/src/jsify/snapshots/inflight_field_from_inflight_class.snap +++ b/libs/wingc/src/jsify/snapshots/inflight_field_from_inflight_class.snap @@ -88,8 +88,8 @@ class $Root extends $stdlib.std.Resource { }); } } - if ($preflightTypesMap[93]) { throw new Error("MyType is already in type map"); } - $preflightTypesMap[93] = MyType; + if ($preflightTypesMap[92]) { throw new Error("MyType is already in type map"); } + $preflightTypesMap[92] = MyType; } } const $PlatformManager = new $stdlib.platform.PlatformManager({platformPaths: $platforms}); diff --git a/libs/wingc/src/jsify/snapshots/qualify_inflight_type_refrencing_preflight_instance.snap b/libs/wingc/src/jsify/snapshots/qualify_inflight_type_refrencing_preflight_instance.snap index 81fbf9cf5f8..ad0d188e1f3 100644 --- a/libs/wingc/src/jsify/snapshots/qualify_inflight_type_refrencing_preflight_instance.snap +++ b/libs/wingc/src/jsify/snapshots/qualify_inflight_type_refrencing_preflight_instance.snap @@ -158,8 +158,8 @@ class $Root extends $stdlib.std.Resource { }); } } - if ($preflightTypesMap[145]) { throw new Error("InflightC is already in type map"); } - $preflightTypesMap[145] = InflightC; + if ($preflightTypesMap[144]) { throw new Error("InflightC is already in type map"); } + $preflightTypesMap[144] = InflightC; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -187,11 +187,11 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ - [$helpers.nodeof(this).root.$preflightTypesMap[145]._singleton(this,"InflightC_singleton_145"), ["foo"]], + [$helpers.nodeof(this).root.$preflightTypesMap[144]._singleton(this,"InflightC_singleton_144"), ["foo"]], [InflightC, []], ], "$inflight_init": [ - [$helpers.nodeof(this).root.$preflightTypesMap[145]._singleton(this,"InflightC_singleton_145"), []], + [$helpers.nodeof(this).root.$preflightTypesMap[144]._singleton(this,"InflightC_singleton_144"), []], [InflightC, []], ], }); diff --git a/libs/wingc/src/jsify/snapshots/reference_inflight_from_inflight.snap b/libs/wingc/src/jsify/snapshots/reference_inflight_from_inflight.snap index 1629efec7a4..f533490fec7 100644 --- a/libs/wingc/src/jsify/snapshots/reference_inflight_from_inflight.snap +++ b/libs/wingc/src/jsify/snapshots/reference_inflight_from_inflight.snap @@ -114,8 +114,8 @@ class $Root extends $stdlib.std.Resource { }); } } - if ($preflightTypesMap[153]) { throw new Error("Foo is already in type map"); } - $preflightTypesMap[153] = Foo; + if ($preflightTypesMap[152]) { throw new Error("Foo is already in type map"); } + $preflightTypesMap[152] = Foo; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/static_external_inflight_class.snap b/libs/wingc/src/jsify/snapshots/static_external_inflight_class.snap index 1b0ef8e70f6..d7b42b481f6 100644 --- a/libs/wingc/src/jsify/snapshots/static_external_inflight_class.snap +++ b/libs/wingc/src/jsify/snapshots/static_external_inflight_class.snap @@ -114,8 +114,8 @@ class $Root extends $stdlib.std.Resource { }); } } - if ($preflightTypesMap[164]) { throw new Error("A is already in type map"); } - $preflightTypesMap[164] = A; + if ($preflightTypesMap[163]) { throw new Error("A is already in type map"); } + $preflightTypesMap[163] = A; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { From 90521a6752540f0edb24920e6acece5967b348b9 Mon Sep 17 00:00:00 2001 From: "monada-bot[bot]" Date: Thu, 13 Jun 2024 12:41:14 +0000 Subject: [PATCH 49/78] chore: self mutation (e2e-1of2.diff) Signed-off-by: monada-bot[bot] --- ..._preflight_object.test.w_compile_tf-aws.md | 427 ++++++++++++++++-- ...apture_preflight_object.test.w_test_sim.md | 3 +- 2 files changed, 403 insertions(+), 27 deletions(-) diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_capture_preflight_object.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_capture_preflight_object.test.w_compile_tf-aws.md index 5bf185d8f18..e474158dd57 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_capture_preflight_object.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_capture_preflight_object.test.w_compile_tf-aws.md @@ -1,6 +1,6 @@ # [inflight_class_capture_preflight_object.test.w](../../../../../examples/tests/valid/inflight_class_capture_preflight_object.test.w) | compile | tf-aws -## inflight.$Closure1-1.cjs +## inflight.$Closure1-5.cjs ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); @@ -18,10 +18,10 @@ module.exports = function({ $Foo }) { } return $Closure1; } -//# sourceMappingURL=inflight.$Closure1-1.cjs.map +//# sourceMappingURL=inflight.$Closure1-5.cjs.map ``` -## inflight.$Closure2-1.cjs +## inflight.$Closure2-5.cjs ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); @@ -38,10 +38,10 @@ module.exports = function({ $Foo }) { } return $Closure2; } -//# sourceMappingURL=inflight.$Closure2-1.cjs.map +//# sourceMappingURL=inflight.$Closure2-5.cjs.map ``` -## inflight.$Closure3-1.cjs +## inflight.$Closure3-5.cjs ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); @@ -58,10 +58,10 @@ module.exports = function({ $Foo }) { } return $Closure3; } -//# sourceMappingURL=inflight.$Closure3-1.cjs.map +//# sourceMappingURL=inflight.$Closure3-5.cjs.map ``` -## inflight.$Closure4-1.cjs +## inflight.$Closure4-5.cjs ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); @@ -79,10 +79,10 @@ module.exports = function({ $getFoo }) { } return $Closure4; } -//# sourceMappingURL=inflight.$Closure4-1.cjs.map +//# sourceMappingURL=inflight.$Closure4-5.cjs.map ``` -## inflight.$Closure5-1.cjs +## inflight.$Closure5-5.cjs ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); @@ -106,10 +106,73 @@ module.exports = function({ $b }) { } return $Closure5; } -//# sourceMappingURL=inflight.$Closure5-1.cjs.map +//# sourceMappingURL=inflight.$Closure5-5.cjs.map ``` -## inflight.Foo-1.cjs +## inflight.$Closure6-5.cjs +```cjs +"use strict"; +const $helpers = require("@winglang/sdk/lib/helpers"); +module.exports = function({ $subdir_InflightClass }) { + class $Closure6 { + constructor({ }) { + const $obj = (...args) => this.handle(...args); + Object.setPrototypeOf($obj, this); + return $obj; + } + async handle() { + const x = (await (async () => {const o = new $subdir_InflightClass(); await o.$inflight_init?.(); return o; })()); + $helpers.assert($helpers.eq((await x.method()), "What did you expect?"), "x.method() == \"What did you expect?\""); + } + } + return $Closure6; +} +//# sourceMappingURL=inflight.$Closure6-5.cjs.map +``` + +## inflight.Bar-3.cjs +```cjs +"use strict"; +const $helpers = require("@winglang/sdk/lib/helpers"); +module.exports = function({ }) { + class Bar { + constructor({ }) { + } + } + return Bar; +} +//# sourceMappingURL=inflight.Bar-3.cjs.map +``` + +## inflight.Foo-2.cjs +```cjs +"use strict"; +const $helpers = require("@winglang/sdk/lib/helpers"); +module.exports = function({ }) { + class Foo { + constructor({ }) { + } + } + return Foo; +} +//# sourceMappingURL=inflight.Foo-2.cjs.map +``` + +## inflight.Foo-3.cjs +```cjs +"use strict"; +const $helpers = require("@winglang/sdk/lib/helpers"); +module.exports = function({ }) { + class Foo { + constructor({ }) { + } + } + return Foo; +} +//# sourceMappingURL=inflight.Foo-3.cjs.map +``` + +## inflight.Foo-5.cjs ```cjs "use strict"; const $helpers = require("@winglang/sdk/lib/helpers"); @@ -120,12 +183,42 @@ module.exports = function({ $b }) { $helpers.assert($helpers.eq((await $b.get(k)), value), "b.get(k) == value"); } static async fooStatic() { - (await $b.list()); + (await $b.put("a", "b")); + $helpers.assert($helpers.eq((await $b.list()), ["a"]), "b.list() == [\"a\"]"); } } return Foo; } -//# sourceMappingURL=inflight.Foo-1.cjs.map +//# sourceMappingURL=inflight.Foo-5.cjs.map +``` + +## inflight.InflightClass-4.cjs +```cjs +"use strict"; +const $helpers = require("@winglang/sdk/lib/helpers"); +module.exports = function({ }) { + class InflightClass { + async method() { + return "What did you expect?"; + } + } + return InflightClass; +} +//# sourceMappingURL=inflight.InflightClass-4.cjs.map +``` + +## inflight.Widget-1.cjs +```cjs +"use strict"; +const $helpers = require("@winglang/sdk/lib/helpers"); +module.exports = function({ }) { + class Widget { + constructor({ }) { + } + } + return Widget; +} +//# sourceMappingURL=inflight.Widget-1.cjs.map ``` ## main.tf.json @@ -177,6 +270,8 @@ class $Root extends $stdlib.std.Resource { $helpers.nodeof(this).root.$preflightTypesMap = { }; let $preflightTypesMap = {}; const cloud = $stdlib.cloud; + const subdir = require("./preflight.subdir2-6.cjs"); + Object.assign($preflightTypesMap, subdir.$preflightTypesMap); $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { @@ -184,7 +279,7 @@ class $Root extends $stdlib.std.Resource { } static _toInflightType() { return ` - require("${$helpers.normalPath(__dirname)}/inflight.Foo-1.cjs")({ + require("${$helpers.normalPath(__dirname)}/inflight.Foo-5.cjs")({ $b: ${$stdlib.core.liftObject(b)}, }) `; @@ -213,13 +308,13 @@ class $Root extends $stdlib.std.Resource { static get _liftTypeMap() { return ({ "fooStatic": [ - [b, ["list"]], + [b, [].concat(["put"], ["list"])], ], }); } } - if ($preflightTypesMap[0]) { throw new Error("Foo is already in type map"); } - $preflightTypesMap[0] = Foo; + if ($preflightTypesMap[5]) { throw new Error("Foo is already in type map"); } + $preflightTypesMap[5] = Foo; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -228,7 +323,7 @@ class $Root extends $stdlib.std.Resource { } static _toInflightType() { return ` - require("${$helpers.normalPath(__dirname)}/inflight.$Closure1-1.cjs")({ + require("${$helpers.normalPath(__dirname)}/inflight.$Closure1-5.cjs")({ $Foo: ${$stdlib.core.liftObject(Foo)}, }) `; @@ -247,11 +342,11 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ - [$helpers.nodeof(this).root.$preflightTypesMap[0]._singleton(this,"Foo_singleton_0"), ["uploadToBucket"]], + [$helpers.nodeof(this).root.$preflightTypesMap[5]._singleton(this,"Foo_singleton_5"), ["uploadToBucket"]], [Foo, []], ], "$inflight_init": [ - [$helpers.nodeof(this).root.$preflightTypesMap[0]._singleton(this,"Foo_singleton_0"), []], + [$helpers.nodeof(this).root.$preflightTypesMap[5]._singleton(this,"Foo_singleton_5"), []], [Foo, []], ], }); @@ -265,7 +360,7 @@ class $Root extends $stdlib.std.Resource { } static _toInflightType() { return ` - require("${$helpers.normalPath(__dirname)}/inflight.$Closure2-1.cjs")({ + require("${$helpers.normalPath(__dirname)}/inflight.$Closure2-5.cjs")({ $Foo: ${$stdlib.core.liftObject(Foo)}, }) `; @@ -300,7 +395,7 @@ class $Root extends $stdlib.std.Resource { } static _toInflightType() { return ` - require("${$helpers.normalPath(__dirname)}/inflight.$Closure3-1.cjs")({ + require("${$helpers.normalPath(__dirname)}/inflight.$Closure3-5.cjs")({ $Foo: ${$stdlib.core.liftObject(Foo)}, }) `; @@ -335,7 +430,7 @@ class $Root extends $stdlib.std.Resource { } static _toInflightType() { return ` - require("${$helpers.normalPath(__dirname)}/inflight.$Closure4-1.cjs")({ + require("${$helpers.normalPath(__dirname)}/inflight.$Closure4-5.cjs")({ $getFoo: ${$stdlib.core.liftObject(getFoo)}, }) `; @@ -354,11 +449,11 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ - [$helpers.nodeof(this).root.$preflightTypesMap[0]._singleton(this,"Foo_singleton_0"), ["uploadToBucket"]], + [$helpers.nodeof(this).root.$preflightTypesMap[5]._singleton(this,"Foo_singleton_5"), ["uploadToBucket"]], [getFoo, ["handle"]], ], "$inflight_init": [ - [$helpers.nodeof(this).root.$preflightTypesMap[0]._singleton(this,"Foo_singleton_0"), []], + [$helpers.nodeof(this).root.$preflightTypesMap[5]._singleton(this,"Foo_singleton_5"), []], [getFoo, []], ], }); @@ -372,7 +467,7 @@ class $Root extends $stdlib.std.Resource { } static _toInflightType() { return ` - require("${$helpers.normalPath(__dirname)}/inflight.$Closure5-1.cjs")({ + require("${$helpers.normalPath(__dirname)}/inflight.$Closure5-5.cjs")({ $b: ${$stdlib.core.liftObject(b)}, }) `; @@ -399,12 +494,50 @@ class $Root extends $stdlib.std.Resource { }); } } + class $Closure6 extends $stdlib.std.AutoIdResource { + _id = $stdlib.core.closureId(); + constructor($scope, $id, ) { + super($scope, $id); + $helpers.nodeof(this).hidden = true; + } + static _toInflightType() { + return ` + require("${$helpers.normalPath(__dirname)}/inflight.$Closure6-5.cjs")({ + $subdir_InflightClass: ${$stdlib.core.liftObject($stdlib.core.toLiftableModuleType(subdir.InflightClass, "", "InflightClass"))}, + }) + `; + } + _toInflight() { + return ` + (await (async () => { + const $Closure6Client = ${$Closure6._toInflightType()}; + const client = new $Closure6Client({ + }); + if (client.$inflight_init) { await client.$inflight_init(); } + return client; + })()) + `; + } + get _liftMap() { + return ({ + "handle": [ + [$helpers.nodeof(this).root.$preflightTypesMap[4]._singleton(this,"InflightClass_singleton_4"), ["method"]], + [$stdlib.core.toLiftableModuleType(subdir.InflightClass, "", "InflightClass"), []], + ], + "$inflight_init": [ + [$helpers.nodeof(this).root.$preflightTypesMap[4]._singleton(this,"InflightClass_singleton_4"), []], + [$stdlib.core.toLiftableModuleType(subdir.InflightClass, "", "InflightClass"), []], + ], + }); + } + } const b = this.node.root.new("@winglang/sdk.cloud.Bucket", cloud.Bucket, this, "Bucket"); this.node.root.new("@winglang/sdk.std.Test", std.Test, this, "test:inflight class captures preflight resource", new $Closure1(this, "$Closure1")); this.node.root.new("@winglang/sdk.std.Test", std.Test, this, "test:inflight class type captures preflight resource", new $Closure2(this, "$Closure2")); const getFoo = new $Closure3(this, "$Closure3"); this.node.root.new("@winglang/sdk.std.Test", std.Test, this, "test:inflight class qualified without explicit reference", new $Closure4(this, "$Closure4")); this.node.root.new("@winglang/sdk.std.Test", std.Test, this, "test:inflight class defined inflight captures preflight object", new $Closure5(this, "$Closure5")); + this.node.root.new("@winglang/sdk.std.Test", std.Test, this, "test:bring inflight class from subdir", new $Closure6(this, "$Closure6")); } } const $PlatformManager = new $stdlib.platform.PlatformManager({platformPaths: $platforms}); @@ -413,3 +546,245 @@ $APP.synth(); //# sourceMappingURL=preflight.cjs.map ``` +## preflight.file1-3.cjs +```cjs +"use strict"; +const $stdlib = require('@winglang/sdk'); +const std = $stdlib.std; +const $helpers = $stdlib.helpers; +const $extern = $helpers.createExternRequire(__dirname); +let $preflightTypesMap = {}; +const blah = require("./preflight.inner-2.cjs"); +Object.assign($preflightTypesMap, blah.$preflightTypesMap); +const cloud = $stdlib.cloud; +const util = $stdlib.util; +class Foo extends $stdlib.std.Resource { + constructor($scope, $id, ) { + super($scope, $id); + } + foo() { + return "foo"; + } + checkWidget(widget) { + return ((widget.compute()) + (blah.Widget.staticCompute(this))); + } + static _toInflightType() { + return ` + require("${$helpers.normalPath(__dirname)}/inflight.Foo-2.cjs")({ + }) + `; + } + _toInflight() { + return ` + (await (async () => { + const FooClient = ${Foo._toInflightType()}; + const client = new FooClient({ + }); + if (client.$inflight_init) { await client.$inflight_init(); } + return client; + })()) + `; + } + get _liftMap() { + return ({ + "$inflight_init": [ + ], + }); + } +} +module.exports = { $preflightTypesMap, Foo }; +//# sourceMappingURL=preflight.file1-3.cjs.map +``` + +## preflight.file2-4.cjs +```cjs +"use strict"; +const $stdlib = require('@winglang/sdk'); +const std = $stdlib.std; +const $helpers = $stdlib.helpers; +const $extern = $helpers.createExternRequire(__dirname); +let $preflightTypesMap = {}; +const util = $stdlib.util; +class Bar extends $stdlib.std.Resource { + constructor($scope, $id, ) { + super($scope, $id); + } + bar() { + (util.Util.nanoid()); + return "bar"; + } + static _toInflightType() { + return ` + require("${$helpers.normalPath(__dirname)}/inflight.Bar-3.cjs")({ + }) + `; + } + _toInflight() { + return ` + (await (async () => { + const BarClient = ${Bar._toInflightType()}; + const client = new BarClient({ + }); + if (client.$inflight_init) { await client.$inflight_init(); } + return client; + })()) + `; + } + get _liftMap() { + return ({ + "$inflight_init": [ + ], + }); + } +} +class Foo extends $stdlib.std.Resource { + constructor($scope, $id, ) { + super($scope, $id); + } + static _toInflightType() { + return ` + require("${$helpers.normalPath(__dirname)}/inflight.Foo-3.cjs")({ + }) + `; + } + _toInflight() { + return ` + (await (async () => { + const FooClient = ${Foo._toInflightType()}; + const client = new FooClient({ + }); + if (client.$inflight_init) { await client.$inflight_init(); } + return client; + })()) + `; + } + get _liftMap() { + return ({ + "$inflight_init": [ + ], + }); + } +} +module.exports = { $preflightTypesMap, Bar }; +//# sourceMappingURL=preflight.file2-4.cjs.map +``` + +## preflight.inflightclass-5.cjs +```cjs +"use strict"; +const $stdlib = require('@winglang/sdk'); +const std = $stdlib.std; +const $helpers = $stdlib.helpers; +const $extern = $helpers.createExternRequire(__dirname); +let $preflightTypesMap = {}; +class InflightClass extends $stdlib.std.Resource { + constructor($scope, $id, ) { + super($scope, $id); + } + static _toInflightType() { + return ` + require("${$helpers.normalPath(__dirname)}/inflight.InflightClass-4.cjs")({ + }) + `; + } + _toInflight() { + return ` + (await (async () => { + const InflightClassClient = ${InflightClass._toInflightType()}; + const client = new InflightClassClient({ + }); + if (client.$inflight_init) { await client.$inflight_init(); } + return client; + })()) + `; + } + get _liftMap() { + return ({ + "method": [ + ], + "$inflight_init": [ + ], + }); + } +} +if ($preflightTypesMap[4]) { throw new Error("InflightClass is already in type map"); } +$preflightTypesMap[4] = InflightClass; +module.exports = { $preflightTypesMap, InflightClass }; +//# sourceMappingURL=preflight.inflightclass-5.cjs.map +``` + +## preflight.inner-2.cjs +```cjs +"use strict"; +const $stdlib = require('@winglang/sdk'); +const std = $stdlib.std; +const $helpers = $stdlib.helpers; +const $extern = $helpers.createExternRequire(__dirname); +let $preflightTypesMap = {}; +Object.assign(module.exports, $helpers.bringJs(`${__dirname}/preflight.widget-1.cjs`, "$preflightTypesMap", $preflightTypesMap)); +module.exports = { ...module.exports, $preflightTypesMap }; +//# sourceMappingURL=preflight.inner-2.cjs.map +``` + +## preflight.subdir2-6.cjs +```cjs +"use strict"; +const $stdlib = require('@winglang/sdk'); +const std = $stdlib.std; +const $helpers = $stdlib.helpers; +const $extern = $helpers.createExternRequire(__dirname); +let $preflightTypesMap = {}; +Object.assign(module.exports, { get inner() { return $helpers.bringJs(`${__dirname}/preflight.inner-2.cjs`, "$preflightTypesMap", $preflightTypesMap); } }); +Object.assign(module.exports, $helpers.bringJs(`${__dirname}/preflight.inflightclass-5.cjs`, "$preflightTypesMap", $preflightTypesMap)); +Object.assign(module.exports, $helpers.bringJs(`${__dirname}/preflight.file2-4.cjs`, "$preflightTypesMap", $preflightTypesMap)); +Object.assign(module.exports, $helpers.bringJs(`${__dirname}/preflight.file1-3.cjs`, "$preflightTypesMap", $preflightTypesMap)); +module.exports = { ...module.exports, $preflightTypesMap }; +//# sourceMappingURL=preflight.subdir2-6.cjs.map +``` + +## preflight.widget-1.cjs +```cjs +"use strict"; +const $stdlib = require('@winglang/sdk'); +const std = $stdlib.std; +const $helpers = $stdlib.helpers; +const $extern = $helpers.createExternRequire(__dirname); +let $preflightTypesMap = {}; +class Widget extends $stdlib.std.Resource { + constructor($scope, $id, ) { + super($scope, $id); + } + compute() { + return 42; + } + static staticCompute($scope) { + return 1337; + } + static _toInflightType() { + return ` + require("${$helpers.normalPath(__dirname)}/inflight.Widget-1.cjs")({ + }) + `; + } + _toInflight() { + return ` + (await (async () => { + const WidgetClient = ${Widget._toInflightType()}; + const client = new WidgetClient({ + }); + if (client.$inflight_init) { await client.$inflight_init(); } + return client; + })()) + `; + } + get _liftMap() { + return ({ + "$inflight_init": [ + ], + }); + } +} +module.exports = { $preflightTypesMap, Widget }; +//# sourceMappingURL=preflight.widget-1.cjs.map +``` + diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_capture_preflight_object.test.w_test_sim.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_capture_preflight_object.test.w_test_sim.md index 61d42bf4f69..e7220befa0b 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_capture_preflight_object.test.w_test_sim.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_capture_preflight_object.test.w_test_sim.md @@ -6,8 +6,9 @@ pass ─ inflight_class_capture_preflight_object.test.wsim » root/env0/test:inf pass ─ inflight_class_capture_preflight_object.test.wsim » root/env1/test:inflight class type captures preflight resource pass ─ inflight_class_capture_preflight_object.test.wsim » root/env2/test:inflight class qualified without explicit reference pass ─ inflight_class_capture_preflight_object.test.wsim » root/env3/test:inflight class defined inflight captures preflight object +pass ─ inflight_class_capture_preflight_object.test.wsim » root/env4/test:bring inflight class from subdir -Tests 4 passed (4) +Tests 5 passed (5) Snapshots 1 skipped Test Files 1 passed (1) Duration From dc0b7d750d1f2b961b185374a8eeea176a7c7832 Mon Sep 17 00:00:00 2001 From: "monada-bot[bot]" Date: Thu, 13 Jun 2024 12:41:14 +0000 Subject: [PATCH 50/78] chore: self mutation (e2e-2of2.diff) Signed-off-by: monada-bot[bot] --- .../bring_local_dir.test.w_compile_tf-aws.md | 66 ++++++++++++++++++- 1 file changed, 63 insertions(+), 3 deletions(-) diff --git a/tools/hangar/__snapshots__/test_corpus/valid/bring_local_dir.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/bring_local_dir.test.w_compile_tf-aws.md index 82239172082..01ff2ab9aaf 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/bring_local_dir.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/bring_local_dir.test.w_compile_tf-aws.md @@ -42,6 +42,21 @@ module.exports = function({ }) { //# sourceMappingURL=inflight.Foo-3.cjs.map ``` +## inflight.InflightClass-4.cjs +```cjs +"use strict"; +const $helpers = require("@winglang/sdk/lib/helpers"); +module.exports = function({ }) { + class InflightClass { + async method() { + return "What did you expect?"; + } + } + return InflightClass; +} +//# sourceMappingURL=inflight.InflightClass-4.cjs.map +``` + ## inflight.Widget-1.cjs ```cjs "use strict"; @@ -92,7 +107,7 @@ class $Root extends $stdlib.std.Resource { let $preflightTypesMap = {}; const w = require("./preflight.widget-1.cjs"); Object.assign($preflightTypesMap, w.$preflightTypesMap); - const subdir = require("./preflight.subdir2-5.cjs"); + const subdir = require("./preflight.subdir2-6.cjs"); Object.assign($preflightTypesMap, subdir.$preflightTypesMap); $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; const widget1 = new w.Widget(this, "widget1"); @@ -235,6 +250,50 @@ module.exports = { $preflightTypesMap, Bar }; //# sourceMappingURL=preflight.file2-4.cjs.map ``` +## preflight.inflightclass-5.cjs +```cjs +"use strict"; +const $stdlib = require('@winglang/sdk'); +const std = $stdlib.std; +const $helpers = $stdlib.helpers; +const $extern = $helpers.createExternRequire(__dirname); +let $preflightTypesMap = {}; +class InflightClass extends $stdlib.std.Resource { + constructor($scope, $id, ) { + super($scope, $id); + } + static _toInflightType() { + return ` + require("${$helpers.normalPath(__dirname)}/inflight.InflightClass-4.cjs")({ + }) + `; + } + _toInflight() { + return ` + (await (async () => { + const InflightClassClient = ${InflightClass._toInflightType()}; + const client = new InflightClassClient({ + }); + if (client.$inflight_init) { await client.$inflight_init(); } + return client; + })()) + `; + } + get _liftMap() { + return ({ + "method": [ + ], + "$inflight_init": [ + ], + }); + } +} +if ($preflightTypesMap[4]) { throw new Error("InflightClass is already in type map"); } +$preflightTypesMap[4] = InflightClass; +module.exports = { $preflightTypesMap, InflightClass }; +//# sourceMappingURL=preflight.inflightclass-5.cjs.map +``` + ## preflight.inner-2.cjs ```cjs "use strict"; @@ -248,7 +307,7 @@ module.exports = { ...module.exports, $preflightTypesMap }; //# sourceMappingURL=preflight.inner-2.cjs.map ``` -## preflight.subdir2-5.cjs +## preflight.subdir2-6.cjs ```cjs "use strict"; const $stdlib = require('@winglang/sdk'); @@ -257,10 +316,11 @@ const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); let $preflightTypesMap = {}; Object.assign(module.exports, { get inner() { return $helpers.bringJs(`${__dirname}/preflight.inner-2.cjs`, "$preflightTypesMap", $preflightTypesMap); } }); +Object.assign(module.exports, $helpers.bringJs(`${__dirname}/preflight.inflightclass-5.cjs`, "$preflightTypesMap", $preflightTypesMap)); Object.assign(module.exports, $helpers.bringJs(`${__dirname}/preflight.file2-4.cjs`, "$preflightTypesMap", $preflightTypesMap)); Object.assign(module.exports, $helpers.bringJs(`${__dirname}/preflight.file1-3.cjs`, "$preflightTypesMap", $preflightTypesMap)); module.exports = { ...module.exports, $preflightTypesMap }; -//# sourceMappingURL=preflight.subdir2-5.cjs.map +//# sourceMappingURL=preflight.subdir2-6.cjs.map ``` ## preflight.widget-1.cjs From 2fd723ee813f2d5c7c7465a55f8f5b9ba8333385 Mon Sep 17 00:00:00 2001 From: Yoav Steinberg Date: Thu, 13 Jun 2024 15:45:25 +0300 Subject: [PATCH 51/78] cleanup --- libs/wingc/src/jsify.rs | 52 ++++++--------------------------------- libs/wingc/src/lifting.rs | 15 ----------- 2 files changed, 7 insertions(+), 60 deletions(-) diff --git a/libs/wingc/src/jsify.rs b/libs/wingc/src/jsify.rs index a2673a8a186..72dcb65ed1e 100644 --- a/libs/wingc/src/jsify.rs +++ b/libs/wingc/src/jsify.rs @@ -41,8 +41,8 @@ const PREFLIGHT_FILE_NAME: &str = "preflight.cjs"; const STDLIB: &str = "$stdlib"; const STDLIB_CORE: &str = formatcp!("{STDLIB}.core"); -const STDLIB_CORE_RESOURCE: &str = formatcp!("{}.{}", STDLIB, WINGSDK_RESOURCE); -const STDLIB_CORE_AUTOID_RESOURCE: &str = formatcp!("{}.{}", STDLIB, WINGSDK_AUTOID_RESOURCE); +const STDLIB_CORE_RESOURCE: &str = formatcp!("{STDLIB}.{WINGSDK_RESOURCE}"); +const STDLIB_CORE_AUTOID_RESOURCE: &str = formatcp!("{STDLIB}.{WINGSDK_AUTOID_RESOURCE}"); const STDLIB_MODULE: &str = WINGSDK_ASSEMBLY_NAME; const ENV_WING_IS_TEST: &str = "$wing_is_test"; @@ -59,8 +59,6 @@ const __DIRNAME: &str = "__dirname"; const SUPER_CLASS_INFLIGHT_INIT_NAME: &str = formatcp!("super_{CLASS_INFLIGHT_INIT_NAME}"); -//const PREFLIGHT_TYPES_MAP: &str = "globalThis.$preflightTypesMap"; -//const PREFLIGHT_TYPES_MAP: &str = "this.node.root.$preflightTypesMap"; const PREFLIGHT_TYPES_MAP: &str = "$helpers.nodeof(this).root.$preflightTypesMap"; const MODULE_PREFLIGHT_TYPES_MAP: &str = "$preflightTypesMap"; @@ -230,38 +228,13 @@ impl<'a> JSifier<'a> { let directory_children = self.source_file_graph.dependencies_of(source_path); let preflight_file_map = self.preflight_file_map.borrow(); - // supposing a directory has two files and two subdirectories in it, + // supposing a directory has a file and a subdirectory in it, // we generate code like this: // ``` - // module.exports = { - // get inner_directory1() { return require("./preflight.inner-directory1.cjs") }, - // get inner_directory2() { return require("./preflight.inner-directory2.cjs") }, - // ...require("./preflight.inner-file1.cjs"), - // ...require("./preflight.inner-file2.cjs"), - // }; - // ``` - // output.open("module.exports = {"); - // for file in directory_children { - // let preflight_file_name = preflight_file_map.get(file).expect("no emitted JS file found"); - // if file.is_dir() { - // let directory_name = file.file_stem().unwrap(); - // output.line(format!( - // "get {directory_name}() {{ return require(\"./{preflight_file_name}\") }}," - // )); - // } else { - // output.line(format!("...require(\"./{preflight_file_name}\"),")); - // } - // } - // output.close("};"); - - // supposing a directory has a files and a subdirectory in it, - // we generate code like this: - // ``` - // let $brought; - // $brought = $helpers.bringJs("./preflight.inner-file1.js", "$preflightTypesMap", $preflightTypesMap); - // module.exports = { ...module.export, ...$brought }; - // $brought = $helpers.bringJs("./preflight.inner-directory1.js", "$preflightTypesMap", $preflightTypesMap); - // module.exports = { ...module.export, get inner_directory1() { return $brought; } }; + // let $preflightTypesMap = {}; + // Object.assign(module.exports, $helpers.bringJs("./preflight.inner-file1.js", "$preflightTypesMap", $preflightTypesMap)); + // Object.assign(module.exports, { get inner_directory1() { $helpers.bringJs("./preflight.inner-directory1.js", "$preflightTypesMap", $preflightTypesMap); } }); + // module.exports = { ...module.exports, $preflightTypesMap }; // ``` // This module's preflight type map @@ -1889,17 +1862,6 @@ impl<'a> JSifier<'a> { code.close("}"); - // Inflight classes might need their type to be lift-qualified (onLift), but their type name might not be necessarily avaialble - // at the scope when they are qualified (it might even be shadowed by another type name). Here we generate a unique - // type name to be used in such cases. - // if class.phase == Phase::Inflight { - // let inflight_class_unique_instance = self.unique_class_alias(class_type); - // code.line(format!( - // "const {inflight_class_unique_instance} = new {}(this, \"{inflight_class_unique_instance}\");", - // class.name, - // )); - // } - // Inflight classes might need to be lift-qualified (onLift), but their type name might not be necessarily available // at the scope when they are qualified (it might even be shadowed by another type name). We store a reference to these // class types in a global preflight types map indexed by the class's unique id. diff --git a/libs/wingc/src/lifting.rs b/libs/wingc/src/lifting.rs index 7f41d530dc7..c96ed8d858a 100644 --- a/libs/wingc/src/lifting.rs +++ b/libs/wingc/src/lifting.rs @@ -274,21 +274,6 @@ impl<'a> Visit<'a> for LiftVisitor<'a> { v.lifts_stack.push(lifts); return; } - // else if expr_phase == Phase::Inflight && expr_type.is_closure() { - // // We assume any reference to a closure means it might be called and therefore we need to lift it if it's - // // a method of a class defined preflight. - - // if let Some(sig) = expr_type.as_deep_function_sig() { - // if let Some(class_type) = sig.this_type { - // if let Some(class) = class_type.as_class() { - // if class.defined_in_phase == Phase::Preflight && class.phase == Phase::Inflight { - // println!("A reference to a method {:?} of an inflight class {class_type}!", v.ctx.current_property()); - - // } - // } - // } - // } - // } // Before we continue lets dive into this (non-preflight) expression to see if we need to lift any parts of it visit::visit_expr(v, node); From 226e2b2da3560671bd0a944a1b742f2b95fc8521 Mon Sep 17 00:00:00 2001 From: Yoav Steinberg Date: Thu, 13 Jun 2024 15:53:51 +0300 Subject: [PATCH 52/78] cleanup --- libs/wingc/src/type_check.rs | 26 -------------------------- 1 file changed, 26 deletions(-) diff --git a/libs/wingc/src/type_check.rs b/libs/wingc/src/type_check.rs index fb2bbdcdbca..325708aef7f 100644 --- a/libs/wingc/src/type_check.rs +++ b/libs/wingc/src/type_check.rs @@ -423,32 +423,6 @@ pub trait ClassLike: Display { None } } - - // fn phase(&self) -> Phase { - // // A class is considered a "preflight class" if it has any preflight fields. - // // Having a preflight state means that different instances of the class - // // might access different preflight data. Such instances need to be lifted - // // into inflight individually. Non preflight class instances don't need to be - // // lifted and can therefore be instantiated inflight. - // if self - // .fields(true) - // .any(|(_, vi)| vi.kind == VariableKind::InstanceMember && vi.phase == Phase::Preflight) - // { - // return Phase::Preflight; - // } - - // // If all memebers are phase independent, then this class is phase independent - // if self - // .get_env() - // .iter(true) - // .all(|(_, v, _)| v.as_variable().unwrap().phase == Phase::Independent) - // { - // return Phase::Independent; - // } - - // // Otherwise, this is an inflight class - // Phase::Inflight - // } } impl ClassLike for Interface { From e7ff30f2ac49687ab740ba4a06a91fba999c2bfd Mon Sep 17 00:00:00 2001 From: "monada-bot[bot]" Date: Thu, 13 Jun 2024 13:00:55 +0000 Subject: [PATCH 53/78] chore: self mutation (build.diff) Signed-off-by: monada-bot[bot] --- .../call_static_inflight_from_static_inflight.snap | 4 ++-- .../capture_type_static_method_inflight_class.snap | 4 ++-- ...losed_inflight_class_extends_outer_inflight_class.snap | 4 ++-- .../snapshots/inflight_class_extends_inflight_class.snap | 8 ++++---- .../snapshots/inflight_field_from_inflight_class.snap | 4 ++-- libs/wingc/src/jsify/snapshots/new_inflight_object.snap | 4 ++-- ...alify_inflight_type_refrencing_preflight_instance.snap | 8 ++++---- .../jsify/snapshots/static_external_inflight_class.snap | 4 ++-- .../transitive_reference_via_inflight_class.snap | 8 ++++---- 9 files changed, 24 insertions(+), 24 deletions(-) diff --git a/libs/wingc/src/jsify/snapshots/call_static_inflight_from_static_inflight.snap b/libs/wingc/src/jsify/snapshots/call_static_inflight_from_static_inflight.snap index 2036add1c87..cf07e70b377 100644 --- a/libs/wingc/src/jsify/snapshots/call_static_inflight_from_static_inflight.snap +++ b/libs/wingc/src/jsify/snapshots/call_static_inflight_from_static_inflight.snap @@ -139,8 +139,8 @@ class $Root extends $stdlib.std.Resource { }); } } - if ($preflightTypesMap[24]) { throw new Error("B is already in type map"); } - $preflightTypesMap[24] = B; + if ($preflightTypesMap[28]) { throw new Error("B is already in type map"); } + $preflightTypesMap[28] = B; } } const $PlatformManager = new $stdlib.platform.PlatformManager({platformPaths: $platforms}); diff --git a/libs/wingc/src/jsify/snapshots/capture_type_static_method_inflight_class.snap b/libs/wingc/src/jsify/snapshots/capture_type_static_method_inflight_class.snap index d4ee2863513..6814a5a73c3 100644 --- a/libs/wingc/src/jsify/snapshots/capture_type_static_method_inflight_class.snap +++ b/libs/wingc/src/jsify/snapshots/capture_type_static_method_inflight_class.snap @@ -103,8 +103,8 @@ class $Root extends $stdlib.std.Resource { }); } } - if ($preflightTypesMap[51]) { throw new Error("Foo is already in type map"); } - $preflightTypesMap[51] = Foo; + if ($preflightTypesMap[53]) { throw new Error("Foo is already in type map"); } + $preflightTypesMap[53] = Foo; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/closed_inflight_class_extends_outer_inflight_class.snap b/libs/wingc/src/jsify/snapshots/closed_inflight_class_extends_outer_inflight_class.snap index 1cc30b10a23..fc34c1d9a2c 100644 --- a/libs/wingc/src/jsify/snapshots/closed_inflight_class_extends_outer_inflight_class.snap +++ b/libs/wingc/src/jsify/snapshots/closed_inflight_class_extends_outer_inflight_class.snap @@ -95,8 +95,8 @@ class $Root extends $stdlib.std.Resource { }); } } - if ($preflightTypesMap[55]) { throw new Error("Base is already in type map"); } - $preflightTypesMap[55] = Base; + if ($preflightTypesMap[56]) { throw new Error("Base is already in type map"); } + $preflightTypesMap[56] = Base; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/inflight_class_extends_inflight_class.snap b/libs/wingc/src/jsify/snapshots/inflight_class_extends_inflight_class.snap index 677c637979a..28f3bd2ed33 100644 --- a/libs/wingc/src/jsify/snapshots/inflight_class_extends_inflight_class.snap +++ b/libs/wingc/src/jsify/snapshots/inflight_class_extends_inflight_class.snap @@ -81,8 +81,8 @@ class $Root extends $stdlib.std.Resource { }); } } - if ($preflightTypesMap[89]) { throw new Error("A is already in type map"); } - $preflightTypesMap[89] = A; + if ($preflightTypesMap[88]) { throw new Error("A is already in type map"); } + $preflightTypesMap[88] = A; class B extends A { constructor($scope, $id, ) { super($scope, $id); @@ -112,8 +112,8 @@ class $Root extends $stdlib.std.Resource { }); } } - if ($preflightTypesMap[90]) { throw new Error("B is already in type map"); } - $preflightTypesMap[90] = B; + if ($preflightTypesMap[89]) { throw new Error("B is already in type map"); } + $preflightTypesMap[89] = B; } } const $PlatformManager = new $stdlib.platform.PlatformManager({platformPaths: $platforms}); diff --git a/libs/wingc/src/jsify/snapshots/inflight_field_from_inflight_class.snap b/libs/wingc/src/jsify/snapshots/inflight_field_from_inflight_class.snap index f2407f1702d..782218355a7 100644 --- a/libs/wingc/src/jsify/snapshots/inflight_field_from_inflight_class.snap +++ b/libs/wingc/src/jsify/snapshots/inflight_field_from_inflight_class.snap @@ -88,8 +88,8 @@ class $Root extends $stdlib.std.Resource { }); } } - if ($preflightTypesMap[92]) { throw new Error("MyType is already in type map"); } - $preflightTypesMap[92] = MyType; + if ($preflightTypesMap[95]) { throw new Error("MyType is already in type map"); } + $preflightTypesMap[95] = MyType; } } const $PlatformManager = new $stdlib.platform.PlatformManager({platformPaths: $platforms}); diff --git a/libs/wingc/src/jsify/snapshots/new_inflight_object.snap b/libs/wingc/src/jsify/snapshots/new_inflight_object.snap index 3b2623b6e27..99b20e13ffc 100644 --- a/libs/wingc/src/jsify/snapshots/new_inflight_object.snap +++ b/libs/wingc/src/jsify/snapshots/new_inflight_object.snap @@ -92,8 +92,8 @@ class $Root extends $stdlib.std.Resource { }); } } - if ($preflightTypesMap[119]) { throw new Error("Foo is already in type map"); } - $preflightTypesMap[119] = Foo; + if ($preflightTypesMap[118]) { throw new Error("Foo is already in type map"); } + $preflightTypesMap[118] = Foo; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/qualify_inflight_type_refrencing_preflight_instance.snap b/libs/wingc/src/jsify/snapshots/qualify_inflight_type_refrencing_preflight_instance.snap index ad0d188e1f3..c2f5acbca32 100644 --- a/libs/wingc/src/jsify/snapshots/qualify_inflight_type_refrencing_preflight_instance.snap +++ b/libs/wingc/src/jsify/snapshots/qualify_inflight_type_refrencing_preflight_instance.snap @@ -158,8 +158,8 @@ class $Root extends $stdlib.std.Resource { }); } } - if ($preflightTypesMap[144]) { throw new Error("InflightC is already in type map"); } - $preflightTypesMap[144] = InflightC; + if ($preflightTypesMap[143]) { throw new Error("InflightC is already in type map"); } + $preflightTypesMap[143] = InflightC; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -187,11 +187,11 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ - [$helpers.nodeof(this).root.$preflightTypesMap[144]._singleton(this,"InflightC_singleton_144"), ["foo"]], + [$helpers.nodeof(this).root.$preflightTypesMap[143]._singleton(this,"InflightC_singleton_143"), ["foo"]], [InflightC, []], ], "$inflight_init": [ - [$helpers.nodeof(this).root.$preflightTypesMap[144]._singleton(this,"InflightC_singleton_144"), []], + [$helpers.nodeof(this).root.$preflightTypesMap[143]._singleton(this,"InflightC_singleton_143"), []], [InflightC, []], ], }); diff --git a/libs/wingc/src/jsify/snapshots/static_external_inflight_class.snap b/libs/wingc/src/jsify/snapshots/static_external_inflight_class.snap index d7b42b481f6..e21818bea3f 100644 --- a/libs/wingc/src/jsify/snapshots/static_external_inflight_class.snap +++ b/libs/wingc/src/jsify/snapshots/static_external_inflight_class.snap @@ -114,8 +114,8 @@ class $Root extends $stdlib.std.Resource { }); } } - if ($preflightTypesMap[163]) { throw new Error("A is already in type map"); } - $preflightTypesMap[163] = A; + if ($preflightTypesMap[166]) { throw new Error("A is already in type map"); } + $preflightTypesMap[166] = A; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/transitive_reference_via_inflight_class.snap b/libs/wingc/src/jsify/snapshots/transitive_reference_via_inflight_class.snap index b32096c8259..bb61f97d911 100644 --- a/libs/wingc/src/jsify/snapshots/transitive_reference_via_inflight_class.snap +++ b/libs/wingc/src/jsify/snapshots/transitive_reference_via_inflight_class.snap @@ -111,8 +111,8 @@ class $Root extends $stdlib.std.Resource { }); } } - if ($preflightTypesMap[180]) { throw new Error("MyInflightClass is already in type map"); } - $preflightTypesMap[180] = MyInflightClass; + if ($preflightTypesMap[179]) { throw new Error("MyInflightClass is already in type map"); } + $preflightTypesMap[179] = MyInflightClass; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -140,11 +140,11 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ - [$helpers.nodeof(this).root.$preflightTypesMap[180]._singleton(this,"MyInflightClass_singleton_180"), ["putInBucket"]], + [$helpers.nodeof(this).root.$preflightTypesMap[179]._singleton(this,"MyInflightClass_singleton_179"), ["putInBucket"]], [MyInflightClass, []], ], "$inflight_init": [ - [$helpers.nodeof(this).root.$preflightTypesMap[180]._singleton(this,"MyInflightClass_singleton_180"), []], + [$helpers.nodeof(this).root.$preflightTypesMap[179]._singleton(this,"MyInflightClass_singleton_179"), []], [MyInflightClass, []], ], }); From 41d93ddf833e25f015e4f0415c6b463c4683f472 Mon Sep 17 00:00:00 2001 From: Yoav Steinberg Date: Thu, 13 Jun 2024 16:20:53 +0300 Subject: [PATCH 54/78] cleanup --- libs/wingc/src/lifting.rs | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/libs/wingc/src/lifting.rs b/libs/wingc/src/lifting.rs index c96ed8d858a..ab5f4ec4baf 100644 --- a/libs/wingc/src/lifting.rs +++ b/libs/wingc/src/lifting.rs @@ -330,20 +330,6 @@ impl<'a> Visit<'a> for LiftVisitor<'a> { let code = self.jsify_udt(&node); let property = self.ctx.current_property(); - - // check that we can qualify the lift (e.g. determine which property is being accessed) - // if property.is_none() { - // report_diagnostic(Diagnostic { - // message: format!( - // "Cannot qualify access to a lifted type \"{udt_type}\" (see https://github.com/winglang/wing/issues/76 for more details)"), - // span: Some(node.span.clone()), - // annotations: vec![], - // hints: vec![], - // }); - - // return; - // } - let mut lifts = self.lifts_stack.pop().unwrap(); lifts.lift( self.ctx.current_method().map(|(m, _)| m).expect("a method"), From 704dd470254ca45d5a0b3f88214389ef98b3b3fc Mon Sep 17 00:00:00 2001 From: Yoav Steinberg Date: Thu, 13 Jun 2024 16:39:28 +0300 Subject: [PATCH 55/78] comment --- libs/wingc/src/type_check.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libs/wingc/src/type_check.rs b/libs/wingc/src/type_check.rs index 325708aef7f..8b86d6ee8d0 100644 --- a/libs/wingc/src/type_check.rs +++ b/libs/wingc/src/type_check.rs @@ -326,7 +326,9 @@ pub struct Class { pub phase: Phase, pub docs: Docs, pub lifts: Option, - pub defined_in_phase: Phase, // TODO: naming: maybe this should just be `phase` while `phase` should be `default_member_phase`? + + // The phase in which this class was defined (this should be the same as the env.phase where the class name is defined) + pub defined_in_phase: Phase, // Preflight classes are CDK Constructs which means they have a scope and id as their first arguments // this is natively supported by wing using the `as` `in` keywords. However theoretically it is possible From e0d4adc80cee921f80c7bcad1eb69c77e892b6c6 Mon Sep 17 00:00:00 2001 From: Yoav Steinberg Date: Sun, 16 Jun 2024 14:56:26 +0300 Subject: [PATCH 56/78] don't use global for class types ids (causes non consistent snaps) --- .../call_static_inflight_from_static_inflight.snap | 4 ++-- .../capture_type_new_inflight_class_outer.snap | 4 ++-- .../capture_type_static_method_inflight_class.snap | 4 ++-- ...ed_inflight_class_extends_outer_inflight_class.snap | 4 ++-- .../inflight_class_extends_inflight_class.snap | 8 ++++---- .../snapshots/inflight_field_from_inflight_class.snap | 4 ++-- .../wingc/src/jsify/snapshots/new_inflight_object.snap | 4 ++-- ...fy_inflight_type_refrencing_preflight_instance.snap | 8 ++++---- .../src/jsify/snapshots/reference_inflight_class.snap | 4 ++-- .../snapshots/reference_inflight_from_inflight.snap | 4 ++-- .../snapshots/static_external_inflight_class.snap | 4 ++-- .../transitive_reference_via_inflight_class.snap | 8 ++++---- libs/wingc/src/type_check.rs | 10 +++++----- 13 files changed, 35 insertions(+), 35 deletions(-) diff --git a/libs/wingc/src/jsify/snapshots/call_static_inflight_from_static_inflight.snap b/libs/wingc/src/jsify/snapshots/call_static_inflight_from_static_inflight.snap index cf07e70b377..494f0904577 100644 --- a/libs/wingc/src/jsify/snapshots/call_static_inflight_from_static_inflight.snap +++ b/libs/wingc/src/jsify/snapshots/call_static_inflight_from_static_inflight.snap @@ -139,8 +139,8 @@ class $Root extends $stdlib.std.Resource { }); } } - if ($preflightTypesMap[28]) { throw new Error("B is already in type map"); } - $preflightTypesMap[28] = B; + if ($preflightTypesMap[1]) { throw new Error("B is already in type map"); } + $preflightTypesMap[1] = B; } } const $PlatformManager = new $stdlib.platform.PlatformManager({platformPaths: $platforms}); diff --git a/libs/wingc/src/jsify/snapshots/capture_type_new_inflight_class_outer.snap b/libs/wingc/src/jsify/snapshots/capture_type_new_inflight_class_outer.snap index 56ba03ea5bf..cedede44ee9 100644 --- a/libs/wingc/src/jsify/snapshots/capture_type_new_inflight_class_outer.snap +++ b/libs/wingc/src/jsify/snapshots/capture_type_new_inflight_class_outer.snap @@ -92,8 +92,8 @@ class $Root extends $stdlib.std.Resource { }); } } - if ($preflightTypesMap[47]) { throw new Error("Foo is already in type map"); } - $preflightTypesMap[47] = Foo; + if ($preflightTypesMap[0]) { throw new Error("Foo is already in type map"); } + $preflightTypesMap[0] = Foo; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/capture_type_static_method_inflight_class.snap b/libs/wingc/src/jsify/snapshots/capture_type_static_method_inflight_class.snap index 6814a5a73c3..77116c494e1 100644 --- a/libs/wingc/src/jsify/snapshots/capture_type_static_method_inflight_class.snap +++ b/libs/wingc/src/jsify/snapshots/capture_type_static_method_inflight_class.snap @@ -103,8 +103,8 @@ class $Root extends $stdlib.std.Resource { }); } } - if ($preflightTypesMap[53]) { throw new Error("Foo is already in type map"); } - $preflightTypesMap[53] = Foo; + if ($preflightTypesMap[0]) { throw new Error("Foo is already in type map"); } + $preflightTypesMap[0] = Foo; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/closed_inflight_class_extends_outer_inflight_class.snap b/libs/wingc/src/jsify/snapshots/closed_inflight_class_extends_outer_inflight_class.snap index fc34c1d9a2c..618175ae30a 100644 --- a/libs/wingc/src/jsify/snapshots/closed_inflight_class_extends_outer_inflight_class.snap +++ b/libs/wingc/src/jsify/snapshots/closed_inflight_class_extends_outer_inflight_class.snap @@ -95,8 +95,8 @@ class $Root extends $stdlib.std.Resource { }); } } - if ($preflightTypesMap[56]) { throw new Error("Base is already in type map"); } - $preflightTypesMap[56] = Base; + if ($preflightTypesMap[0]) { throw new Error("Base is already in type map"); } + $preflightTypesMap[0] = Base; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/inflight_class_extends_inflight_class.snap b/libs/wingc/src/jsify/snapshots/inflight_class_extends_inflight_class.snap index 28f3bd2ed33..17bda2ad86d 100644 --- a/libs/wingc/src/jsify/snapshots/inflight_class_extends_inflight_class.snap +++ b/libs/wingc/src/jsify/snapshots/inflight_class_extends_inflight_class.snap @@ -81,8 +81,8 @@ class $Root extends $stdlib.std.Resource { }); } } - if ($preflightTypesMap[88]) { throw new Error("A is already in type map"); } - $preflightTypesMap[88] = A; + if ($preflightTypesMap[0]) { throw new Error("A is already in type map"); } + $preflightTypesMap[0] = A; class B extends A { constructor($scope, $id, ) { super($scope, $id); @@ -112,8 +112,8 @@ class $Root extends $stdlib.std.Resource { }); } } - if ($preflightTypesMap[89]) { throw new Error("B is already in type map"); } - $preflightTypesMap[89] = B; + if ($preflightTypesMap[1]) { throw new Error("B is already in type map"); } + $preflightTypesMap[1] = B; } } const $PlatformManager = new $stdlib.platform.PlatformManager({platformPaths: $platforms}); diff --git a/libs/wingc/src/jsify/snapshots/inflight_field_from_inflight_class.snap b/libs/wingc/src/jsify/snapshots/inflight_field_from_inflight_class.snap index 782218355a7..2577a58c636 100644 --- a/libs/wingc/src/jsify/snapshots/inflight_field_from_inflight_class.snap +++ b/libs/wingc/src/jsify/snapshots/inflight_field_from_inflight_class.snap @@ -88,8 +88,8 @@ class $Root extends $stdlib.std.Resource { }); } } - if ($preflightTypesMap[95]) { throw new Error("MyType is already in type map"); } - $preflightTypesMap[95] = MyType; + if ($preflightTypesMap[0]) { throw new Error("MyType is already in type map"); } + $preflightTypesMap[0] = MyType; } } const $PlatformManager = new $stdlib.platform.PlatformManager({platformPaths: $platforms}); diff --git a/libs/wingc/src/jsify/snapshots/new_inflight_object.snap b/libs/wingc/src/jsify/snapshots/new_inflight_object.snap index 99b20e13ffc..6ddf3a6df92 100644 --- a/libs/wingc/src/jsify/snapshots/new_inflight_object.snap +++ b/libs/wingc/src/jsify/snapshots/new_inflight_object.snap @@ -92,8 +92,8 @@ class $Root extends $stdlib.std.Resource { }); } } - if ($preflightTypesMap[118]) { throw new Error("Foo is already in type map"); } - $preflightTypesMap[118] = Foo; + if ($preflightTypesMap[0]) { throw new Error("Foo is already in type map"); } + $preflightTypesMap[0] = Foo; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/qualify_inflight_type_refrencing_preflight_instance.snap b/libs/wingc/src/jsify/snapshots/qualify_inflight_type_refrencing_preflight_instance.snap index c2f5acbca32..f256aa79174 100644 --- a/libs/wingc/src/jsify/snapshots/qualify_inflight_type_refrencing_preflight_instance.snap +++ b/libs/wingc/src/jsify/snapshots/qualify_inflight_type_refrencing_preflight_instance.snap @@ -158,8 +158,8 @@ class $Root extends $stdlib.std.Resource { }); } } - if ($preflightTypesMap[143]) { throw new Error("InflightC is already in type map"); } - $preflightTypesMap[143] = InflightC; + if ($preflightTypesMap[1]) { throw new Error("InflightC is already in type map"); } + $preflightTypesMap[1] = InflightC; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -187,11 +187,11 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ - [$helpers.nodeof(this).root.$preflightTypesMap[143]._singleton(this,"InflightC_singleton_143"), ["foo"]], + [$helpers.nodeof(this).root.$preflightTypesMap[1]._singleton(this,"InflightC_singleton_1"), ["foo"]], [InflightC, []], ], "$inflight_init": [ - [$helpers.nodeof(this).root.$preflightTypesMap[143]._singleton(this,"InflightC_singleton_143"), []], + [$helpers.nodeof(this).root.$preflightTypesMap[1]._singleton(this,"InflightC_singleton_1"), []], [InflightC, []], ], }); diff --git a/libs/wingc/src/jsify/snapshots/reference_inflight_class.snap b/libs/wingc/src/jsify/snapshots/reference_inflight_class.snap index 1983b1e044b..8c353b407c4 100644 --- a/libs/wingc/src/jsify/snapshots/reference_inflight_class.snap +++ b/libs/wingc/src/jsify/snapshots/reference_inflight_class.snap @@ -103,8 +103,8 @@ class $Root extends $stdlib.std.Resource { }); } } - if ($preflightTypesMap[150]) { throw new Error("Foo is already in type map"); } - $preflightTypesMap[150] = Foo; + if ($preflightTypesMap[0]) { throw new Error("Foo is already in type map"); } + $preflightTypesMap[0] = Foo; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/reference_inflight_from_inflight.snap b/libs/wingc/src/jsify/snapshots/reference_inflight_from_inflight.snap index f533490fec7..8373760614a 100644 --- a/libs/wingc/src/jsify/snapshots/reference_inflight_from_inflight.snap +++ b/libs/wingc/src/jsify/snapshots/reference_inflight_from_inflight.snap @@ -114,8 +114,8 @@ class $Root extends $stdlib.std.Resource { }); } } - if ($preflightTypesMap[152]) { throw new Error("Foo is already in type map"); } - $preflightTypesMap[152] = Foo; + if ($preflightTypesMap[0]) { throw new Error("Foo is already in type map"); } + $preflightTypesMap[0] = Foo; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/static_external_inflight_class.snap b/libs/wingc/src/jsify/snapshots/static_external_inflight_class.snap index e21818bea3f..6afd1a2e505 100644 --- a/libs/wingc/src/jsify/snapshots/static_external_inflight_class.snap +++ b/libs/wingc/src/jsify/snapshots/static_external_inflight_class.snap @@ -114,8 +114,8 @@ class $Root extends $stdlib.std.Resource { }); } } - if ($preflightTypesMap[166]) { throw new Error("A is already in type map"); } - $preflightTypesMap[166] = A; + if ($preflightTypesMap[0]) { throw new Error("A is already in type map"); } + $preflightTypesMap[0] = A; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/transitive_reference_via_inflight_class.snap b/libs/wingc/src/jsify/snapshots/transitive_reference_via_inflight_class.snap index bb61f97d911..afc06015d74 100644 --- a/libs/wingc/src/jsify/snapshots/transitive_reference_via_inflight_class.snap +++ b/libs/wingc/src/jsify/snapshots/transitive_reference_via_inflight_class.snap @@ -111,8 +111,8 @@ class $Root extends $stdlib.std.Resource { }); } } - if ($preflightTypesMap[179]) { throw new Error("MyInflightClass is already in type map"); } - $preflightTypesMap[179] = MyInflightClass; + if ($preflightTypesMap[0]) { throw new Error("MyInflightClass is already in type map"); } + $preflightTypesMap[0] = MyInflightClass; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -140,11 +140,11 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ - [$helpers.nodeof(this).root.$preflightTypesMap[179]._singleton(this,"MyInflightClass_singleton_179"), ["putInBucket"]], + [$helpers.nodeof(this).root.$preflightTypesMap[0]._singleton(this,"MyInflightClass_singleton_0"), ["putInBucket"]], [MyInflightClass, []], ], "$inflight_init": [ - [$helpers.nodeof(this).root.$preflightTypesMap[179]._singleton(this,"MyInflightClass_singleton_179"), []], + [$helpers.nodeof(this).root.$preflightTypesMap[0]._singleton(this,"MyInflightClass_singleton_0"), []], [MyInflightClass, []], ], }); diff --git a/libs/wingc/src/type_check.rs b/libs/wingc/src/type_check.rs index 8b86d6ee8d0..8960629424c 100644 --- a/libs/wingc/src/type_check.rs +++ b/libs/wingc/src/type_check.rs @@ -41,7 +41,6 @@ use std::cmp; use std::collections::{BTreeMap, HashMap, HashSet}; use std::fmt::{Debug, Display}; use std::iter::FilterMap; -use std::sync::atomic::{AtomicUsize, Ordering}; use symbol_env::{StatementIdx, SymbolEnv}; use wingii::fqn::FQN; use wingii::type_system::TypeSystem; @@ -1395,6 +1394,8 @@ pub struct Types { type_expressions: IndexMap, /// Append empty struct to end of arg list pub append_empty_struct_to_arglist: HashSet, + /// Class counter, used to generate unique ids for class types + pub class_counter: usize, } impl Types { @@ -1447,6 +1448,7 @@ impl Types { append_empty_struct_to_arglist: HashSet::new(), libraries: SymbolEnv::new(None, SymbolEnvKind::Scope, Phase::Preflight, 0), intrinsics: SymbolEnv::new(None, SymbolEnvKind::Scope, Phase::Independent, 0), + class_counter: 0, } } @@ -1821,9 +1823,6 @@ pub struct TypeChecker<'a> { ctx: VisitContext, } -/// Class counter, used to generate unique names class types -static CLASS_COUNTER: AtomicUsize = AtomicUsize::new(0); - impl<'a> TypeChecker<'a> { pub fn new( types: &'a mut Types, @@ -4484,8 +4483,9 @@ new cloud.Function(@inflight("./handler.ts"), lifts: { bucket: ["put"] }); docs: stmt.doc.as_ref().map_or(Docs::default(), |s| Docs::with_summary(s)), std_construct_args: ast_class.phase == Phase::Preflight, lifts: None, - uid: CLASS_COUNTER.fetch_add(1, Ordering::Relaxed), + uid: self.types.class_counter, }; + self.types.class_counter += 1; let mut class_type = self.types.add_type(Type::Class(class_spec)); match env.define( &ast_class.name, From f161b99421ff3bea4bccd51d56c909daee168beb Mon Sep 17 00:00:00 2001 From: Yoav Steinberg Date: Sun, 16 Jun 2024 15:18:47 +0300 Subject: [PATCH 57/78] cleanup, merge fix --- .../website/react-website/build/public/index.html | 12 ------------ .../website/react-website/build/public/index.js | 2 -- .../website/react-website/build/public/wing.js | 2 -- .../sdk_tests/website/react-website/public/wing.js | 2 -- 4 files changed, 18 deletions(-) delete mode 100644 examples/tests/sdk_tests/website/react-website/build/public/index.html delete mode 100644 examples/tests/sdk_tests/website/react-website/build/public/index.js delete mode 100644 examples/tests/sdk_tests/website/react-website/build/public/wing.js delete mode 100644 examples/tests/sdk_tests/website/react-website/public/wing.js diff --git a/examples/tests/sdk_tests/website/react-website/build/public/index.html b/examples/tests/sdk_tests/website/react-website/build/public/index.html deleted file mode 100644 index fd19a87f0bc..00000000000 --- a/examples/tests/sdk_tests/website/react-website/build/public/index.html +++ /dev/null @@ -1,12 +0,0 @@ - - - - Demo website - - -

Hello Wing!

-

-

- - - diff --git a/examples/tests/sdk_tests/website/react-website/build/public/index.js b/examples/tests/sdk_tests/website/react-website/build/public/index.js deleted file mode 100644 index 6447c845ca7..00000000000 --- a/examples/tests/sdk_tests/website/react-website/build/public/index.js +++ /dev/null @@ -1,2 +0,0 @@ -document.getElementById("par1").innerText = `apiUrl is: ${window.wingEnv?.apiUrl}`; -document.getElementById("par2").innerText = `anotherEnvVar is: ${window.wingEnv?.anotherEnvVar}`; diff --git a/examples/tests/sdk_tests/website/react-website/build/public/wing.js b/examples/tests/sdk_tests/website/react-website/build/public/wing.js deleted file mode 100644 index 098745900a8..00000000000 --- a/examples/tests/sdk_tests/website/react-website/build/public/wing.js +++ /dev/null @@ -1,2 +0,0 @@ -// This file is generated by wing -window.wingEnv = {}; \ No newline at end of file diff --git a/examples/tests/sdk_tests/website/react-website/public/wing.js b/examples/tests/sdk_tests/website/react-website/public/wing.js deleted file mode 100644 index 098745900a8..00000000000 --- a/examples/tests/sdk_tests/website/react-website/public/wing.js +++ /dev/null @@ -1,2 +0,0 @@ -// This file is generated by wing -window.wingEnv = {}; \ No newline at end of file From 2b7e63e212f90b4df7e233b2c3e3813d686d3b8f Mon Sep 17 00:00:00 2001 From: Yoav Steinberg Date: Mon, 17 Jun 2024 13:58:02 +0300 Subject: [PATCH 58/78] cr, use `$helpers.bringJs` in for all imports, document it --- libs/wingc/src/jsify.rs | 6 +----- libs/wingsdk/src/helpers.ts | 9 +++++++++ ...ring_extend_non_entry.test.w_compile_tf-aws.md | 3 +-- .../valid/bring_local.test.w_compile_tf-aws.md | 12 ++++-------- .../bring_local_dir.test.w_compile_tf-aws.md | 9 +++------ ...g_local_normalization.test.w_compile_tf-aws.md | 15 +++++---------- .../bring_wing_library.test.w_compile_tf-aws.md | 12 ++++-------- ...ture_preflight_object.test.w_compile_tf-aws.md | 6 ++---- .../valid/intrinsics.test.w_compile_tf-aws.md | 3 +-- .../valid/new_in_static.test.w_compile_tf-aws.md | 3 +-- .../test_corpus/valid/store.w_compile_tf-aws.md | 3 +-- .../struct_from_json.test.w_compile_tf-aws.md | 6 ++---- 12 files changed, 34 insertions(+), 53 deletions(-) diff --git a/libs/wingc/src/jsify.rs b/libs/wingc/src/jsify.rs index 72dcb65ed1e..ba4db9240a0 100644 --- a/libs/wingc/src/jsify.rs +++ b/libs/wingc/src/jsify.rs @@ -1502,11 +1502,7 @@ impl<'a> JSifier<'a> { let var_name = identifier.as_ref().expect("bring wing module requires an alias"); let preflight_file_map = self.preflight_file_map.borrow(); let preflight_file_name = preflight_file_map.get(path).unwrap(); - code.line(format!("const {var_name} = require(\"./{preflight_file_name}\");")); - // Add brought preflight types to this module's preflight types - code.line(format!( - "Object.assign({MODULE_PREFLIGHT_TYPES_MAP}, {var_name}.{MODULE_PREFLIGHT_TYPES_MAP});" - )); + code.line(format!("const {var_name} = $helpers.bringJs(`${{__dirname}}/{preflight_file_name}`,\"{MODULE_PREFLIGHT_TYPES_MAP}\", {MODULE_PREFLIGHT_TYPES_MAP});")); code } diff --git a/libs/wingsdk/src/helpers.ts b/libs/wingsdk/src/helpers.ts index a4d20f9d9cd..01a205eb6ff 100644 --- a/libs/wingsdk/src/helpers.ts +++ b/libs/wingsdk/src/helpers.ts @@ -167,6 +167,15 @@ export function resolveDirname( return normalPath(path.resolve(outdir, relativeSourceDir)); } +/** + * Helper function to `require` a compiled preflight wing file (js) into another compiled (js) wing file. + * We need this instead of simply calling `require` because in addition to returning the imported module's exports, + * we also need to update the current module's preflight types map with the brought module's preflight types map. + * @param moduleFile - the file to `require` + * @param preflightTypesObjectName - this should always be $preflightTypesMap (based on the wingc jsify rust code) + * @param outPreflightTypesObject - the current module's $preflightTypesMap + * @returns all symbols exported by the `moduleFile` except `$preflightTypesMap` + */ export function bringJs( moduleFile: string, preflightTypesObjectName: string, diff --git a/tools/hangar/__snapshots__/test_corpus/valid/bring_extend_non_entry.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/bring_extend_non_entry.test.w_compile_tf-aws.md index 08321f3d3dd..ff73f6420e8 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/bring_extend_non_entry.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/bring_extend_non_entry.test.w_compile_tf-aws.md @@ -49,8 +49,7 @@ class $Root extends $stdlib.std.Resource { super($scope, $id); $helpers.nodeof(this).root.$preflightTypesMap = { }; let $preflightTypesMap = {}; - const lib = require("./preflight.extendnonentrypoint-1.cjs"); - Object.assign($preflightTypesMap, lib.$preflightTypesMap); + const lib = $helpers.bringJs(`${__dirname}/preflight.extendnonentrypoint-1.cjs`,"$preflightTypesMap", $preflightTypesMap); $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; const f = new lib.Foo(this, "Foo"); } diff --git a/tools/hangar/__snapshots__/test_corpus/valid/bring_local.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/bring_local.test.w_compile_tf-aws.md index 247bb29336c..fad40e73073 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/bring_local.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/bring_local.test.w_compile_tf-aws.md @@ -303,12 +303,9 @@ class $Root extends $stdlib.std.Resource { super($scope, $id); $helpers.nodeof(this).root.$preflightTypesMap = { }; let $preflightTypesMap = {}; - const file1 = require("./preflight.store-2.cjs"); - Object.assign($preflightTypesMap, file1.$preflightTypesMap); - const file2 = require("./preflight.subfile-3.cjs"); - Object.assign($preflightTypesMap, file2.$preflightTypesMap); - const file3 = require("./preflight.empty-1.cjs"); - Object.assign($preflightTypesMap, file3.$preflightTypesMap); + const file1 = $helpers.bringJs(`${__dirname}/preflight.store-2.cjs`,"$preflightTypesMap", $preflightTypesMap); + const file2 = $helpers.bringJs(`${__dirname}/preflight.subfile-3.cjs`,"$preflightTypesMap", $preflightTypesMap); + const file3 = $helpers.bringJs(`${__dirname}/preflight.empty-1.cjs`,"$preflightTypesMap", $preflightTypesMap); const math = $stdlib.math; const expect = $stdlib.expect; $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; @@ -481,8 +478,7 @@ const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); let $preflightTypesMap = {}; -const file3 = require("./preflight.empty-1.cjs"); -Object.assign($preflightTypesMap, file3.$preflightTypesMap); +const file3 = $helpers.bringJs(`${__dirname}/preflight.empty-1.cjs`,"$preflightTypesMap", $preflightTypesMap); const math = $stdlib.math; const cloud = $stdlib.cloud; const Color = diff --git a/tools/hangar/__snapshots__/test_corpus/valid/bring_local_dir.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/bring_local_dir.test.w_compile_tf-aws.md index 01ff2ab9aaf..1f28daac6a4 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/bring_local_dir.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/bring_local_dir.test.w_compile_tf-aws.md @@ -105,10 +105,8 @@ class $Root extends $stdlib.std.Resource { super($scope, $id); $helpers.nodeof(this).root.$preflightTypesMap = { }; let $preflightTypesMap = {}; - const w = require("./preflight.widget-1.cjs"); - Object.assign($preflightTypesMap, w.$preflightTypesMap); - const subdir = require("./preflight.subdir2-6.cjs"); - Object.assign($preflightTypesMap, subdir.$preflightTypesMap); + const w = $helpers.bringJs(`${__dirname}/preflight.widget-1.cjs`,"$preflightTypesMap", $preflightTypesMap); + const subdir = $helpers.bringJs(`${__dirname}/preflight.subdir2-6.cjs`,"$preflightTypesMap", $preflightTypesMap); $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; const widget1 = new w.Widget(this, "widget1"); $helpers.assert($helpers.eq((widget1.compute()), 42), "widget1.compute() == 42"); @@ -135,8 +133,7 @@ const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); let $preflightTypesMap = {}; -const blah = require("./preflight.inner-2.cjs"); -Object.assign($preflightTypesMap, blah.$preflightTypesMap); +const blah = $helpers.bringJs(`${__dirname}/preflight.inner-2.cjs`,"$preflightTypesMap", $preflightTypesMap); const cloud = $stdlib.cloud; const util = $stdlib.util; class Foo extends $stdlib.std.Resource { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/bring_local_normalization.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/bring_local_normalization.test.w_compile_tf-aws.md index cd23b19159d..180e2d0aaf7 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/bring_local_normalization.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/bring_local_normalization.test.w_compile_tf-aws.md @@ -165,12 +165,9 @@ class $Root extends $stdlib.std.Resource { super($scope, $id); $helpers.nodeof(this).root.$preflightTypesMap = { }; let $preflightTypesMap = {}; - const foo = require("./preflight.foo-3.cjs"); - Object.assign($preflightTypesMap, foo.$preflightTypesMap); - const bar = require("./preflight.bar-1.cjs"); - Object.assign($preflightTypesMap, bar.$preflightTypesMap); - const baz = require("./preflight.baz-2.cjs"); - Object.assign($preflightTypesMap, baz.$preflightTypesMap); + const foo = $helpers.bringJs(`${__dirname}/preflight.foo-3.cjs`,"$preflightTypesMap", $preflightTypesMap); + const bar = $helpers.bringJs(`${__dirname}/preflight.bar-1.cjs`,"$preflightTypesMap", $preflightTypesMap); + const baz = $helpers.bringJs(`${__dirname}/preflight.baz-2.cjs`,"$preflightTypesMap", $preflightTypesMap); $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; $helpers.assert($helpers.eq((foo.Foo.foo(this)), "foo"), "foo.Foo.foo() == \"foo\""); $helpers.assert($helpers.eq((foo.Foo.bar(this)), "bar"), "foo.Foo.bar() == \"bar\""); @@ -193,10 +190,8 @@ const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); let $preflightTypesMap = {}; -const bar = require("./preflight.bar-1.cjs"); -Object.assign($preflightTypesMap, bar.$preflightTypesMap); -const baz = require("./preflight.baz-2.cjs"); -Object.assign($preflightTypesMap, baz.$preflightTypesMap); +const bar = $helpers.bringJs(`${__dirname}/preflight.bar-1.cjs`,"$preflightTypesMap", $preflightTypesMap); +const baz = $helpers.bringJs(`${__dirname}/preflight.baz-2.cjs`,"$preflightTypesMap", $preflightTypesMap); class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/bring_wing_library.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/bring_wing_library.test.w_compile_tf-aws.md index 0fb30a163d7..e100383a923 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/bring_wing_library.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/bring_wing_library.test.w_compile_tf-aws.md @@ -113,12 +113,9 @@ class $Root extends $stdlib.std.Resource { super($scope, $id); $helpers.nodeof(this).root.$preflightTypesMap = { }; let $preflightTypesMap = {}; - const fixture = require("./preflight.testfixture-5.cjs"); - Object.assign($preflightTypesMap, fixture.$preflightTypesMap); - const testfixture = require("./preflight.testfixture-5.cjs"); - Object.assign($preflightTypesMap, testfixture.$preflightTypesMap); - const testfixture2 = require("./preflight.testfixture-5.cjs"); - Object.assign($preflightTypesMap, testfixture2.$preflightTypesMap); + const fixture = $helpers.bringJs(`${__dirname}/preflight.testfixture-5.cjs`,"$preflightTypesMap", $preflightTypesMap); + const testfixture = $helpers.bringJs(`${__dirname}/preflight.testfixture-5.cjs`,"$preflightTypesMap", $preflightTypesMap); + const testfixture2 = $helpers.bringJs(`${__dirname}/preflight.testfixture-5.cjs`,"$preflightTypesMap", $preflightTypesMap); $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); @@ -197,8 +194,7 @@ const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); let $preflightTypesMap = {}; const cloud = $stdlib.cloud; -const myutil = require("./preflight.util-2.cjs"); -Object.assign($preflightTypesMap, myutil.$preflightTypesMap); +const myutil = $helpers.bringJs(`${__dirname}/preflight.util-2.cjs`,"$preflightTypesMap", $preflightTypesMap); class Store extends $stdlib.std.Resource { constructor($scope, $id, options) { super($scope, $id); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_capture_preflight_object.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_capture_preflight_object.test.w_compile_tf-aws.md index e474158dd57..6d625f778a3 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_capture_preflight_object.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_capture_preflight_object.test.w_compile_tf-aws.md @@ -270,8 +270,7 @@ class $Root extends $stdlib.std.Resource { $helpers.nodeof(this).root.$preflightTypesMap = { }; let $preflightTypesMap = {}; const cloud = $stdlib.cloud; - const subdir = require("./preflight.subdir2-6.cjs"); - Object.assign($preflightTypesMap, subdir.$preflightTypesMap); + const subdir = $helpers.bringJs(`${__dirname}/preflight.subdir2-6.cjs`,"$preflightTypesMap", $preflightTypesMap); $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { @@ -554,8 +553,7 @@ const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); let $preflightTypesMap = {}; -const blah = require("./preflight.inner-2.cjs"); -Object.assign($preflightTypesMap, blah.$preflightTypesMap); +const blah = $helpers.bringJs(`${__dirname}/preflight.inner-2.cjs`,"$preflightTypesMap", $preflightTypesMap); const cloud = $stdlib.cloud; const util = $stdlib.util; class Foo extends $stdlib.std.Resource { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/intrinsics.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/intrinsics.test.w_compile_tf-aws.md index 61c12072f70..9a33a15dc7c 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/intrinsics.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/intrinsics.test.w_compile_tf-aws.md @@ -285,8 +285,7 @@ class $Root extends $stdlib.std.Resource { const expect = $stdlib.expect; const cloud = $stdlib.cloud; const util = $stdlib.util; - const bar = require("./preflight.bar-1.cjs"); - Object.assign($preflightTypesMap, bar.$preflightTypesMap); + const bar = $helpers.bringJs(`${__dirname}/preflight.bar-1.cjs`,"$preflightTypesMap", $preflightTypesMap); $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Example extends $stdlib.std.Resource { constructor($scope, $id, ) { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/new_in_static.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/new_in_static.test.w_compile_tf-aws.md index ee2ef2e88d1..cdae8aa998f 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/new_in_static.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/new_in_static.test.w_compile_tf-aws.md @@ -183,8 +183,7 @@ class $Root extends $stdlib.std.Resource { const cloud = $stdlib.cloud; const c = require("constructs"); const jsii_fixture = require("jsii-fixture"); - const new_in_static_lib = require("./preflight.newinstaticlib-1.cjs"); - Object.assign($preflightTypesMap, new_in_static_lib.$preflightTypesMap); + const new_in_static_lib = $helpers.bringJs(`${__dirname}/preflight.newinstaticlib-1.cjs`,"$preflightTypesMap", $preflightTypesMap); $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class MyClass extends $stdlib.std.Resource { constructor($scope, $id, ) { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/store.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/store.w_compile_tf-aws.md index 377d4b78ffe..06fadd9e683 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/store.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/store.w_compile_tf-aws.md @@ -60,8 +60,7 @@ const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); let $preflightTypesMap = {}; -const file3 = require("./preflight.empty-1.cjs"); -Object.assign($preflightTypesMap, file3.$preflightTypesMap); +const file3 = $helpers.bringJs(`${__dirname}/preflight.empty-1.cjs`,"$preflightTypesMap", $preflightTypesMap); const math = $stdlib.math; const cloud = $stdlib.cloud; const Color = diff --git a/tools/hangar/__snapshots__/test_corpus/valid/struct_from_json.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/struct_from_json.test.w_compile_tf-aws.md index b6976ae517b..65b5c5dbd8e 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/struct_from_json.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/struct_from_json.test.w_compile_tf-aws.md @@ -183,10 +183,8 @@ class $Root extends $stdlib.std.Resource { $helpers.nodeof(this).root.$preflightTypesMap = { }; let $preflightTypesMap = {}; const cloud = $stdlib.cloud; - const externalStructs = require("./preflight.structs-1.cjs"); - Object.assign($preflightTypesMap, externalStructs.$preflightTypesMap); - const otherExternalStructs = require("./preflight.structs2-2.cjs"); - Object.assign($preflightTypesMap, otherExternalStructs.$preflightTypesMap); + const externalStructs = $helpers.bringJs(`${__dirname}/preflight.structs-1.cjs`,"$preflightTypesMap", $preflightTypesMap); + const otherExternalStructs = $helpers.bringJs(`${__dirname}/preflight.structs2-2.cjs`,"$preflightTypesMap", $preflightTypesMap); const Bar = $stdlib.std.Struct._createJsonSchema({$id:"/Bar",type:"object",properties:{b:{type:"number"},f:{type:"string"},},required:["b","f",]}); const Foo = $stdlib.std.Struct._createJsonSchema({$id:"/Foo",type:"object",properties:{f:{type:"string"},},required:["f",]}); const Foosible = $stdlib.std.Struct._createJsonSchema({$id:"/Foosible",type:"object",properties:{f:{type:"string"},},required:[]}); From 36fbbac6fc5bcefb8d23420db12d7499af3dcebb Mon Sep 17 00:00:00 2001 From: Yoav Steinberg Date: Mon, 17 Jun 2024 14:12:47 +0300 Subject: [PATCH 59/78] cr cleanup --- temp/bla.w | 6 -- temp/bladir/a.w | 13 --- temp/bladir/b.w | 13 --- temp/bladir/common.w | 9 -- temp/main.w | 53 ----------- temp/source.extern.d.ts | 196 ---------------------------------------- temp/source.ts | 0 7 files changed, 290 deletions(-) delete mode 100644 temp/bla.w delete mode 100644 temp/bladir/a.w delete mode 100644 temp/bladir/b.w delete mode 100644 temp/bladir/common.w delete mode 100644 temp/main.w delete mode 100644 temp/source.extern.d.ts delete mode 100644 temp/source.ts diff --git a/temp/bla.w b/temp/bla.w deleted file mode 100644 index e070852a700..00000000000 --- a/temp/bla.w +++ /dev/null @@ -1,6 +0,0 @@ -bring cloud; -pub inflight class Bar { - pub method() { - log("method called"); - } -} diff --git a/temp/bladir/a.w b/temp/bladir/a.w deleted file mode 100644 index f8e842b9212..00000000000 --- a/temp/bladir/a.w +++ /dev/null @@ -1,13 +0,0 @@ -bring "./common.w" as common; - -pub inflight class FooA { - pub method() { - new common.Common(); - } -} - -pub class BarA { - pub method() { - new common.CommonBar(); - } -} \ No newline at end of file diff --git a/temp/bladir/b.w b/temp/bladir/b.w deleted file mode 100644 index d488f4b07bc..00000000000 --- a/temp/bladir/b.w +++ /dev/null @@ -1,13 +0,0 @@ -bring "./common.w" as common; - -pub inflight class FooB { - pub method() { - new common.Common(); - } -} - -pub class BarB { - pub method() { - new common.CommonBar(); - } -} \ No newline at end of file diff --git a/temp/bladir/common.w b/temp/bladir/common.w deleted file mode 100644 index 666f7e708b9..00000000000 --- a/temp/bladir/common.w +++ /dev/null @@ -1,9 +0,0 @@ -pub inflight class Common { - pub method() { - } -} - -pub class CommonBar { - pub method() { - } -} \ No newline at end of file diff --git a/temp/main.w b/temp/main.w deleted file mode 100644 index e15b57e3ade..00000000000 --- a/temp/main.w +++ /dev/null @@ -1,53 +0,0 @@ -// bring "./bladir" as bladir; - -// inflight () => { -// let a = new bladir.FooA(); -// a.method(); -// let b = new bladir.FooB(); -// b.method(); -// }; - -// let pfa = new bladir.BarA(); -// pfa.method(); -// let pfb = new bladir.BarB(); -// pfb.method(); - -bring cloud; -bring "./bla.w" as bla; - -let b = new cloud.Bucket(); -let myConst = "bang bang"; - -inflight class Foo { - pub uploadToBucket(k: str, value: str) { - b.put(k, value); - log(b.get("hello.txt")); - } -} - -let getAnF = inflight () => { - return new Foo(); -}; - -let getABar = inflight () => { - return new bla.Bar(); -}; - -if true { - let b =1; - let f = 2; - - test "inflight class captures preflight resource" { - let f = getAnF(); - f.uploadToBucket("hello.txt", "world"); - let b = getABar(); - b.method(); - } -} - -test "another test" { - let f = getAnF(); - f.uploadToBucket("hello.txt", "world"); - let b = getABar(); - b.method(); -} diff --git a/temp/source.extern.d.ts b/temp/source.extern.d.ts deleted file mode 100644 index 98ee5a643cd..00000000000 --- a/temp/source.extern.d.ts +++ /dev/null @@ -1,196 +0,0 @@ -export default interface extern { - foo: (b: Bucket$Inflight) => Promise, -} -/** Trait marker for classes that can be depended upon. -The presence of this interface indicates that an object has -an `IDependable` implementation. - -This interface can be used to take an (ordering) dependency on a set of -constructs. An ordering dependency implies that the resources represented by -those constructs are deployed before the resources depending ON them are -deployed. */ -export interface IDependable$Inflight { -} -/** Represents a construct. */ -export interface IConstruct$Inflight extends IDependable$Inflight { -} -/** Represents the building block of the construct graph. -All constructs besides the root construct must be created within the scope of -another construct. */ -export class Construct$Inflight implements IConstruct$Inflight { -} -/** Data that can be lifted into inflight. */ -export interface ILiftable$Inflight { -} -/** A liftable object that needs to be registered on the host as part of the lifting process. -This is generally used so the host can set up permissions -to access the lifted object inflight. */ -export interface IHostedLiftable$Inflight extends ILiftable$Inflight { -} -/** Abstract interface for `Resource`. */ -export interface IResource$Inflight extends IConstruct$Inflight, IHostedLiftable$Inflight { -} -/** Shared behavior between all Wing SDK resources. */ -export class Resource$Inflight extends Construct$Inflight implements IResource$Inflight { -} -/** Options for `Bucket.delete()`. */ -export interface BucketDeleteOptions { - /** Check failures on the method and retrieve errors if any. */ - readonly mustExist?: (boolean) | undefined; -} -/** Options for `Bucket.get()`. */ -export interface BucketGetOptions { - /** The ending byte to read up to (including). */ - readonly endByte?: (number) | undefined; - /** The starting byte to read from. */ - readonly startByte?: (number) | undefined; -} -/** Data that can be lifted into inflight. */ -export interface ILiftable { -} -/** Represents a local or UTC date object. */ -export class Datetime implements ILiftable { - /** Returns the day of month in the local machine time or in utc (1 - 31). - @returns a number representing the datetime's day of month */ - readonly dayOfMonth: number; - /** Returns the day in month of the local machine time or in utc (0 - 6). - @returns a number representing the datetime's day of week */ - readonly dayOfWeek: number; - /** Returns the hour of the local machine time or in utc. - @returns a number representing the datetime's hour */ - readonly hours: number; - /** Returns the minute of the local machine time or in utc. - @returns a number representing the datetime's minute */ - readonly min: number; - /** Returns the month of the local machine time or in utc (0 - 11). - @returns a number representing the datetime's month */ - readonly month: number; - /** Returns the milliseconds of the local machine time or in utc *. - @returns a number representing the datetime's milliseconds */ - readonly ms: number; - /** Returns the seconds of the local machine time or in utc. - @returns a number representing the datetime's seconds */ - readonly sec: number; - /** Return a timestamp of non-leap year seconds since epoch. - @returns a number representing the current timestamp in seconds */ - readonly timestamp: number; - /** Return a timestamp of non-leap year milliseconds since epoch. - @returns a number representing the current timestamp in milliseconds */ - readonly timestampMs: number; - /** Returns the offset in minutes from UTC. - @returns a number representing the datetime's offset in minutes from UTC */ - readonly timezone: number; - /** Returns ISO-8601 string. - @returns a ISO-8601 string representation of the datetime */ - readonly toIso: () => string; - /** Returns a Datetime represents the same date in utc. - @returns a datetime representing the datetime's date in UTC */ - readonly toUtc: () => Datetime; - /** Returns the year of the local machine time or in utc. - @returns a number representing the datetime's year */ - readonly year: number; -} -/** Metadata of a bucket object. */ -export interface ObjectMetadata { - /** The content type of the object, if it is known. */ - readonly contentType?: (string) | undefined; - /** The time the object was last modified. */ - readonly lastModified: Datetime; - /** The size of the object in bytes. */ - readonly size: number; -} -/** Options for `Bucket.put()`. */ -export interface BucketPutOptions { - /** The HTTP Content-Type of the object. - @see https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers/Content-Type */ - readonly contentType: string; -} -/** Specifies the action permitted by a presigned URL for a bucket. */ -export enum BucketSignedUrlAction { - DOWNLOAD = 0, - UPLOAD = 1, -} -/** Represents a length of time. */ -export class Duration implements ILiftable { - /** Return the total number of days in this Duration. - @returns the value of this `Duration` expressed in Days. */ - readonly days: number; - /** Return the total number of hours in this Duration. - @returns the value of this `Duration` expressed in Hours. */ - readonly hours: number; - /** Return the total number of milliseconds in this Duration. - @returns the value of this `Duration` expressed in Milliseconds. */ - readonly milliseconds: number; - /** Return the total number of minutes in this Duration. - @returns the value of this `Duration` expressed in Minutes. */ - readonly minutes: number; - /** Return the total number of months in this Duration. - @returns the value of this `Duration` expressed in Months. */ - readonly months: number; - /** Return the total number of seconds in this Duration. - @returns the value of this `Duration` expressed in Seconds. */ - readonly seconds: number; - /** Return the total number of years in this Duration. - @returns the value of this `Duration` expressed in Years. */ - readonly years: number; -} -/** Options for `Bucket.signedUrl()`. */ -export interface BucketSignedUrlOptions { - /** The action allowed by the signed URL. */ - readonly action?: (BucketSignedUrlAction) | undefined; - /** The duration for the signed URL to expire. */ - readonly duration?: (Duration) | undefined; -} -/** Options for `Bucket.tryGet()`. */ -export interface BucketTryGetOptions { - /** The ending byte to read up to (including). */ - readonly endByte?: (number) | undefined; - /** The starting byte to read from. */ - readonly startByte?: (number) | undefined; -} -/** A cloud object store. */ -export class Bucket$Inflight extends Resource$Inflight { - /** Copy an object to a new location in the bucket. - If the destination object - already exists, it will be overwritten. */ - readonly copy: (srcKey: string, dstKey: string) => Promise; - /** Delete an existing object using a key from the bucket. */ - readonly delete: (key: string, opts?: (BucketDeleteOptions) | undefined) => Promise; - /** Check if an object exists in the bucket. */ - readonly exists: (key: string) => Promise; - /** Retrieve an object from the bucket. - If the bytes returned are not a valid UTF-8 string, an error is thrown. */ - readonly get: (key: string, options?: (BucketGetOptions) | undefined) => Promise; - /** Retrieve a Json object from the bucket. */ - readonly getJson: (key: string) => Promise>; - /** Retrieve existing objects keys from the bucket. - @returns a list of keys or an empty array if the bucket is empty. */ - readonly list: (prefix?: (string) | undefined) => Promise<(readonly (string)[])>; - /** Get the metadata of an object in the bucket. */ - readonly metadata: (key: string) => Promise; - /** Returns a url to the given file. */ - readonly publicUrl: (key: string) => Promise; - /** Put an object in the bucket. */ - readonly put: (key: string, body: string, options?: (BucketPutOptions) | undefined) => Promise; - /** Put a Json object in the bucket. */ - readonly putJson: (key: string, body: Readonly) => Promise; - /** Move an object to a new location in the bucket. - If the destination object - already exists, it will be overwritten. Returns once the renaming is finished. */ - readonly rename: (srcKey: string, dstKey: string) => Promise; - /** Returns a signed url to the given file. - @returns A string representing the signed url of the object which can be used to download in any downstream system */ - readonly signedUrl: (key: string, options?: (BucketSignedUrlOptions) | undefined) => Promise; - /** Delete an object from the bucket if it exists. - @returns the result of the delete operation */ - readonly tryDelete: (key: string) => Promise; - /** Get an object from the bucket if it exists If the bytes returned are not a valid UTF-8 string, an error is thrown. - @returns the contents of the object as a string if it exists, nil otherwise */ - readonly tryGet: (key: string, options?: (BucketTryGetOptions) | undefined) => Promise<(string) | undefined>; - /** Gets an object from the bucket if it exists, parsing it as Json. - @returns the contents of the object as Json if it exists, nil otherwise */ - readonly tryGetJson: (key: string) => Promise<(Readonly) | undefined>; -} -export class Output$Inflight { - readonly $inflight_init: (b: Bucket$Inflight) => Promise; -} \ No newline at end of file diff --git a/temp/source.ts b/temp/source.ts deleted file mode 100644 index e69de29bb2d..00000000000 From 8a73252f03a92b27151f65cfb7cecab9dee2b5cb Mon Sep 17 00:00:00 2001 From: Yoav Steinberg Date: Wed, 26 Jun 2024 13:53:40 +0300 Subject: [PATCH 60/78] cr: comments --- libs/wingc/src/type_check.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libs/wingc/src/type_check.rs b/libs/wingc/src/type_check.rs index 8960629424c..eabb3c8ebad 100644 --- a/libs/wingc/src/type_check.rs +++ b/libs/wingc/src/type_check.rs @@ -335,8 +335,10 @@ pub struct Class { // and instead the user will need to pass the relevant args to the class's init method. pub std_construct_args: bool, - // Unique identifier for this class type, used to generate a unique type alias for this class so we can - // reference it regardless of type name shadowing or scoping. + // Unique identifier for this class type, used to get access to the type's generated preflight code even when + // the type name isn't available in scope or is shadowed. + // Ideally we should use the FQN and unify the implementation of JSII imported classes and Wing classes, currently + // uid is used for Wing classes and is always 0 for JSII classes to avoid snapshot noise. pub uid: usize, } impl Class { From 6b09dd05c0508c3fed9b88e1083906aaa3c425de Mon Sep 17 00:00:00 2001 From: Yoav Steinberg Date: Wed, 26 Jun 2024 13:59:06 +0300 Subject: [PATCH 61/78] cr --- libs/wingc/src/type_check.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/libs/wingc/src/type_check.rs b/libs/wingc/src/type_check.rs index eabb3c8ebad..70458e265dc 100644 --- a/libs/wingc/src/type_check.rs +++ b/libs/wingc/src/type_check.rs @@ -1450,7 +1450,9 @@ impl Types { append_empty_struct_to_arglist: HashSet::new(), libraries: SymbolEnv::new(None, SymbolEnvKind::Scope, Phase::Preflight, 0), intrinsics: SymbolEnv::new(None, SymbolEnvKind::Scope, Phase::Independent, 0), - class_counter: 0, + // 1 based to avoid conflict with imported JSII classes. This isn't strictly needed since brought JSII classes are never accessed + // through their unique ID, but still good to avoid confusion. + class_counter: 1, } } From 6fb4361f8c688faefc23a9f2785973460e93e8f7 Mon Sep 17 00:00:00 2001 From: Yoav Steinberg Date: Wed, 26 Jun 2024 15:00:05 +0300 Subject: [PATCH 62/78] cr: refactor --- libs/wingc/src/jsify.rs | 5 +---- libs/wingsdk/src/helpers.ts | 23 +++++++++++++++++++++++ libs/wingsdk/src/std/resource.ts | 23 ----------------------- 3 files changed, 24 insertions(+), 27 deletions(-) diff --git a/libs/wingc/src/jsify.rs b/libs/wingc/src/jsify.rs index ba4db9240a0..bd26f896150 100644 --- a/libs/wingc/src/jsify.rs +++ b/libs/wingc/src/jsify.rs @@ -1880,10 +1880,7 @@ impl<'a> JSifier<'a> { pub fn class_singleton(&self, type_: TypeRef) -> String { let c = type_.as_class().unwrap(); - format!( - "{PREFLIGHT_TYPES_MAP}[{}]._singleton(this,\"{}_singleton_{}\")", - c.uid, c.name, c.uid - ) + format!("$helpers.preflightClassSingleton(this, {})", c.uid) } fn jsify_preflight_constructor(&self, class: &AstClass, ctx: &mut JSifyContext) -> CodeMaker { diff --git a/libs/wingsdk/src/helpers.ts b/libs/wingsdk/src/helpers.ts index 01a205eb6ff..70daa4e873b 100644 --- a/libs/wingsdk/src/helpers.ts +++ b/libs/wingsdk/src/helpers.ts @@ -8,6 +8,7 @@ import type { Node } from "./std/node"; // https://github.com/winglang/wing/issues/4444 // therefore we're using a local version of the comparison from node 18. import { deepStrictEqual } from "./util/equality"; +import { std } from "."; export function eq(a: any, b: any): boolean { try { @@ -193,3 +194,25 @@ export function bringJs( }) ); } + +/** + * Helper function to get a singleton instance of a class defined in preflight. + * In practice this is used to get the preflight instance of **inflight** classes defined **preflight**. + * This instance is used for accessing the lift map of such classes. + * @param scope - a scope in the construct tree that'll hold the instance (a singleton within that tree). + * @param typeId - the unique id of the preflight class type we want. + * @returns the instance of the class. + */ +export function preflightClassSingleton(scope: Construct, typeId: number): std.Resource { + const root: any = nodeof(scope).root; + const type: any = root.$preflightTypesMap[typeId]; + if (root.resourceSingletons === undefined) { + root.resourceSingletons = {}; + } + const instance = root.resourceSingletons[type]; + if (instance) { + return instance; + } + root.resourceSingletons[type] = new type(scope, `${type.name}_singleton_${typeId}`); + return root.resourceSingletons[type]; +} \ No newline at end of file diff --git a/libs/wingsdk/src/std/resource.ts b/libs/wingsdk/src/std/resource.ts index d5e66fa3ec9..bd28fed4286 100644 --- a/libs/wingsdk/src/std/resource.ts +++ b/libs/wingsdk/src/std/resource.ts @@ -148,29 +148,6 @@ export abstract class Resource extends Construct implements IResource { return obj._toInflight(); } - /** - * Create a singleton of this resource. This uses `this` in a static context - * to create a singleton of any subclass of `Resource`. - * This helper function is used to create a single dummy instance of `inflight class`es - * defined in preflight code. This instances are needed to create a lift qualification - * map for such classes. - * - * @internal - */ - public static _singleton(scope: Construct, id: string): Resource { - const root: any = Node.of(scope).root; - let t: any = this; - if (root.resourceSingletons === undefined) { - root.resourceSingletons = {}; - } - const instance = root.resourceSingletons[t]; - if (instance) { - return instance; - } - root.resourceSingletons[t] = new t(root, id); - return root.resourceSingletons[t]; - } - /** * Create an instance of this resource with the current App factory. * This is commonly used in the constructor of a pseudo-abstract resource class before the super() call. From bf29b3edc08947b278f2933bf57797d1cde5a1d9 Mon Sep 17 00:00:00 2001 From: Yoav Steinberg Date: Wed, 26 Jun 2024 15:34:02 +0300 Subject: [PATCH 63/78] cr fix --- libs/wingsdk/src/helpers.ts | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libs/wingsdk/src/helpers.ts b/libs/wingsdk/src/helpers.ts index 70daa4e873b..66c4fe2c896 100644 --- a/libs/wingsdk/src/helpers.ts +++ b/libs/wingsdk/src/helpers.ts @@ -187,6 +187,10 @@ export function bringJs( Object.entries(require(moduleFile)).filter(([k, v]) => { // If this is the preflight types array then update the input object and skip it if (k === preflightTypesObjectName) { + // Verify no key collision (should never happen) + Object.keys(v as object).forEach((key) => { + if (key in outPreflightTypesObject) throw new Error(`Key collision (${key}) in preflight types map`); + }); Object.assign(outPreflightTypesObject, v); return false; } From 073bde26fa91f93aceca2fa079c14059a8382959 Mon Sep 17 00:00:00 2001 From: Yoav Steinberg Date: Wed, 26 Jun 2024 15:44:49 +0300 Subject: [PATCH 64/78] snapshots --- .../bring_local_dir.test.w_compile_tf-aws.md | 4 ++-- ..._static_of_myself.test.w_compile_tf-aws.md | 8 ++++---- .../valid/class.test.w_compile_tf-aws.md | 12 +++++------ .../impl_interface.test.w_compile_tf-aws.md | 4 ++-- ...ht_capture_static.test.w_compile_tf-aws.md | 4 ++-- ...as_struct_members.test.w_compile_tf-aws.md | 8 ++++---- ...ass_capture_const.test.w_compile_tf-aws.md | 8 ++++---- ..._preflight_object.test.w_compile_tf-aws.md | 20 +++++++++---------- ...class_definitions.test.w_compile_tf-aws.md | 16 +++++++-------- ...t_class_modifiers.test.w_compile_tf-aws.md | 4 ++-- ..._inflight_closure.test.w_compile_tf-aws.md | 8 ++++---- ..._interace_handler.test.w_compile_tf-aws.md | 4 ++-- ...lass_without_init.test.w_compile_tf-aws.md | 4 ++-- .../inflight_init.test.w_compile_tf-aws.md | 16 +++++++-------- ..._object_issue6501.test.w_compile_tf-aws.md | 8 ++++---- .../sim_resource.test.w_compile_tf-aws.md | 4 ++-- .../valid/super_call.test.w_compile_tf-aws.md | 12 +++++------ 17 files changed, 72 insertions(+), 72 deletions(-) diff --git a/tools/hangar/__snapshots__/test_corpus/valid/bring_local_dir.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/bring_local_dir.test.w_compile_tf-aws.md index 1f28daac6a4..4aeb799bedb 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/bring_local_dir.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/bring_local_dir.test.w_compile_tf-aws.md @@ -285,8 +285,8 @@ class InflightClass extends $stdlib.std.Resource { }); } } -if ($preflightTypesMap[4]) { throw new Error("InflightClass is already in type map"); } -$preflightTypesMap[4] = InflightClass; +if ($preflightTypesMap[5]) { throw new Error("InflightClass is already in type map"); } +$preflightTypesMap[5] = InflightClass; module.exports = { $preflightTypesMap, InflightClass }; //# sourceMappingURL=preflight.inflightclass-5.cjs.map ``` diff --git a/tools/hangar/__snapshots__/test_corpus/valid/call_static_of_myself.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/call_static_of_myself.test.w_compile_tf-aws.md index 15929b94a08..e81b4ae5207 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/call_static_of_myself.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/call_static_of_myself.test.w_compile_tf-aws.md @@ -185,8 +185,8 @@ class $Root extends $stdlib.std.Resource { }); } } - if ($preflightTypesMap[1]) { throw new Error("Bar is already in type map"); } - $preflightTypesMap[1] = Bar; + if ($preflightTypesMap[2]) { throw new Error("Bar is already in type map"); } + $preflightTypesMap[2] = Bar; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -216,13 +216,13 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ - [$helpers.nodeof(this).root.$preflightTypesMap[1]._singleton(this,"Bar_singleton_1"), ["callThis"]], + [$helpers.preflightClassSingleton(this, 2), ["callThis"]], [Bar, ["bar"]], [Foo, ["foo"]], [foo, ["callThis"]], ], "$inflight_init": [ - [$helpers.nodeof(this).root.$preflightTypesMap[1]._singleton(this,"Bar_singleton_1"), []], + [$helpers.preflightClassSingleton(this, 2), []], [Bar, []], [Foo, []], [foo, []], diff --git a/tools/hangar/__snapshots__/test_corpus/valid/class.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/class.test.w_compile_tf-aws.md index bd8f09c2008..0827f250cbf 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/class.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/class.test.w_compile_tf-aws.md @@ -1157,8 +1157,8 @@ class $Root extends $stdlib.std.Resource { }); } } - if ($preflightTypesMap[19]) { throw new Error("A is already in type map"); } - $preflightTypesMap[19] = A; + if ($preflightTypesMap[20]) { throw new Error("A is already in type map"); } + $preflightTypesMap[20] = A; class B extends A { constructor($scope, $id, ) { super($scope, $id); @@ -1188,8 +1188,8 @@ class $Root extends $stdlib.std.Resource { }); } } - if ($preflightTypesMap[20]) { throw new Error("B is already in type map"); } - $preflightTypesMap[20] = B; + if ($preflightTypesMap[21]) { throw new Error("B is already in type map"); } + $preflightTypesMap[21] = B; class $Closure5 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -1217,11 +1217,11 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ - [$helpers.nodeof(this).root.$preflightTypesMap[20]._singleton(this,"B_singleton_20"), ["sound"]], + [$helpers.preflightClassSingleton(this, 21), ["sound"]], [B, []], ], "$inflight_init": [ - [$helpers.nodeof(this).root.$preflightTypesMap[20]._singleton(this,"B_singleton_20"), []], + [$helpers.preflightClassSingleton(this, 21), []], [B, []], ], }); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/impl_interface.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/impl_interface.test.w_compile_tf-aws.md index e0d7bf011db..52b7e149414 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/impl_interface.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/impl_interface.test.w_compile_tf-aws.md @@ -629,8 +629,8 @@ class $Root extends $stdlib.std.Resource { }); } } - if ($preflightTypesMap[10]) { throw new Error("ImplInflightIfaceInInflightClass is already in type map"); } - $preflightTypesMap[10] = ImplInflightIfaceInInflightClass; + if ($preflightTypesMap[11]) { throw new Error("ImplInflightIfaceInInflightClass is already in type map"); } + $preflightTypesMap[11] = ImplInflightIfaceInInflightClass; class ImplInflightIfaceInPreflightClass extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight_capture_static.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight_capture_static.test.w_compile_tf-aws.md index e0b5a62dcc6..7e7f20706c3 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight_capture_static.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight_capture_static.test.w_compile_tf-aws.md @@ -230,8 +230,8 @@ class $Root extends $stdlib.std.Resource { }); } } - if ($preflightTypesMap[1]) { throw new Error("OuterInflight is already in type map"); } - $preflightTypesMap[1] = OuterInflight; + if ($preflightTypesMap[2]) { throw new Error("OuterInflight is already in type map"); } + $preflightTypesMap[2] = OuterInflight; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_as_struct_members.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_as_struct_members.test.w_compile_tf-aws.md index e279c3089b9..1bec37e0b1a 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_as_struct_members.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_as_struct_members.test.w_compile_tf-aws.md @@ -121,8 +121,8 @@ class $Root extends $stdlib.std.Resource { }); } } - if ($preflightTypesMap[0]) { throw new Error("Foo is already in type map"); } - $preflightTypesMap[0] = Foo; + if ($preflightTypesMap[1]) { throw new Error("Foo is already in type map"); } + $preflightTypesMap[1] = Foo; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -185,11 +185,11 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ - [$helpers.nodeof(this).root.$preflightTypesMap[0]._singleton(this,"Foo_singleton_0"), ["get"]], + [$helpers.preflightClassSingleton(this, 1), ["get"]], [getBar, ["handle"]], ], "$inflight_init": [ - [$helpers.nodeof(this).root.$preflightTypesMap[0]._singleton(this,"Foo_singleton_0"), []], + [$helpers.preflightClassSingleton(this, 1), []], [getBar, []], ], }); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_capture_const.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_capture_const.test.w_compile_tf-aws.md index 09ab5eeb98c..703c8737687 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_capture_const.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_capture_const.test.w_compile_tf-aws.md @@ -105,8 +105,8 @@ class $Root extends $stdlib.std.Resource { }); } } - if ($preflightTypesMap[0]) { throw new Error("Foo is already in type map"); } - $preflightTypesMap[0] = Foo; + if ($preflightTypesMap[1]) { throw new Error("Foo is already in type map"); } + $preflightTypesMap[1] = Foo; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -135,12 +135,12 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ - [$helpers.nodeof(this).root.$preflightTypesMap[0]._singleton(this,"Foo_singleton_0"), ["getValue"]], + [$helpers.preflightClassSingleton(this, 1), ["getValue"]], [Foo, []], [myConst, []], ], "$inflight_init": [ - [$helpers.nodeof(this).root.$preflightTypesMap[0]._singleton(this,"Foo_singleton_0"), []], + [$helpers.preflightClassSingleton(this, 1), []], [Foo, []], [myConst, []], ], diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_capture_preflight_object.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_capture_preflight_object.test.w_compile_tf-aws.md index 6d625f778a3..5a67bf934ad 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_capture_preflight_object.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_capture_preflight_object.test.w_compile_tf-aws.md @@ -312,8 +312,8 @@ class $Root extends $stdlib.std.Resource { }); } } - if ($preflightTypesMap[5]) { throw new Error("Foo is already in type map"); } - $preflightTypesMap[5] = Foo; + if ($preflightTypesMap[6]) { throw new Error("Foo is already in type map"); } + $preflightTypesMap[6] = Foo; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -341,11 +341,11 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ - [$helpers.nodeof(this).root.$preflightTypesMap[5]._singleton(this,"Foo_singleton_5"), ["uploadToBucket"]], + [$helpers.preflightClassSingleton(this, 6), ["uploadToBucket"]], [Foo, []], ], "$inflight_init": [ - [$helpers.nodeof(this).root.$preflightTypesMap[5]._singleton(this,"Foo_singleton_5"), []], + [$helpers.preflightClassSingleton(this, 6), []], [Foo, []], ], }); @@ -448,11 +448,11 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ - [$helpers.nodeof(this).root.$preflightTypesMap[5]._singleton(this,"Foo_singleton_5"), ["uploadToBucket"]], + [$helpers.preflightClassSingleton(this, 6), ["uploadToBucket"]], [getFoo, ["handle"]], ], "$inflight_init": [ - [$helpers.nodeof(this).root.$preflightTypesMap[5]._singleton(this,"Foo_singleton_5"), []], + [$helpers.preflightClassSingleton(this, 6), []], [getFoo, []], ], }); @@ -520,11 +520,11 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ - [$helpers.nodeof(this).root.$preflightTypesMap[4]._singleton(this,"InflightClass_singleton_4"), ["method"]], + [$helpers.preflightClassSingleton(this, 5), ["method"]], [$stdlib.core.toLiftableModuleType(subdir.InflightClass, "", "InflightClass"), []], ], "$inflight_init": [ - [$helpers.nodeof(this).root.$preflightTypesMap[4]._singleton(this,"InflightClass_singleton_4"), []], + [$helpers.preflightClassSingleton(this, 5), []], [$stdlib.core.toLiftableModuleType(subdir.InflightClass, "", "InflightClass"), []], ], }); @@ -705,8 +705,8 @@ class InflightClass extends $stdlib.std.Resource { }); } } -if ($preflightTypesMap[4]) { throw new Error("InflightClass is already in type map"); } -$preflightTypesMap[4] = InflightClass; +if ($preflightTypesMap[5]) { throw new Error("InflightClass is already in type map"); } +$preflightTypesMap[5] = InflightClass; module.exports = { $preflightTypesMap, InflightClass }; //# sourceMappingURL=preflight.inflightclass-5.cjs.map ``` diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_definitions.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_definitions.test.w_compile_tf-aws.md index da914c7dadf..4bbf44801fc 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_definitions.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_definitions.test.w_compile_tf-aws.md @@ -248,8 +248,8 @@ class $Root extends $stdlib.std.Resource { }); } } - if ($preflightTypesMap[1]) { throw new Error("B is already in type map"); } - $preflightTypesMap[1] = B; + if ($preflightTypesMap[2]) { throw new Error("B is already in type map"); } + $preflightTypesMap[2] = B; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -348,8 +348,8 @@ class $Root extends $stdlib.std.Resource { }); } } - if ($preflightTypesMap[7]) { throw new Error("F is already in type map"); } - $preflightTypesMap[7] = F; + if ($preflightTypesMap[8]) { throw new Error("F is already in type map"); } + $preflightTypesMap[8] = F; class $Closure2 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -377,11 +377,11 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ - [$helpers.nodeof(this).root.$preflightTypesMap[7]._singleton(this,"F_singleton_7"), ["foo"]], + [$helpers.preflightClassSingleton(this, 8), ["foo"]], [F, ["foo"]], ], "$inflight_init": [ - [$helpers.nodeof(this).root.$preflightTypesMap[7]._singleton(this,"F_singleton_7"), []], + [$helpers.preflightClassSingleton(this, 8), []], [F, []], ], }); @@ -452,7 +452,7 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ - [$helpers.nodeof(this).root.$preflightTypesMap[1]._singleton(this,"B_singleton_1"), ["foo"]], + [$helpers.preflightClassSingleton(this, 2), ["foo"]], [B, []], [a, ["goo"]], [d, ["callInner"]], @@ -460,7 +460,7 @@ class $Root extends $stdlib.std.Resource { [innerD, ["handle"]], ], "$inflight_init": [ - [$helpers.nodeof(this).root.$preflightTypesMap[1]._singleton(this,"B_singleton_1"), []], + [$helpers.preflightClassSingleton(this, 2), []], [B, []], [a, []], [d, []], diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_modifiers.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_modifiers.test.w_compile_tf-aws.md index 7e344980f01..d5b0b360981 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_modifiers.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_modifiers.test.w_compile_tf-aws.md @@ -87,8 +87,8 @@ class $Root extends $stdlib.std.Resource { }); } } - if ($preflightTypesMap[0]) { throw new Error("C is already in type map"); } - $preflightTypesMap[0] = C; + if ($preflightTypesMap[1]) { throw new Error("C is already in type map"); } + $preflightTypesMap[1] = C; } } const $PlatformManager = new $stdlib.platform.PlatformManager({platformPaths: $platforms}); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_outside_inflight_closure.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_outside_inflight_closure.test.w_compile_tf-aws.md index f38ba917abc..33111bd19d7 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_outside_inflight_closure.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_outside_inflight_closure.test.w_compile_tf-aws.md @@ -114,8 +114,8 @@ class $Root extends $stdlib.std.Resource { }); } } - if ($preflightTypesMap[0]) { throw new Error("BinaryOperation is already in type map"); } - $preflightTypesMap[0] = BinaryOperation; + if ($preflightTypesMap[1]) { throw new Error("BinaryOperation is already in type map"); } + $preflightTypesMap[1] = BinaryOperation; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -143,11 +143,11 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ - [$helpers.nodeof(this).root.$preflightTypesMap[0]._singleton(this,"BinaryOperation_singleton_0"), ["add"]], + [$helpers.preflightClassSingleton(this, 1), ["add"]], [BinaryOperation, []], ], "$inflight_init": [ - [$helpers.nodeof(this).root.$preflightTypesMap[0]._singleton(this,"BinaryOperation_singleton_0"), []], + [$helpers.preflightClassSingleton(this, 1), []], [BinaryOperation, []], ], }); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_structural_interace_handler.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_structural_interace_handler.test.w_compile_tf-aws.md index 9b7b109ab09..91173a4f4d9 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_structural_interace_handler.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_structural_interace_handler.test.w_compile_tf-aws.md @@ -113,8 +113,8 @@ class $Root extends $stdlib.std.Resource { }); } } - if ($preflightTypesMap[0]) { throw new Error("NotGoo is already in type map"); } - $preflightTypesMap[0] = NotGoo; + if ($preflightTypesMap[1]) { throw new Error("NotGoo is already in type map"); } + $preflightTypesMap[1] = NotGoo; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_without_init.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_without_init.test.w_compile_tf-aws.md index 0978d2094df..2220db8b354 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_without_init.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_without_init.test.w_compile_tf-aws.md @@ -96,8 +96,8 @@ class $Root extends $stdlib.std.Resource { }); } } - if ($preflightTypesMap[0]) { throw new Error("Foo is already in type map"); } - $preflightTypesMap[0] = Foo; + if ($preflightTypesMap[1]) { throw new Error("Foo is already in type map"); } + $preflightTypesMap[1] = Foo; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight_init.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight_init.test.w_compile_tf-aws.md index d5fe6e510d1..36f615e019b 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight_init.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight_init.test.w_compile_tf-aws.md @@ -235,8 +235,8 @@ class $Root extends $stdlib.std.Resource { }); } } - if ($preflightTypesMap[0]) { throw new Error("Foo is already in type map"); } - $preflightTypesMap[0] = Foo; + if ($preflightTypesMap[1]) { throw new Error("Foo is already in type map"); } + $preflightTypesMap[1] = Foo; class FooChild extends Foo { constructor($scope, $id, ) { super($scope, $id); @@ -269,8 +269,8 @@ class $Root extends $stdlib.std.Resource { }); } } - if ($preflightTypesMap[1]) { throw new Error("FooChild is already in type map"); } - $preflightTypesMap[1] = FooChild; + if ($preflightTypesMap[2]) { throw new Error("FooChild is already in type map"); } + $preflightTypesMap[2] = FooChild; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -298,11 +298,11 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ - [$helpers.nodeof(this).root.$preflightTypesMap[0]._singleton(this,"Foo_singleton_0"), [].concat(["field1"], ["field2"])], + [$helpers.preflightClassSingleton(this, 1), [].concat(["field1"], ["field2"])], [Foo, []], ], "$inflight_init": [ - [$helpers.nodeof(this).root.$preflightTypesMap[0]._singleton(this,"Foo_singleton_0"), []], + [$helpers.preflightClassSingleton(this, 1), []], [Foo, []], ], }); @@ -335,11 +335,11 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ - [$helpers.nodeof(this).root.$preflightTypesMap[1]._singleton(this,"FooChild_singleton_1"), [].concat(["field1"], ["field2"], ["field3"])], + [$helpers.preflightClassSingleton(this, 2), [].concat(["field1"], ["field2"], ["field3"])], [FooChild, []], ], "$inflight_init": [ - [$helpers.nodeof(this).root.$preflightTypesMap[1]._singleton(this,"FooChild_singleton_1"), []], + [$helpers.preflightClassSingleton(this, 2), []], [FooChild, []], ], }); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/lift_inflight_closure_returning_object_issue6501.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/lift_inflight_closure_returning_object_issue6501.test.w_compile_tf-aws.md index 9b1705a1863..7e3bd6052d8 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/lift_inflight_closure_returning_object_issue6501.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/lift_inflight_closure_returning_object_issue6501.test.w_compile_tf-aws.md @@ -178,8 +178,8 @@ class $Root extends $stdlib.std.Resource { }); } } - if ($preflightTypesMap[0]) { throw new Error("Foo is already in type map"); } - $preflightTypesMap[0] = Foo; + if ($preflightTypesMap[1]) { throw new Error("Foo is already in type map"); } + $preflightTypesMap[1] = Foo; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -242,11 +242,11 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ - [$helpers.nodeof(this).root.$preflightTypesMap[0]._singleton(this,"Foo_singleton_0"), ["do"]], + [$helpers.preflightClassSingleton(this, 1), ["do"]], [foo, ["handle"]], ], "$inflight_init": [ - [$helpers.nodeof(this).root.$preflightTypesMap[0]._singleton(this,"Foo_singleton_0"), []], + [$helpers.preflightClassSingleton(this, 1), []], [foo, []], ], }); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/sim_resource.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/sim_resource.test.w_compile_tf-aws.md index f1ca7078fcd..311f848b334 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/sim_resource.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/sim_resource.test.w_compile_tf-aws.md @@ -148,8 +148,8 @@ class $Root extends $stdlib.std.Resource { }); } } - if ($preflightTypesMap[0]) { throw new Error("ResourceBackend is already in type map"); } - $preflightTypesMap[0] = ResourceBackend; + if ($preflightTypesMap[1]) { throw new Error("ResourceBackend is already in type map"); } + $preflightTypesMap[1] = ResourceBackend; } } const $PlatformManager = new $stdlib.platform.PlatformManager({platformPaths: $platforms}); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/super_call.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/super_call.test.w_compile_tf-aws.md index d8ac0c5a67f..b6f5fc7b7ef 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/super_call.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/super_call.test.w_compile_tf-aws.md @@ -416,8 +416,8 @@ class $Root extends $stdlib.std.Resource { }); } } - if ($preflightTypesMap[5]) { throw new Error("InflightA is already in type map"); } - $preflightTypesMap[5] = InflightA; + if ($preflightTypesMap[6]) { throw new Error("InflightA is already in type map"); } + $preflightTypesMap[6] = InflightA; class InflightB extends InflightA { constructor($scope, $id, ) { super($scope, $id); @@ -449,8 +449,8 @@ class $Root extends $stdlib.std.Resource { }); } } - if ($preflightTypesMap[6]) { throw new Error("InflightB is already in type map"); } - $preflightTypesMap[6] = InflightB; + if ($preflightTypesMap[7]) { throw new Error("InflightB is already in type map"); } + $preflightTypesMap[7] = InflightB; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -479,12 +479,12 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ - [$helpers.nodeof(this).root.$preflightTypesMap[6]._singleton(this,"InflightB_singleton_6"), ["description"]], + [$helpers.preflightClassSingleton(this, 7), ["description"]], [$stdlib.core.toLiftableModuleType(expect.Util, "@winglang/sdk/expect", "Util"), ["equal"]], [InflightB, []], ], "$inflight_init": [ - [$helpers.nodeof(this).root.$preflightTypesMap[6]._singleton(this,"InflightB_singleton_6"), []], + [$helpers.preflightClassSingleton(this, 7), []], [$stdlib.core.toLiftableModuleType(expect.Util, "@winglang/sdk/expect", "Util"), []], [InflightB, []], ], From b185760f73159e5390d509e4d356232bcbb8e67e Mon Sep 17 00:00:00 2001 From: Yoav Steinberg Date: Wed, 26 Jun 2024 16:04:25 +0300 Subject: [PATCH 65/78] udpate snaps after merge --- tools/hangar/__snapshots__/invalid.ts.snap | 14 -------------- .../container/container.test.w_test_sim.md | 2 -- .../container/entrypoint.test.w_test_sim.md | 1 - .../sdk_tests/container/mount.test.w_test_sim.md | 1 - .../valid/this.test.w_compile_tf-aws.md | 5 ++++- 5 files changed, 4 insertions(+), 19 deletions(-) diff --git a/tools/hangar/__snapshots__/invalid.ts.snap b/tools/hangar/__snapshots__/invalid.ts.snap index d9674665bb4..8a33a50b6fa 100644 --- a/tools/hangar/__snapshots__/invalid.ts.snap +++ b/tools/hangar/__snapshots__/invalid.ts.snap @@ -2597,13 +2597,6 @@ error: Cannot create preflight class "PreflightClass" in inflight phase | ^^^^^^^^^^^^^^^^^^^^ -error: Cannot qualify access to a lifted type "PreflightClass" (see https://github.com/winglang/wing/issues/76 for more details) - --> ../../../examples/tests/invalid/inflight_class_created_in_preflight.test.w:19:7 - | -19 | new PreflightClass(); - | ^^^^^^^^^^^^^^ - - Tests 1 failed (1) Snapshots 1 skipped @@ -3983,13 +3976,6 @@ exports[`resource_inflight.test.w 1`] = ` | ^^^^^^^^^^^^^^^^^^ -error: Cannot qualify access to a lifted type "Bucket" (see https://github.com/winglang/wing/issues/76 for more details) - --> ../../../examples/tests/invalid/resource_inflight.test.w:4:7 - | -4 | new cloud.Bucket(); // Should fail because we can't create resources inflight - | ^^^^^^^^^^^^ - - Tests 1 failed (1) Snapshots 1 skipped diff --git a/tools/hangar/__snapshots__/test_corpus/sdk_tests/container/container.test.w_test_sim.md b/tools/hangar/__snapshots__/test_corpus/sdk_tests/container/container.test.w_test_sim.md index 709d96238a6..a80626a598b 100644 --- a/tools/hangar/__snapshots__/test_corpus/sdk_tests/container/container.test.w_test_sim.md +++ b/tools/hangar/__snapshots__/test_corpus/sdk_tests/container/container.test.w_test_sim.md @@ -5,8 +5,6 @@ [INFO] get echo | bang [INFO] get echo | [INFO] get app | Hello, Wingnuts! -[WARNING] get echo | Timeout waiting for container root/env0/my-app to shutdown, removing forcefully -[WARNING] get app | Timeout waiting for container root/env1/my-app to shutdown, removing forcefully pass ─ container.test.wsim » root/env0/test:get echo pass ─ container.test.wsim » root/env1/test:get app diff --git a/tools/hangar/__snapshots__/test_corpus/sdk_tests/container/entrypoint.test.w_test_sim.md b/tools/hangar/__snapshots__/test_corpus/sdk_tests/container/entrypoint.test.w_test_sim.md index ac93580ae7a..92383053ab4 100644 --- a/tools/hangar/__snapshots__/test_corpus/sdk_tests/container/entrypoint.test.w_test_sim.md +++ b/tools/hangar/__snapshots__/test_corpus/sdk_tests/container/entrypoint.test.w_test_sim.md @@ -3,7 +3,6 @@ ## stdout.log ```log [INFO] container with entrypoint | hello -[WARNING] container with entrypoint | Timeout waiting for container root/env0/with-entrypoint to shutdown, removing forcefully pass ─ entrypoint.test.wsim » root/env0/test:container with entrypoint Tests 1 passed (1) diff --git a/tools/hangar/__snapshots__/test_corpus/sdk_tests/container/mount.test.w_test_sim.md b/tools/hangar/__snapshots__/test_corpus/sdk_tests/container/mount.test.w_test_sim.md index 95a38ddb3bf..913bd8c5535 100644 --- a/tools/hangar/__snapshots__/test_corpus/sdk_tests/container/mount.test.w_test_sim.md +++ b/tools/hangar/__snapshots__/test_corpus/sdk_tests/container/mount.test.w_test_sim.md @@ -3,7 +3,6 @@ ## stdout.log ```log [INFO] my test | dummy test -[WARNING] my test | Timeout waiting for container root/env0/Container to shutdown, removing forcefully pass ─ mount.test.wsim » root/env0/test:my test Tests 1 passed (1) diff --git a/tools/hangar/__snapshots__/test_corpus/valid/this.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/this.test.w_compile_tf-aws.md index 2356d69988e..a62860645e0 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/this.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/this.test.w_compile_tf-aws.md @@ -28,10 +28,13 @@ const $wing_is_test = process.env.WING_IS_TEST === "true"; const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -const expect = $stdlib.expect; class $Root extends $stdlib.std.Resource { constructor($scope, $id) { super($scope, $id); + $helpers.nodeof(this).root.$preflightTypesMap = { }; + let $preflightTypesMap = {}; + const expect = $stdlib.expect; + $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; const path = $helpers.nodeof(this).path; for (const c of $helpers.nodeof(this).children) { console.log($helpers.nodeof(c).path); From fbf2d6f1671866a57d7282aa4ce8ad45af9bddd6 Mon Sep 17 00:00:00 2001 From: "monada-bot[bot]" Date: Wed, 26 Jun 2024 13:18:09 +0000 Subject: [PATCH 66/78] chore: self mutation (build.diff) Signed-off-by: monada-bot[bot] --- .../src/dtsify/snapshots/declarations.snap | 13 +++++++++---- ..._static_inflight_from_static_inflight.snap | 4 ++-- ...capture_type_new_inflight_class_outer.snap | 4 ++-- ...ure_type_static_method_inflight_class.snap | 4 ++-- ...ht_class_extends_outer_inflight_class.snap | 4 ++-- ...inflight_class_extends_inflight_class.snap | 8 ++++---- .../inflight_field_from_inflight_class.snap | 4 ++-- .../jsify/snapshots/new_inflight_object.snap | 4 ++-- ...ht_type_refrencing_preflight_instance.snap | 8 ++++---- .../snapshots/reference_inflight_class.snap | 4 ++-- .../reference_inflight_from_inflight.snap | 4 ++-- .../static_external_inflight_class.snap | 4 ++-- ...ansitive_reference_via_inflight_class.snap | 8 ++++---- libs/wingsdk/src/helpers.ts | 19 +++++++++++++------ 14 files changed, 52 insertions(+), 40 deletions(-) diff --git a/libs/wingc/src/dtsify/snapshots/declarations.snap b/libs/wingc/src/dtsify/snapshots/declarations.snap index 98f93db09e3..fc4801e6623 100644 --- a/libs/wingc/src/dtsify/snapshots/declarations.snap +++ b/libs/wingc/src/dtsify/snapshots/declarations.snap @@ -105,9 +105,9 @@ const $stdlib = require('@winglang/sdk'); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -module.exports = { - ...require("./preflight.lib-1.cjs"), -}; +let $preflightTypesMap = {}; +Object.assign(module.exports, $helpers.bringJs(`${__dirname}/preflight.lib-1.cjs`, "$preflightTypesMap", $preflightTypesMap)); +module.exports = { ...module.exports, $preflightTypesMap }; //# sourceMappingURL=preflight.cjs.map ``` @@ -125,6 +125,7 @@ const $stdlib = require('@winglang/sdk'); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); +let $preflightTypesMap = {}; class InflightClass extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); @@ -155,6 +156,8 @@ class InflightClass extends $stdlib.std.Resource { }); } } +if ($preflightTypesMap[1]) { throw new Error("InflightClass is already in type map"); } +$preflightTypesMap[1] = InflightClass; class ParentClass extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); @@ -186,12 +189,14 @@ class ParentClass extends $stdlib.std.Resource { "bar": [ ], "$inflight_init": [ + [InflightClass, []], ], }); } static get _liftTypeMap() { return ({ "static_method": [ + [InflightClass, []], ], }); } @@ -225,7 +230,7 @@ class Child extends ParentClass { }); } } -module.exports = { InflightClass, ParentClass, Child }; +module.exports = { $preflightTypesMap, InflightClass, ParentClass, Child }; //# sourceMappingURL=preflight.lib-1.cjs.map ``` diff --git a/libs/wingc/src/jsify/snapshots/call_static_inflight_from_static_inflight.snap b/libs/wingc/src/jsify/snapshots/call_static_inflight_from_static_inflight.snap index 494f0904577..74ed9c87f61 100644 --- a/libs/wingc/src/jsify/snapshots/call_static_inflight_from_static_inflight.snap +++ b/libs/wingc/src/jsify/snapshots/call_static_inflight_from_static_inflight.snap @@ -139,8 +139,8 @@ class $Root extends $stdlib.std.Resource { }); } } - if ($preflightTypesMap[1]) { throw new Error("B is already in type map"); } - $preflightTypesMap[1] = B; + if ($preflightTypesMap[2]) { throw new Error("B is already in type map"); } + $preflightTypesMap[2] = B; } } const $PlatformManager = new $stdlib.platform.PlatformManager({platformPaths: $platforms}); diff --git a/libs/wingc/src/jsify/snapshots/capture_type_new_inflight_class_outer.snap b/libs/wingc/src/jsify/snapshots/capture_type_new_inflight_class_outer.snap index cedede44ee9..291806a0b6a 100644 --- a/libs/wingc/src/jsify/snapshots/capture_type_new_inflight_class_outer.snap +++ b/libs/wingc/src/jsify/snapshots/capture_type_new_inflight_class_outer.snap @@ -92,8 +92,8 @@ class $Root extends $stdlib.std.Resource { }); } } - if ($preflightTypesMap[0]) { throw new Error("Foo is already in type map"); } - $preflightTypesMap[0] = Foo; + if ($preflightTypesMap[1]) { throw new Error("Foo is already in type map"); } + $preflightTypesMap[1] = Foo; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/capture_type_static_method_inflight_class.snap b/libs/wingc/src/jsify/snapshots/capture_type_static_method_inflight_class.snap index 77116c494e1..3a90eddef62 100644 --- a/libs/wingc/src/jsify/snapshots/capture_type_static_method_inflight_class.snap +++ b/libs/wingc/src/jsify/snapshots/capture_type_static_method_inflight_class.snap @@ -103,8 +103,8 @@ class $Root extends $stdlib.std.Resource { }); } } - if ($preflightTypesMap[0]) { throw new Error("Foo is already in type map"); } - $preflightTypesMap[0] = Foo; + if ($preflightTypesMap[1]) { throw new Error("Foo is already in type map"); } + $preflightTypesMap[1] = Foo; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/closed_inflight_class_extends_outer_inflight_class.snap b/libs/wingc/src/jsify/snapshots/closed_inflight_class_extends_outer_inflight_class.snap index 618175ae30a..163c019e172 100644 --- a/libs/wingc/src/jsify/snapshots/closed_inflight_class_extends_outer_inflight_class.snap +++ b/libs/wingc/src/jsify/snapshots/closed_inflight_class_extends_outer_inflight_class.snap @@ -95,8 +95,8 @@ class $Root extends $stdlib.std.Resource { }); } } - if ($preflightTypesMap[0]) { throw new Error("Base is already in type map"); } - $preflightTypesMap[0] = Base; + if ($preflightTypesMap[1]) { throw new Error("Base is already in type map"); } + $preflightTypesMap[1] = Base; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/inflight_class_extends_inflight_class.snap b/libs/wingc/src/jsify/snapshots/inflight_class_extends_inflight_class.snap index 17bda2ad86d..8a86b9e9704 100644 --- a/libs/wingc/src/jsify/snapshots/inflight_class_extends_inflight_class.snap +++ b/libs/wingc/src/jsify/snapshots/inflight_class_extends_inflight_class.snap @@ -81,8 +81,8 @@ class $Root extends $stdlib.std.Resource { }); } } - if ($preflightTypesMap[0]) { throw new Error("A is already in type map"); } - $preflightTypesMap[0] = A; + if ($preflightTypesMap[1]) { throw new Error("A is already in type map"); } + $preflightTypesMap[1] = A; class B extends A { constructor($scope, $id, ) { super($scope, $id); @@ -112,8 +112,8 @@ class $Root extends $stdlib.std.Resource { }); } } - if ($preflightTypesMap[1]) { throw new Error("B is already in type map"); } - $preflightTypesMap[1] = B; + if ($preflightTypesMap[2]) { throw new Error("B is already in type map"); } + $preflightTypesMap[2] = B; } } const $PlatformManager = new $stdlib.platform.PlatformManager({platformPaths: $platforms}); diff --git a/libs/wingc/src/jsify/snapshots/inflight_field_from_inflight_class.snap b/libs/wingc/src/jsify/snapshots/inflight_field_from_inflight_class.snap index 2577a58c636..fd0b68dc5e0 100644 --- a/libs/wingc/src/jsify/snapshots/inflight_field_from_inflight_class.snap +++ b/libs/wingc/src/jsify/snapshots/inflight_field_from_inflight_class.snap @@ -88,8 +88,8 @@ class $Root extends $stdlib.std.Resource { }); } } - if ($preflightTypesMap[0]) { throw new Error("MyType is already in type map"); } - $preflightTypesMap[0] = MyType; + if ($preflightTypesMap[1]) { throw new Error("MyType is already in type map"); } + $preflightTypesMap[1] = MyType; } } const $PlatformManager = new $stdlib.platform.PlatformManager({platformPaths: $platforms}); diff --git a/libs/wingc/src/jsify/snapshots/new_inflight_object.snap b/libs/wingc/src/jsify/snapshots/new_inflight_object.snap index 6ddf3a6df92..9b3694cc392 100644 --- a/libs/wingc/src/jsify/snapshots/new_inflight_object.snap +++ b/libs/wingc/src/jsify/snapshots/new_inflight_object.snap @@ -92,8 +92,8 @@ class $Root extends $stdlib.std.Resource { }); } } - if ($preflightTypesMap[0]) { throw new Error("Foo is already in type map"); } - $preflightTypesMap[0] = Foo; + if ($preflightTypesMap[1]) { throw new Error("Foo is already in type map"); } + $preflightTypesMap[1] = Foo; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/qualify_inflight_type_refrencing_preflight_instance.snap b/libs/wingc/src/jsify/snapshots/qualify_inflight_type_refrencing_preflight_instance.snap index f256aa79174..f35589d1325 100644 --- a/libs/wingc/src/jsify/snapshots/qualify_inflight_type_refrencing_preflight_instance.snap +++ b/libs/wingc/src/jsify/snapshots/qualify_inflight_type_refrencing_preflight_instance.snap @@ -158,8 +158,8 @@ class $Root extends $stdlib.std.Resource { }); } } - if ($preflightTypesMap[1]) { throw new Error("InflightC is already in type map"); } - $preflightTypesMap[1] = InflightC; + if ($preflightTypesMap[2]) { throw new Error("InflightC is already in type map"); } + $preflightTypesMap[2] = InflightC; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -187,11 +187,11 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ - [$helpers.nodeof(this).root.$preflightTypesMap[1]._singleton(this,"InflightC_singleton_1"), ["foo"]], + [$helpers.preflightClassSingleton(this, 2), ["foo"]], [InflightC, []], ], "$inflight_init": [ - [$helpers.nodeof(this).root.$preflightTypesMap[1]._singleton(this,"InflightC_singleton_1"), []], + [$helpers.preflightClassSingleton(this, 2), []], [InflightC, []], ], }); diff --git a/libs/wingc/src/jsify/snapshots/reference_inflight_class.snap b/libs/wingc/src/jsify/snapshots/reference_inflight_class.snap index 8c353b407c4..c4c96cd62bd 100644 --- a/libs/wingc/src/jsify/snapshots/reference_inflight_class.snap +++ b/libs/wingc/src/jsify/snapshots/reference_inflight_class.snap @@ -103,8 +103,8 @@ class $Root extends $stdlib.std.Resource { }); } } - if ($preflightTypesMap[0]) { throw new Error("Foo is already in type map"); } - $preflightTypesMap[0] = Foo; + if ($preflightTypesMap[1]) { throw new Error("Foo is already in type map"); } + $preflightTypesMap[1] = Foo; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/reference_inflight_from_inflight.snap b/libs/wingc/src/jsify/snapshots/reference_inflight_from_inflight.snap index 8373760614a..0597623b6b5 100644 --- a/libs/wingc/src/jsify/snapshots/reference_inflight_from_inflight.snap +++ b/libs/wingc/src/jsify/snapshots/reference_inflight_from_inflight.snap @@ -114,8 +114,8 @@ class $Root extends $stdlib.std.Resource { }); } } - if ($preflightTypesMap[0]) { throw new Error("Foo is already in type map"); } - $preflightTypesMap[0] = Foo; + if ($preflightTypesMap[1]) { throw new Error("Foo is already in type map"); } + $preflightTypesMap[1] = Foo; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/static_external_inflight_class.snap b/libs/wingc/src/jsify/snapshots/static_external_inflight_class.snap index 6afd1a2e505..322b97d5ff9 100644 --- a/libs/wingc/src/jsify/snapshots/static_external_inflight_class.snap +++ b/libs/wingc/src/jsify/snapshots/static_external_inflight_class.snap @@ -114,8 +114,8 @@ class $Root extends $stdlib.std.Resource { }); } } - if ($preflightTypesMap[0]) { throw new Error("A is already in type map"); } - $preflightTypesMap[0] = A; + if ($preflightTypesMap[1]) { throw new Error("A is already in type map"); } + $preflightTypesMap[1] = A; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { diff --git a/libs/wingc/src/jsify/snapshots/transitive_reference_via_inflight_class.snap b/libs/wingc/src/jsify/snapshots/transitive_reference_via_inflight_class.snap index afc06015d74..c3e61474e94 100644 --- a/libs/wingc/src/jsify/snapshots/transitive_reference_via_inflight_class.snap +++ b/libs/wingc/src/jsify/snapshots/transitive_reference_via_inflight_class.snap @@ -111,8 +111,8 @@ class $Root extends $stdlib.std.Resource { }); } } - if ($preflightTypesMap[0]) { throw new Error("MyInflightClass is already in type map"); } - $preflightTypesMap[0] = MyInflightClass; + if ($preflightTypesMap[1]) { throw new Error("MyInflightClass is already in type map"); } + $preflightTypesMap[1] = MyInflightClass; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); constructor($scope, $id, ) { @@ -140,11 +140,11 @@ class $Root extends $stdlib.std.Resource { get _liftMap() { return ({ "handle": [ - [$helpers.nodeof(this).root.$preflightTypesMap[0]._singleton(this,"MyInflightClass_singleton_0"), ["putInBucket"]], + [$helpers.preflightClassSingleton(this, 1), ["putInBucket"]], [MyInflightClass, []], ], "$inflight_init": [ - [$helpers.nodeof(this).root.$preflightTypesMap[0]._singleton(this,"MyInflightClass_singleton_0"), []], + [$helpers.preflightClassSingleton(this, 1), []], [MyInflightClass, []], ], }); diff --git a/libs/wingsdk/src/helpers.ts b/libs/wingsdk/src/helpers.ts index 66c4fe2c896..8dcb3180067 100644 --- a/libs/wingsdk/src/helpers.ts +++ b/libs/wingsdk/src/helpers.ts @@ -3,12 +3,12 @@ import { notDeepStrictEqual } from "node:assert"; import * as path from "node:path"; import type { Construct } from "constructs"; +import { std } from "."; import type { Node } from "./std/node"; // since we moved from node:18 to node:20 the deepStrictEqual doesn't work as expected. // https://github.com/winglang/wing/issues/4444 // therefore we're using a local version of the comparison from node 18. import { deepStrictEqual } from "./util/equality"; -import { std } from "."; export function eq(a: any, b: any): boolean { try { @@ -189,7 +189,8 @@ export function bringJs( if (k === preflightTypesObjectName) { // Verify no key collision (should never happen) Object.keys(v as object).forEach((key) => { - if (key in outPreflightTypesObject) throw new Error(`Key collision (${key}) in preflight types map`); + if (key in outPreflightTypesObject) + throw new Error(`Key collision (${key}) in preflight types map`); }); Object.assign(outPreflightTypesObject, v); return false; @@ -200,14 +201,17 @@ export function bringJs( } /** - * Helper function to get a singleton instance of a class defined in preflight. + * Helper function to get a singleton instance of a class defined in preflight. * In practice this is used to get the preflight instance of **inflight** classes defined **preflight**. * This instance is used for accessing the lift map of such classes. * @param scope - a scope in the construct tree that'll hold the instance (a singleton within that tree). * @param typeId - the unique id of the preflight class type we want. * @returns the instance of the class. */ -export function preflightClassSingleton(scope: Construct, typeId: number): std.Resource { +export function preflightClassSingleton( + scope: Construct, + typeId: number +): std.Resource { const root: any = nodeof(scope).root; const type: any = root.$preflightTypesMap[typeId]; if (root.resourceSingletons === undefined) { @@ -217,6 +221,9 @@ export function preflightClassSingleton(scope: Construct, typeId: number): std.R if (instance) { return instance; } - root.resourceSingletons[type] = new type(scope, `${type.name}_singleton_${typeId}`); + root.resourceSingletons[type] = new type( + scope, + `${type.name}_singleton_${typeId}` + ); return root.resourceSingletons[type]; -} \ No newline at end of file +} From 9f014224e3a07709b7a591224c824145bf7986b8 Mon Sep 17 00:00:00 2001 From: "monada-bot[bot]" Date: Wed, 26 Jun 2024 13:18:09 +0000 Subject: [PATCH 67/78] chore: self mutation (e2e-1of2.diff) Signed-off-by: monada-bot[bot] --- .../sdk_tests/container/container.test.w_test_sim.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tools/hangar/__snapshots__/test_corpus/sdk_tests/container/container.test.w_test_sim.md b/tools/hangar/__snapshots__/test_corpus/sdk_tests/container/container.test.w_test_sim.md index a80626a598b..709d96238a6 100644 --- a/tools/hangar/__snapshots__/test_corpus/sdk_tests/container/container.test.w_test_sim.md +++ b/tools/hangar/__snapshots__/test_corpus/sdk_tests/container/container.test.w_test_sim.md @@ -5,6 +5,8 @@ [INFO] get echo | bang [INFO] get echo | [INFO] get app | Hello, Wingnuts! +[WARNING] get echo | Timeout waiting for container root/env0/my-app to shutdown, removing forcefully +[WARNING] get app | Timeout waiting for container root/env1/my-app to shutdown, removing forcefully pass ─ container.test.wsim » root/env0/test:get echo pass ─ container.test.wsim » root/env1/test:get app From b2280bc6d4daf0acdcb3f36361d196a6239f4436 Mon Sep 17 00:00:00 2001 From: "monada-bot[bot]" Date: Wed, 26 Jun 2024 13:18:09 +0000 Subject: [PATCH 68/78] chore: self mutation (e2e-2of2.diff) Signed-off-by: monada-bot[bot] --- .../sdk_tests/container/entrypoint.test.w_test_sim.md | 1 + .../test_corpus/sdk_tests/container/mount.test.w_test_sim.md | 1 + 2 files changed, 2 insertions(+) diff --git a/tools/hangar/__snapshots__/test_corpus/sdk_tests/container/entrypoint.test.w_test_sim.md b/tools/hangar/__snapshots__/test_corpus/sdk_tests/container/entrypoint.test.w_test_sim.md index 92383053ab4..ac93580ae7a 100644 --- a/tools/hangar/__snapshots__/test_corpus/sdk_tests/container/entrypoint.test.w_test_sim.md +++ b/tools/hangar/__snapshots__/test_corpus/sdk_tests/container/entrypoint.test.w_test_sim.md @@ -3,6 +3,7 @@ ## stdout.log ```log [INFO] container with entrypoint | hello +[WARNING] container with entrypoint | Timeout waiting for container root/env0/with-entrypoint to shutdown, removing forcefully pass ─ entrypoint.test.wsim » root/env0/test:container with entrypoint Tests 1 passed (1) diff --git a/tools/hangar/__snapshots__/test_corpus/sdk_tests/container/mount.test.w_test_sim.md b/tools/hangar/__snapshots__/test_corpus/sdk_tests/container/mount.test.w_test_sim.md index 913bd8c5535..95a38ddb3bf 100644 --- a/tools/hangar/__snapshots__/test_corpus/sdk_tests/container/mount.test.w_test_sim.md +++ b/tools/hangar/__snapshots__/test_corpus/sdk_tests/container/mount.test.w_test_sim.md @@ -3,6 +3,7 @@ ## stdout.log ```log [INFO] my test | dummy test +[WARNING] my test | Timeout waiting for container root/env0/Container to shutdown, removing forcefully pass ─ mount.test.wsim » root/env0/test:my test Tests 1 passed (1) From 8a76882bca7eb9304d0b7fe1b7d693cf0d5062ed Mon Sep 17 00:00:00 2001 From: yoav-steinberg Date: Thu, 27 Jun 2024 13:50:38 +0300 Subject: [PATCH 69/78] Update libs/wingsdk/src/helpers.ts Co-authored-by: Chris Rybicki --- libs/wingsdk/src/helpers.ts | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libs/wingsdk/src/helpers.ts b/libs/wingsdk/src/helpers.ts index 8dcb3180067..f694217b99b 100644 --- a/libs/wingsdk/src/helpers.ts +++ b/libs/wingsdk/src/helpers.ts @@ -189,8 +189,9 @@ export function bringJs( if (k === preflightTypesObjectName) { // Verify no key collision (should never happen) Object.keys(v as object).forEach((key) => { - if (key in outPreflightTypesObject) + if (key in outPreflightTypesObject) { throw new Error(`Key collision (${key}) in preflight types map`); + } }); Object.assign(outPreflightTypesObject, v); return false; From ed660d02d6ee8d8dde69e26e0f333299dbda3b0a Mon Sep 17 00:00:00 2001 From: Yoav Steinberg Date: Thu, 27 Jun 2024 13:51:52 +0300 Subject: [PATCH 70/78] cr cleanup --- wt | 3 --- 1 file changed, 3 deletions(-) delete mode 100755 wt diff --git a/wt b/wt deleted file mode 100755 index 2d5569b631a..00000000000 --- a/wt +++ /dev/null @@ -1,3 +0,0 @@ -#!/bin/sh - -./apps/wing/bin/wing test $@ \ No newline at end of file From 828ef2019073d7d864de4814558e21e38829330b Mon Sep 17 00:00:00 2001 From: Yoav Steinberg Date: Thu, 27 Jun 2024 13:59:26 +0300 Subject: [PATCH 71/78] cr --- libs/wingsdk/src/helpers.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libs/wingsdk/src/helpers.ts b/libs/wingsdk/src/helpers.ts index f694217b99b..125ace55716 100644 --- a/libs/wingsdk/src/helpers.ts +++ b/libs/wingsdk/src/helpers.ts @@ -3,7 +3,7 @@ import { notDeepStrictEqual } from "node:assert"; import * as path from "node:path"; import type { Construct } from "constructs"; -import { std } from "."; +import type { Resource } from "./std"; import type { Node } from "./std/node"; // since we moved from node:18 to node:20 the deepStrictEqual doesn't work as expected. // https://github.com/winglang/wing/issues/4444 @@ -212,7 +212,7 @@ export function bringJs( export function preflightClassSingleton( scope: Construct, typeId: number -): std.Resource { +): Resource { const root: any = nodeof(scope).root; const type: any = root.$preflightTypesMap[typeId]; if (root.resourceSingletons === undefined) { From 8125f7826e07937d54dfc5bf91c23c7cea1eb6e7 Mon Sep 17 00:00:00 2001 From: "monada-bot[bot]" Date: Thu, 27 Jun 2024 11:12:14 +0000 Subject: [PATCH 72/78] chore: self mutation (e2e-2of2.diff) Signed-off-by: monada-bot[bot] --- .../valid/statements_before_super.w_compile_tf-aws.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/tools/hangar/__snapshots__/test_corpus/valid/statements_before_super.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/statements_before_super.w_compile_tf-aws.md index 7fdd23242c0..87c6fd80fb3 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/statements_before_super.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/statements_before_super.w_compile_tf-aws.md @@ -36,6 +36,7 @@ const $stdlib = require('@winglang/sdk'); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); +let $preflightTypesMap = {}; class A extends $stdlib.std.Resource { constructor($scope, $id, a) { super($scope, $id); @@ -95,7 +96,7 @@ class B extends A { }); } } -module.exports = { }; +module.exports = { $preflightTypesMap, }; //# sourceMappingURL=preflight.cjs.map ``` From 53682c43f8847198e462c162a70555f61046c980 Mon Sep 17 00:00:00 2001 From: Yoav Steinberg Date: Thu, 27 Jun 2024 14:21:52 +0300 Subject: [PATCH 73/78] cr cleanup --- libs/wingc/src/jsify.rs | 12 +++++++----- libs/wingsdk/src/helpers.ts | 4 +--- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/libs/wingc/src/jsify.rs b/libs/wingc/src/jsify.rs index bd26f896150..30968c149fd 100644 --- a/libs/wingc/src/jsify.rs +++ b/libs/wingc/src/jsify.rs @@ -232,8 +232,8 @@ impl<'a> JSifier<'a> { // we generate code like this: // ``` // let $preflightTypesMap = {}; - // Object.assign(module.exports, $helpers.bringJs("./preflight.inner-file1.js", "$preflightTypesMap", $preflightTypesMap)); - // Object.assign(module.exports, { get inner_directory1() { $helpers.bringJs("./preflight.inner-directory1.js", "$preflightTypesMap", $preflightTypesMap); } }); + // Object.assign(module.exports, $helpers.bringJs("./preflight.inner-file1.js", $preflightTypesMap)); + // Object.assign(module.exports, { get inner_directory1() { $helpers.bringJs("./preflight.inner-directory1.js", $preflightTypesMap); } }); // module.exports = { ...module.exports, $preflightTypesMap }; // ``` @@ -245,11 +245,11 @@ impl<'a> JSifier<'a> { if file.is_dir() { let directory_name = file.file_stem().unwrap(); output.line(format!( - "Object.assign(module.exports, {{ get {directory_name}() {{ return $helpers.bringJs(`${{__dirname}}/{preflight_file_name}`, \"{MODULE_PREFLIGHT_TYPES_MAP}\", {MODULE_PREFLIGHT_TYPES_MAP}); }} }});" + "Object.assign(module.exports, {{ get {directory_name}() {{ return $helpers.bringJs(`${{__dirname}}/{preflight_file_name}`, {MODULE_PREFLIGHT_TYPES_MAP}); }} }});" )); } else { output.line(format!( - "Object.assign(module.exports, $helpers.bringJs(`${{__dirname}}/{preflight_file_name}`, \"{MODULE_PREFLIGHT_TYPES_MAP}\", {MODULE_PREFLIGHT_TYPES_MAP}));" + "Object.assign(module.exports, $helpers.bringJs(`${{__dirname}}/{preflight_file_name}`, {MODULE_PREFLIGHT_TYPES_MAP}));" )); } } @@ -1502,7 +1502,9 @@ impl<'a> JSifier<'a> { let var_name = identifier.as_ref().expect("bring wing module requires an alias"); let preflight_file_map = self.preflight_file_map.borrow(); let preflight_file_name = preflight_file_map.get(path).unwrap(); - code.line(format!("const {var_name} = $helpers.bringJs(`${{__dirname}}/{preflight_file_name}`,\"{MODULE_PREFLIGHT_TYPES_MAP}\", {MODULE_PREFLIGHT_TYPES_MAP});")); + code.line(format!( + "const {var_name} = $helpers.bringJs(`${{__dirname}}/{preflight_file_name}`, {MODULE_PREFLIGHT_TYPES_MAP});" + )); code } diff --git a/libs/wingsdk/src/helpers.ts b/libs/wingsdk/src/helpers.ts index 125ace55716..26f4697b1a8 100644 --- a/libs/wingsdk/src/helpers.ts +++ b/libs/wingsdk/src/helpers.ts @@ -173,20 +173,18 @@ export function resolveDirname( * We need this instead of simply calling `require` because in addition to returning the imported module's exports, * we also need to update the current module's preflight types map with the brought module's preflight types map. * @param moduleFile - the file to `require` - * @param preflightTypesObjectName - this should always be $preflightTypesMap (based on the wingc jsify rust code) * @param outPreflightTypesObject - the current module's $preflightTypesMap * @returns all symbols exported by the `moduleFile` except `$preflightTypesMap` */ export function bringJs( moduleFile: string, - preflightTypesObjectName: string, outPreflightTypesObject: Object ): Object { /* eslint-disable @typescript-eslint/no-require-imports */ return Object.fromEntries( Object.entries(require(moduleFile)).filter(([k, v]) => { // If this is the preflight types array then update the input object and skip it - if (k === preflightTypesObjectName) { + if (k === "$preflightTypesMap") { // Verify no key collision (should never happen) Object.keys(v as object).forEach((key) => { if (key in outPreflightTypesObject) { From 4757afbb102d7de40bd5cdd64d42f691513fadc0 Mon Sep 17 00:00:00 2001 From: Yoav Steinberg Date: Thu, 27 Jun 2024 14:25:22 +0300 Subject: [PATCH 74/78] cr --- libs/wingc/src/jsify.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/wingc/src/jsify.rs b/libs/wingc/src/jsify.rs index fd416879066..93d8d35c89a 100644 --- a/libs/wingc/src/jsify.rs +++ b/libs/wingc/src/jsify.rs @@ -238,7 +238,7 @@ impl<'a> JSifier<'a> { // ``` // This module's preflight type map - output.line(format!("let {MODULE_PREFLIGHT_TYPES_MAP} = {{}};")); + output.line(format!("const {MODULE_PREFLIGHT_TYPES_MAP} = {{}};")); for file in directory_children { let preflight_file_name = preflight_file_map.get(file).expect("no emitted JS file found"); From 3b92d6449c08e70b5a52cc1bebe9251cf6de09f5 Mon Sep 17 00:00:00 2001 From: "monada-bot[bot]" Date: Thu, 27 Jun 2024 11:39:21 +0000 Subject: [PATCH 75/78] chore: self mutation (build.diff) Signed-off-by: monada-bot[bot] --- libs/wingc/src/dtsify/snapshots/declarations.snap | 4 ++-- libs/wingc/src/dtsify/snapshots/optionals.snap | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/libs/wingc/src/dtsify/snapshots/declarations.snap b/libs/wingc/src/dtsify/snapshots/declarations.snap index fc4801e6623..59471505957 100644 --- a/libs/wingc/src/dtsify/snapshots/declarations.snap +++ b/libs/wingc/src/dtsify/snapshots/declarations.snap @@ -105,8 +105,8 @@ const $stdlib = require('@winglang/sdk'); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -let $preflightTypesMap = {}; -Object.assign(module.exports, $helpers.bringJs(`${__dirname}/preflight.lib-1.cjs`, "$preflightTypesMap", $preflightTypesMap)); +const $preflightTypesMap = {}; +Object.assign(module.exports, $helpers.bringJs(`${__dirname}/preflight.lib-1.cjs`, $preflightTypesMap)); module.exports = { ...module.exports, $preflightTypesMap }; //# sourceMappingURL=preflight.cjs.map ``` diff --git a/libs/wingc/src/dtsify/snapshots/optionals.snap b/libs/wingc/src/dtsify/snapshots/optionals.snap index 61888773f92..f2ec550c899 100644 --- a/libs/wingc/src/dtsify/snapshots/optionals.snap +++ b/libs/wingc/src/dtsify/snapshots/optionals.snap @@ -46,8 +46,8 @@ const $stdlib = require('@winglang/sdk'); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -let $preflightTypesMap = {}; -Object.assign(module.exports, $helpers.bringJs(`${__dirname}/preflight.lib-1.cjs`, "$preflightTypesMap", $preflightTypesMap)); +const $preflightTypesMap = {}; +Object.assign(module.exports, $helpers.bringJs(`${__dirname}/preflight.lib-1.cjs`, $preflightTypesMap)); module.exports = { ...module.exports, $preflightTypesMap }; //# sourceMappingURL=preflight.cjs.map ``` From 025dbbe211975f68f1c40ed497fbcea6277365a2 Mon Sep 17 00:00:00 2001 From: "monada-bot[bot]" Date: Thu, 27 Jun 2024 11:39:21 +0000 Subject: [PATCH 76/78] chore: self mutation (e2e-1of2.diff) Signed-off-by: monada-bot[bot] --- ...e_preflight_object.test.w_compile_tf-aws.md | 18 +++++++++--------- .../valid/intrinsics.test.w_compile_tf-aws.md | 2 +- .../valid/store.w_compile_tf-aws.md | 2 +- .../struct_from_json.test.w_compile_tf-aws.md | 4 ++-- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_capture_preflight_object.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_capture_preflight_object.test.w_compile_tf-aws.md index dcd2eea367f..07738803002 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_capture_preflight_object.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/inflight_class_capture_preflight_object.test.w_compile_tf-aws.md @@ -269,7 +269,7 @@ class $Root extends $stdlib.std.Resource { $helpers.nodeof(this).root.$preflightTypesMap = { }; let $preflightTypesMap = {}; const cloud = $stdlib.cloud; - const subdir = $helpers.bringJs(`${__dirname}/preflight.subdir2-6.cjs`,"$preflightTypesMap", $preflightTypesMap); + const subdir = $helpers.bringJs(`${__dirname}/preflight.subdir2-6.cjs`, $preflightTypesMap); $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { @@ -552,7 +552,7 @@ const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); let $preflightTypesMap = {}; -const blah = $helpers.bringJs(`${__dirname}/preflight.inner-2.cjs`,"$preflightTypesMap", $preflightTypesMap); +const blah = $helpers.bringJs(`${__dirname}/preflight.inner-2.cjs`, $preflightTypesMap); const cloud = $stdlib.cloud; const util = $stdlib.util; class Foo extends $stdlib.std.Resource { @@ -717,8 +717,8 @@ const $stdlib = require('@winglang/sdk'); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -let $preflightTypesMap = {}; -Object.assign(module.exports, $helpers.bringJs(`${__dirname}/preflight.widget-1.cjs`, "$preflightTypesMap", $preflightTypesMap)); +const $preflightTypesMap = {}; +Object.assign(module.exports, $helpers.bringJs(`${__dirname}/preflight.widget-1.cjs`, $preflightTypesMap)); module.exports = { ...module.exports, $preflightTypesMap }; //# sourceMappingURL=preflight.inner-2.cjs.map ``` @@ -730,11 +730,11 @@ const $stdlib = require('@winglang/sdk'); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -let $preflightTypesMap = {}; -Object.assign(module.exports, { get inner() { return $helpers.bringJs(`${__dirname}/preflight.inner-2.cjs`, "$preflightTypesMap", $preflightTypesMap); } }); -Object.assign(module.exports, $helpers.bringJs(`${__dirname}/preflight.inflightclass-5.cjs`, "$preflightTypesMap", $preflightTypesMap)); -Object.assign(module.exports, $helpers.bringJs(`${__dirname}/preflight.file2-4.cjs`, "$preflightTypesMap", $preflightTypesMap)); -Object.assign(module.exports, $helpers.bringJs(`${__dirname}/preflight.file1-3.cjs`, "$preflightTypesMap", $preflightTypesMap)); +const $preflightTypesMap = {}; +Object.assign(module.exports, { get inner() { return $helpers.bringJs(`${__dirname}/preflight.inner-2.cjs`, $preflightTypesMap); } }); +Object.assign(module.exports, $helpers.bringJs(`${__dirname}/preflight.inflightclass-5.cjs`, $preflightTypesMap)); +Object.assign(module.exports, $helpers.bringJs(`${__dirname}/preflight.file2-4.cjs`, $preflightTypesMap)); +Object.assign(module.exports, $helpers.bringJs(`${__dirname}/preflight.file1-3.cjs`, $preflightTypesMap)); module.exports = { ...module.exports, $preflightTypesMap }; //# sourceMappingURL=preflight.subdir2-6.cjs.map ``` diff --git a/tools/hangar/__snapshots__/test_corpus/valid/intrinsics.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/intrinsics.test.w_compile_tf-aws.md index 4936c821217..013392f80ab 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/intrinsics.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/intrinsics.test.w_compile_tf-aws.md @@ -284,7 +284,7 @@ class $Root extends $stdlib.std.Resource { const expect = $stdlib.expect; const cloud = $stdlib.cloud; const util = $stdlib.util; - const bar = $helpers.bringJs(`${__dirname}/preflight.bar-1.cjs`,"$preflightTypesMap", $preflightTypesMap); + const bar = $helpers.bringJs(`${__dirname}/preflight.bar-1.cjs`, $preflightTypesMap); $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class Example extends $stdlib.std.Resource { constructor($scope, $id, ) { diff --git a/tools/hangar/__snapshots__/test_corpus/valid/store.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/store.w_compile_tf-aws.md index 06fadd9e683..2fc82a4643e 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/store.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/store.w_compile_tf-aws.md @@ -60,7 +60,7 @@ const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); let $preflightTypesMap = {}; -const file3 = $helpers.bringJs(`${__dirname}/preflight.empty-1.cjs`,"$preflightTypesMap", $preflightTypesMap); +const file3 = $helpers.bringJs(`${__dirname}/preflight.empty-1.cjs`, $preflightTypesMap); const math = $stdlib.math; const cloud = $stdlib.cloud; const Color = diff --git a/tools/hangar/__snapshots__/test_corpus/valid/struct_from_json.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/struct_from_json.test.w_compile_tf-aws.md index 5ec53140dc0..65c76f35127 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/struct_from_json.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/struct_from_json.test.w_compile_tf-aws.md @@ -182,8 +182,8 @@ class $Root extends $stdlib.std.Resource { $helpers.nodeof(this).root.$preflightTypesMap = { }; let $preflightTypesMap = {}; const cloud = $stdlib.cloud; - const externalStructs = $helpers.bringJs(`${__dirname}/preflight.structs-1.cjs`,"$preflightTypesMap", $preflightTypesMap); - const otherExternalStructs = $helpers.bringJs(`${__dirname}/preflight.structs2-2.cjs`,"$preflightTypesMap", $preflightTypesMap); + const externalStructs = $helpers.bringJs(`${__dirname}/preflight.structs-1.cjs`, $preflightTypesMap); + const otherExternalStructs = $helpers.bringJs(`${__dirname}/preflight.structs2-2.cjs`, $preflightTypesMap); const Bar = $stdlib.std.Struct._createJsonSchema({$id:"/Bar",type:"object",properties:{b:{type:"number"},f:{type:"string"},},required:["b","f",]}); const Foo = $stdlib.std.Struct._createJsonSchema({$id:"/Foo",type:"object",properties:{f:{type:"string"},},required:["f",]}); const Foosible = $stdlib.std.Struct._createJsonSchema({$id:"/Foosible",type:"object",properties:{f:{type:"string"},},required:[]}); From 0412992153fe9b553e06b85c3bb5e4bb82035ee9 Mon Sep 17 00:00:00 2001 From: "monada-bot[bot]" Date: Thu, 27 Jun 2024 11:39:21 +0000 Subject: [PATCH 77/78] chore: self mutation (e2e-2of2.diff) Signed-off-by: monada-bot[bot] --- ..._extend_non_entry.test.w_compile_tf-aws.md | 2 +- .../bring_local.test.w_compile_tf-aws.md | 8 ++++---- .../bring_local_dir.test.w_compile_tf-aws.md | 20 +++++++++---------- ...cal_normalization.test.w_compile_tf-aws.md | 10 +++++----- ...ring_wing_library.test.w_compile_tf-aws.md | 20 +++++++++---------- .../new_in_static.test.w_compile_tf-aws.md | 2 +- 6 files changed, 31 insertions(+), 31 deletions(-) diff --git a/tools/hangar/__snapshots__/test_corpus/valid/bring_extend_non_entry.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/bring_extend_non_entry.test.w_compile_tf-aws.md index 79afcd7dc61..169b251befa 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/bring_extend_non_entry.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/bring_extend_non_entry.test.w_compile_tf-aws.md @@ -48,7 +48,7 @@ class $Root extends $stdlib.std.Resource { super($scope, $id); $helpers.nodeof(this).root.$preflightTypesMap = { }; let $preflightTypesMap = {}; - const lib = $helpers.bringJs(`${__dirname}/preflight.extendnonentrypoint-1.cjs`,"$preflightTypesMap", $preflightTypesMap); + const lib = $helpers.bringJs(`${__dirname}/preflight.extendnonentrypoint-1.cjs`, $preflightTypesMap); $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; const f = new lib.Foo(this, "Foo"); } diff --git a/tools/hangar/__snapshots__/test_corpus/valid/bring_local.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/bring_local.test.w_compile_tf-aws.md index 15dd3f3a746..731e6cfad7f 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/bring_local.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/bring_local.test.w_compile_tf-aws.md @@ -302,9 +302,9 @@ class $Root extends $stdlib.std.Resource { super($scope, $id); $helpers.nodeof(this).root.$preflightTypesMap = { }; let $preflightTypesMap = {}; - const file1 = $helpers.bringJs(`${__dirname}/preflight.store-2.cjs`,"$preflightTypesMap", $preflightTypesMap); - const file2 = $helpers.bringJs(`${__dirname}/preflight.subfile-3.cjs`,"$preflightTypesMap", $preflightTypesMap); - const file3 = $helpers.bringJs(`${__dirname}/preflight.empty-1.cjs`,"$preflightTypesMap", $preflightTypesMap); + const file1 = $helpers.bringJs(`${__dirname}/preflight.store-2.cjs`, $preflightTypesMap); + const file2 = $helpers.bringJs(`${__dirname}/preflight.subfile-3.cjs`, $preflightTypesMap); + const file3 = $helpers.bringJs(`${__dirname}/preflight.empty-1.cjs`, $preflightTypesMap); const math = $stdlib.math; const expect = $stdlib.expect; $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; @@ -477,7 +477,7 @@ const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); let $preflightTypesMap = {}; -const file3 = $helpers.bringJs(`${__dirname}/preflight.empty-1.cjs`,"$preflightTypesMap", $preflightTypesMap); +const file3 = $helpers.bringJs(`${__dirname}/preflight.empty-1.cjs`, $preflightTypesMap); const math = $stdlib.math; const cloud = $stdlib.cloud; const Color = diff --git a/tools/hangar/__snapshots__/test_corpus/valid/bring_local_dir.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/bring_local_dir.test.w_compile_tf-aws.md index bb8fadb2bba..2dd33865c8f 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/bring_local_dir.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/bring_local_dir.test.w_compile_tf-aws.md @@ -104,8 +104,8 @@ class $Root extends $stdlib.std.Resource { super($scope, $id); $helpers.nodeof(this).root.$preflightTypesMap = { }; let $preflightTypesMap = {}; - const w = $helpers.bringJs(`${__dirname}/preflight.widget-1.cjs`,"$preflightTypesMap", $preflightTypesMap); - const subdir = $helpers.bringJs(`${__dirname}/preflight.subdir2-6.cjs`,"$preflightTypesMap", $preflightTypesMap); + const w = $helpers.bringJs(`${__dirname}/preflight.widget-1.cjs`, $preflightTypesMap); + const subdir = $helpers.bringJs(`${__dirname}/preflight.subdir2-6.cjs`, $preflightTypesMap); $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; const widget1 = new w.Widget(this, "widget1"); $helpers.assert($helpers.eq((widget1.compute()), 42), "widget1.compute() == 42"); @@ -132,7 +132,7 @@ const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); let $preflightTypesMap = {}; -const blah = $helpers.bringJs(`${__dirname}/preflight.inner-2.cjs`,"$preflightTypesMap", $preflightTypesMap); +const blah = $helpers.bringJs(`${__dirname}/preflight.inner-2.cjs`, $preflightTypesMap); const cloud = $stdlib.cloud; const util = $stdlib.util; class Foo extends $stdlib.std.Resource { @@ -297,8 +297,8 @@ const $stdlib = require('@winglang/sdk'); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -let $preflightTypesMap = {}; -Object.assign(module.exports, $helpers.bringJs(`${__dirname}/preflight.widget-1.cjs`, "$preflightTypesMap", $preflightTypesMap)); +const $preflightTypesMap = {}; +Object.assign(module.exports, $helpers.bringJs(`${__dirname}/preflight.widget-1.cjs`, $preflightTypesMap)); module.exports = { ...module.exports, $preflightTypesMap }; //# sourceMappingURL=preflight.inner-2.cjs.map ``` @@ -310,11 +310,11 @@ const $stdlib = require('@winglang/sdk'); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -let $preflightTypesMap = {}; -Object.assign(module.exports, { get inner() { return $helpers.bringJs(`${__dirname}/preflight.inner-2.cjs`, "$preflightTypesMap", $preflightTypesMap); } }); -Object.assign(module.exports, $helpers.bringJs(`${__dirname}/preflight.inflightclass-5.cjs`, "$preflightTypesMap", $preflightTypesMap)); -Object.assign(module.exports, $helpers.bringJs(`${__dirname}/preflight.file2-4.cjs`, "$preflightTypesMap", $preflightTypesMap)); -Object.assign(module.exports, $helpers.bringJs(`${__dirname}/preflight.file1-3.cjs`, "$preflightTypesMap", $preflightTypesMap)); +const $preflightTypesMap = {}; +Object.assign(module.exports, { get inner() { return $helpers.bringJs(`${__dirname}/preflight.inner-2.cjs`, $preflightTypesMap); } }); +Object.assign(module.exports, $helpers.bringJs(`${__dirname}/preflight.inflightclass-5.cjs`, $preflightTypesMap)); +Object.assign(module.exports, $helpers.bringJs(`${__dirname}/preflight.file2-4.cjs`, $preflightTypesMap)); +Object.assign(module.exports, $helpers.bringJs(`${__dirname}/preflight.file1-3.cjs`, $preflightTypesMap)); module.exports = { ...module.exports, $preflightTypesMap }; //# sourceMappingURL=preflight.subdir2-6.cjs.map ``` diff --git a/tools/hangar/__snapshots__/test_corpus/valid/bring_local_normalization.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/bring_local_normalization.test.w_compile_tf-aws.md index 615e12570cc..7398aa21dd1 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/bring_local_normalization.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/bring_local_normalization.test.w_compile_tf-aws.md @@ -164,9 +164,9 @@ class $Root extends $stdlib.std.Resource { super($scope, $id); $helpers.nodeof(this).root.$preflightTypesMap = { }; let $preflightTypesMap = {}; - const foo = $helpers.bringJs(`${__dirname}/preflight.foo-3.cjs`,"$preflightTypesMap", $preflightTypesMap); - const bar = $helpers.bringJs(`${__dirname}/preflight.bar-1.cjs`,"$preflightTypesMap", $preflightTypesMap); - const baz = $helpers.bringJs(`${__dirname}/preflight.baz-2.cjs`,"$preflightTypesMap", $preflightTypesMap); + const foo = $helpers.bringJs(`${__dirname}/preflight.foo-3.cjs`, $preflightTypesMap); + const bar = $helpers.bringJs(`${__dirname}/preflight.bar-1.cjs`, $preflightTypesMap); + const baz = $helpers.bringJs(`${__dirname}/preflight.baz-2.cjs`, $preflightTypesMap); $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; $helpers.assert($helpers.eq((foo.Foo.foo(this)), "foo"), "foo.Foo.foo() == \"foo\""); $helpers.assert($helpers.eq((foo.Foo.bar(this)), "bar"), "foo.Foo.bar() == \"bar\""); @@ -189,8 +189,8 @@ const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); let $preflightTypesMap = {}; -const bar = $helpers.bringJs(`${__dirname}/preflight.bar-1.cjs`,"$preflightTypesMap", $preflightTypesMap); -const baz = $helpers.bringJs(`${__dirname}/preflight.baz-2.cjs`,"$preflightTypesMap", $preflightTypesMap); +const bar = $helpers.bringJs(`${__dirname}/preflight.bar-1.cjs`, $preflightTypesMap); +const baz = $helpers.bringJs(`${__dirname}/preflight.baz-2.cjs`, $preflightTypesMap); class Foo extends $stdlib.std.Resource { constructor($scope, $id, ) { super($scope, $id); diff --git a/tools/hangar/__snapshots__/test_corpus/valid/bring_wing_library.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/bring_wing_library.test.w_compile_tf-aws.md index 8b7f66673b9..5e58a8ff2aa 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/bring_wing_library.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/bring_wing_library.test.w_compile_tf-aws.md @@ -112,9 +112,9 @@ class $Root extends $stdlib.std.Resource { super($scope, $id); $helpers.nodeof(this).root.$preflightTypesMap = { }; let $preflightTypesMap = {}; - const fixture = $helpers.bringJs(`${__dirname}/preflight.testfixture-5.cjs`,"$preflightTypesMap", $preflightTypesMap); - const testfixture = $helpers.bringJs(`${__dirname}/preflight.testfixture-5.cjs`,"$preflightTypesMap", $preflightTypesMap); - const testfixture2 = $helpers.bringJs(`${__dirname}/preflight.testfixture-5.cjs`,"$preflightTypesMap", $preflightTypesMap); + const fixture = $helpers.bringJs(`${__dirname}/preflight.testfixture-5.cjs`, $preflightTypesMap); + const testfixture = $helpers.bringJs(`${__dirname}/preflight.testfixture-5.cjs`, $preflightTypesMap); + const testfixture2 = $helpers.bringJs(`${__dirname}/preflight.testfixture-5.cjs`, $preflightTypesMap); $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class $Closure1 extends $stdlib.std.AutoIdResource { _id = $stdlib.core.closureId(); @@ -193,7 +193,7 @@ const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); let $preflightTypesMap = {}; const cloud = $stdlib.cloud; -const myutil = $helpers.bringJs(`${__dirname}/preflight.util-2.cjs`,"$preflightTypesMap", $preflightTypesMap); +const myutil = $helpers.bringJs(`${__dirname}/preflight.util-2.cjs`, $preflightTypesMap); class Store extends $stdlib.std.Resource { constructor($scope, $id, options) { super($scope, $id); @@ -258,8 +258,8 @@ const $stdlib = require('@winglang/sdk'); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -let $preflightTypesMap = {}; -Object.assign(module.exports, $helpers.bringJs(`${__dirname}/preflight.util-2.cjs`, "$preflightTypesMap", $preflightTypesMap)); +const $preflightTypesMap = {}; +Object.assign(module.exports, $helpers.bringJs(`${__dirname}/preflight.util-2.cjs`, $preflightTypesMap)); module.exports = { ...module.exports, $preflightTypesMap }; //# sourceMappingURL=preflight.subdir-4.cjs.map ``` @@ -271,10 +271,10 @@ const $stdlib = require('@winglang/sdk'); const std = $stdlib.std; const $helpers = $stdlib.helpers; const $extern = $helpers.createExternRequire(__dirname); -let $preflightTypesMap = {}; -Object.assign(module.exports, { get subdir() { return $helpers.bringJs(`${__dirname}/preflight.subdir-4.cjs`, "$preflightTypesMap", $preflightTypesMap); } }); -Object.assign(module.exports, $helpers.bringJs(`${__dirname}/preflight.store-3.cjs`, "$preflightTypesMap", $preflightTypesMap)); -Object.assign(module.exports, $helpers.bringJs(`${__dirname}/preflight.enums-1.cjs`, "$preflightTypesMap", $preflightTypesMap)); +const $preflightTypesMap = {}; +Object.assign(module.exports, { get subdir() { return $helpers.bringJs(`${__dirname}/preflight.subdir-4.cjs`, $preflightTypesMap); } }); +Object.assign(module.exports, $helpers.bringJs(`${__dirname}/preflight.store-3.cjs`, $preflightTypesMap)); +Object.assign(module.exports, $helpers.bringJs(`${__dirname}/preflight.enums-1.cjs`, $preflightTypesMap)); module.exports = { ...module.exports, $preflightTypesMap }; //# sourceMappingURL=preflight.testfixture-5.cjs.map ``` diff --git a/tools/hangar/__snapshots__/test_corpus/valid/new_in_static.test.w_compile_tf-aws.md b/tools/hangar/__snapshots__/test_corpus/valid/new_in_static.test.w_compile_tf-aws.md index ba685d44811..2ee9924e3f6 100644 --- a/tools/hangar/__snapshots__/test_corpus/valid/new_in_static.test.w_compile_tf-aws.md +++ b/tools/hangar/__snapshots__/test_corpus/valid/new_in_static.test.w_compile_tf-aws.md @@ -182,7 +182,7 @@ class $Root extends $stdlib.std.Resource { const cloud = $stdlib.cloud; const c = require("constructs"); const jsii_fixture = require("jsii-fixture"); - const new_in_static_lib = $helpers.bringJs(`${__dirname}/preflight.newinstaticlib-1.cjs`,"$preflightTypesMap", $preflightTypesMap); + const new_in_static_lib = $helpers.bringJs(`${__dirname}/preflight.newinstaticlib-1.cjs`, $preflightTypesMap); $helpers.nodeof(this).root.$preflightTypesMap = $preflightTypesMap; class MyClass extends $stdlib.std.Resource { constructor($scope, $id, ) { From eee3d97b0518e78f19462b1772c2af343f550375 Mon Sep 17 00:00:00 2001 From: Yoav Steinberg Date: Thu, 27 Jun 2024 14:52:20 +0300 Subject: [PATCH 78/78] typo --- libs/wingc/src/type_check/jsii_importer.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/wingc/src/type_check/jsii_importer.rs b/libs/wingc/src/type_check/jsii_importer.rs index cc9204f3d64..de39f947dff 100644 --- a/libs/wingc/src/type_check/jsii_importer.rs +++ b/libs/wingc/src/type_check/jsii_importer.rs @@ -737,7 +737,7 @@ impl<'a> JsiiImporter<'a> { std_construct_args: false, // Temporary value, will be updated once we parse the initializer args lifts: None, - // uid is used to create unique names class types so we can access the correct type regradless of type name shadowing, + // uid is used to create unique names class types so we can access the correct type regardless of type name shadowing, // this isn't relevant for imported types (that aren't code generated), so we can default to 0 uid: 0, };