From 82a2f259e108a9262ab12fe91c24a9a5e6870487 Mon Sep 17 00:00:00 2001 From: sfja Date: Thu, 2 Jan 2025 06:46:51 +0100 Subject: [PATCH] desugar param --- compiler/desugar/array_literal.ts | 4 ++-- compiler/desugar/special_loop.ts | 15 ++++++++++++--- compiler/desugar/struct_literal.ts | 4 ++-- 3 files changed, 16 insertions(+), 7 deletions(-) diff --git a/compiler/desugar/array_literal.ts b/compiler/desugar/array_literal.ts index 5a75011..70cd488 100644 --- a/compiler/desugar/array_literal.ts +++ b/compiler/desugar/array_literal.ts @@ -49,10 +49,10 @@ export class ArrayLiteralDesugarer implements AstVisitor { stmts: [ Stmt({ type: "let", - param: { + param: this.astCreator.param({ ident: "::value", pos: npos, - }, + }), value: Expr({ type: "call", subject: Expr({ diff --git a/compiler/desugar/special_loop.ts b/compiler/desugar/special_loop.ts index 7c6b579..f32a776 100644 --- a/compiler/desugar/special_loop.ts +++ b/compiler/desugar/special_loop.ts @@ -70,12 +70,18 @@ export class SpecialLoopDesugarer implements AstVisitor { stmts: [ Stmt({ type: "let", - param: { ident: "::values", pos: npos }, + param: this.astCreator.param({ + ident: "::values", + pos: npos, + }), value: expr.kind.value, }), Stmt({ type: "let", - param: { ident: "::length", pos: npos }, + param: this.astCreator.param({ + ident: "::length", + pos: npos, + }), value: Expr({ type: "call", subject: Expr({ @@ -96,7 +102,10 @@ export class SpecialLoopDesugarer implements AstVisitor { }), Stmt({ type: "let", - param: { ident: "::index", pos: npos }, + param: this.astCreator.param({ + ident: "::index", + pos: npos, + }), value: Expr({ type: "int", value: 0 }), }, expr.pos), Stmt({ diff --git a/compiler/desugar/struct_literal.ts b/compiler/desugar/struct_literal.ts index 0931f0d..cec22d5 100644 --- a/compiler/desugar/struct_literal.ts +++ b/compiler/desugar/struct_literal.ts @@ -52,10 +52,10 @@ export class StructLiteralDesugarer implements AstVisitor { stmts: [ Stmt({ type: "let", - param: { + param: this.astCreator.param({ ident: "::value", pos: npos, - }, + }), value: Expr({ type: "call", subject: Expr({