diff --git a/src/wasm-lib/kcl/src/parsing/parser.rs b/src/wasm-lib/kcl/src/parsing/parser.rs index 48702a7027..8043504739 100644 --- a/src/wasm-lib/kcl/src/parsing/parser.rs +++ b/src/wasm-lib/kcl/src/parsing/parser.rs @@ -2519,9 +2519,17 @@ fn typecheck(spec_arg: &crate::docs::StdLibFnArg, arg: &&Expr) -> PResult<()> { Ok(()) } +/// Either a positional or keyword function call. +fn fn_call_pos_or_kw(i: &mut TokenSlice) -> PResult { + alt(( + fn_call.map(Box::new).map(Expr::CallExpression), + fn_call_kw.map(Box::new).map(Expr::CallExpressionKw), + )) + .parse_next(i) +} + fn labelled_fn_call(i: &mut TokenSlice) -> PResult { - let call = fn_call.parse_next(i)?; - let expr = Expr::CallExpression(Box::new(call)); + let expr = fn_call_pos_or_kw.parse_next(i)?; let label = opt(label).parse_next(i)?; match label { @@ -4369,6 +4377,7 @@ mod snapshot_tests { #[test] fn $func_name() { let module_id = crate::ModuleId::default(); + println!("{}", $test_kcl_program); let tokens = crate::parsing::token::lex($test_kcl_program, module_id).unwrap(); print_tokens(tokens.as_slice()); ParseContext::init(); @@ -4589,6 +4598,7 @@ my14 = 4 ^ 2 - 3 ^ 2 * 2 kw_function_decl_with_default_and_type, r#"fn foo(x?: number = 2) { return 1 }"# ); + snapshot_test!(kw_function_to_draw_square, r#"val = 1 |> f(arg = x)"#); } #[allow(unused)] diff --git a/src/wasm-lib/kcl/src/std/args.rs b/src/wasm-lib/kcl/src/std/args.rs index 3cf06630f8..33f14ea105 100644 --- a/src/wasm-lib/kcl/src/std/args.rs +++ b/src/wasm-lib/kcl/src/std/args.rs @@ -419,10 +419,6 @@ impl Args { FromArgs::from_args(self, 0) } - pub(crate) fn get_sketch_and_optional_tag(&self) -> Result<(Sketch, Option), KclError> { - FromArgs::from_args(self, 0) - } - pub(crate) fn get_data_and_optional_tag<'a, T>(&'a self) -> Result<(T, Option), KclError> where T: serde::de::DeserializeOwned + FromKclValue<'a> + Sized, @@ -490,10 +486,6 @@ impl Args { FromArgs::from_args(self, 0) } - pub(crate) fn get_number_sketch_set(&self) -> Result<(f64, SketchSet), KclError> { - FromArgs::from_args(self, 0) - } - pub(crate) async fn get_adjacent_face_to_tag( &self, exec_state: &mut ExecState, diff --git a/src/wasm-lib/kcl/src/std/extrude.rs b/src/wasm-lib/kcl/src/std/extrude.rs index e8a672d125..0aa1fa343e 100644 --- a/src/wasm-lib/kcl/src/std/extrude.rs +++ b/src/wasm-lib/kcl/src/std/extrude.rs @@ -21,9 +21,10 @@ use crate::{ /// Extrudes by a given amount. pub async fn extrude(exec_state: &mut ExecState, args: Args) -> Result { - let (length, sketch_set) = args.get_number_sketch_set()?; + let sketch_set = args.get_unlabeled_kw_arg("sketch_set")?; + let length = args.get_kw_arg("length")?; - let result = inner_extrude(length, sketch_set, exec_state, args).await?; + let result = inner_extrude(sketch_set, length, exec_state, args).await?; Ok(result.into()) } @@ -77,10 +78,16 @@ pub async fn extrude(exec_state: &mut ExecState, args: Args) -> Result Result { diff --git a/src/wasm-lib/kcl/src/std/mod.rs b/src/wasm-lib/kcl/src/std/mod.rs index 4a280031c7..38b7ab9c84 100644 --- a/src/wasm-lib/kcl/src/std/mod.rs +++ b/src/wasm-lib/kcl/src/std/mod.rs @@ -70,7 +70,6 @@ lazy_static! { Box::new(crate::std::segment::AngleToMatchLengthY), Box::new(crate::std::shapes::Circle), Box::new(crate::std::shapes::Polygon), - Box::new(crate::std::sketch::LineTo), Box::new(crate::std::sketch::Line), Box::new(crate::std::sketch::XLineTo), Box::new(crate::std::sketch::XLine), diff --git a/src/wasm-lib/kcl/src/std/sketch.rs b/src/wasm-lib/kcl/src/std/sketch.rs index b794a96c8a..efcc96afcc 100644 --- a/src/wasm-lib/kcl/src/std/sketch.rs +++ b/src/wasm-lib/kcl/src/std/sketch.rs @@ -94,56 +94,115 @@ pub enum StartOrEnd { pub const NEW_TAG_KW: &'static str = "tag"; /// Draw a line to a point. -pub async fn line_to(exec_state: &mut ExecState, args: Args) -> Result { +pub async fn line(exec_state: &mut ExecState, args: Args) -> Result { // let (to, sketch, tag): ([f64; 2], Sketch, Option) = args.get_data_and_sketch_and_tag()?; let sketch = args.get_unlabeled_kw_arg("sketch")?; - let to = args.get_kw_arg("to")?; + let end = args.get_kw_arg_opt("end"); + let to = args.get_kw_arg_opt("to"); let tag = args.get_kw_arg_opt(NEW_TAG_KW); - let new_sketch = inner_line_to(sketch, to, tag, exec_state, args).await?; + let new_sketch = inner_line(sketch, end, to, tag, exec_state, args).await?; Ok(KclValue::Sketch { value: Box::new(new_sketch), }) } -/// Draw a line from the current origin to some absolute (x, y) point. +/// Extend the current sketch with a new straight line. /// /// ```no_run /// exampleSketch = startSketchOn("XZ") /// |> startProfileAt([0, 0], %) -/// |> lineTo(%, to = [10, 0]) -/// |> lineTo(%, to = [0, 10]) -/// |> lineTo(%, to = [-10, 0], tag = "thirdLineOfBox") +/// |> line(end = [10, 0]) +/// |> line(end = [0, 10]) +/// |> line(end = [-10, 0], tag = "thirdLineOfBox") /// |> close(%) /// /// example = extrude(5, exampleSketch) /// ``` #[stdlib { - name = "lineTo", + name = "line", keywords = true, unlabeled_first = true, arg_docs = { sketch = "Which sketch should this path be added to?", - to = "Which absolute point should this line go to?", + end = "Which absolute point should this line go to? Incompatible with `to`.", + to = "How far away (along the X and Y axes) should this line go? Incompatible with `end`.", tag = "Create a new tag which refers to this line", } }] -async fn inner_line_to( +async fn inner_line( sketch: Sketch, - to: [f64; 2], + end: Option<[f64; 2]>, + to: Option<[f64; 2]>, tag: Option, exec_state: &mut ExecState, args: Args, +) -> Result { + straight_line(StraightLineParams { sketch, end, to, tag }, exec_state, args).await +} + +struct StraightLineParams { + sketch: Sketch, + end: Option<[f64; 2]>, + to: Option<[f64; 2]>, + tag: Option, +} + +impl StraightLineParams { + fn relative(p: [f64; 2], sketch: Sketch, tag: Option) -> Self { + Self { + sketch, + tag, + to: Some(p), + end: None, + } + } + fn absolute(p: [f64; 2], sketch: Sketch, tag: Option) -> Self { + Self { + sketch, + tag, + end: Some(p), + to: None, + } + } +} + +async fn straight_line( + StraightLineParams { sketch, end, to, tag }: StraightLineParams, + exec_state: &mut ExecState, + args: Args, ) -> Result { let from = sketch.current_pen_position()?; - let id = exec_state.next_uuid(); + let (point, is_absolute) = match (end, to) { + (Some(_), Some(_)) => { + return Err(KclError::Semantic(KclErrorDetails { + source_ranges: vec![args.source_range], + message: "You cannot give both `end` and `to` params, you have to choose one or the other".to_owned(), + })); + } + (Some(end), None) => (end, true), + (None, Some(to)) => (to, false), + (None, None) => { + return Err(KclError::Semantic(KclErrorDetails { + source_ranges: vec![args.source_range], + message: "You must supply either `end` or `to` arguments".to_owned(), + })); + } + }; + let end = if is_absolute { + point + } else { + let from = sketch.current_pen_position()?; + [from.x + point[0], from.y + point[1]] + }; + let id = exec_state.global.id_generator.next_uuid(); args.batch_modeling_cmd( id, ModelingCmd::from(mcmd::ExtendPath { path: sketch.id.into(), segment: PathSegment::Line { - end: KPoint2d::from(to).with_z(0.0).map(LengthUnit), + end: KPoint2d::from(end).with_z(0.0).map(LengthUnit), relative: false, }, }), @@ -153,7 +212,7 @@ async fn inner_line_to( let current_path = Path::ToPoint { base: BasePath { from: from.into(), - to, + to: end, tag: tag.clone(), geo_meta: GeoMeta { id, @@ -217,7 +276,12 @@ async fn inner_x_line_to( ) -> Result { let from = sketch.current_pen_position()?; - let new_sketch = inner_line_to(sketch, [to, from.y], tag, exec_state, args).await?; + let new_sketch = straight_line( + StraightLineParams::absolute([to, from.y], sketch, tag), + exec_state, + args, + ) + .await?; Ok(new_sketch) } @@ -260,90 +324,12 @@ async fn inner_y_line_to( ) -> Result { let from = sketch.current_pen_position()?; - let new_sketch = inner_line_to(sketch, [from.x, to], tag, exec_state, args).await?; - Ok(new_sketch) -} - -/// Draw a line. -pub async fn line(exec_state: &mut ExecState, args: Args) -> Result { - let (delta, sketch, tag): ([f64; 2], Sketch, Option) = args.get_data_and_sketch_and_tag()?; - - let new_sketch = inner_line(delta, sketch, tag, exec_state, args).await?; - Ok(KclValue::Sketch { - value: Box::new(new_sketch), - }) -} - -/// Draw a line relative to the current origin to a specified (x, y) away -/// from the current position. -/// -/// ```no_run -/// exampleSketch = startSketchOn("XZ") -/// |> startProfileAt([0, 0], %) -/// |> line([25, 15], %) -/// |> line([5, -6], %) -/// |> line([-10, -10], %) -/// |> close(%) -/// -/// example = extrude(5, exampleSketch) -/// ``` -/// -/// ```no_run -/// exampleSketch = startSketchOn("XZ") -/// |> startProfileAt([0, 0], %) -/// |> line([10, 0], %) -/// |> line([0, 10], %) -/// |> line([-10, 0], %) -/// |> close(%) -/// -/// example = extrude(5, exampleSketch) -/// ``` -#[stdlib { - name = "line", -}] -async fn inner_line( - delta: [f64; 2], - sketch: Sketch, - tag: Option, - exec_state: &mut ExecState, - args: Args, -) -> Result { - let from = sketch.current_pen_position()?; - let to = [from.x + delta[0], from.y + delta[1]]; - - let id = exec_state.next_uuid(); - - args.batch_modeling_cmd( - id, - ModelingCmd::from(mcmd::ExtendPath { - path: sketch.id.into(), - segment: PathSegment::Line { - end: KPoint2d::from(delta).with_z(0.0).map(LengthUnit), - relative: true, - }, - }), + let new_sketch = straight_line( + StraightLineParams::absolute([from.x, to], sketch, tag), + exec_state, + args, ) .await?; - - let current_path = Path::ToPoint { - base: BasePath { - from: from.into(), - to, - tag: tag.clone(), - geo_meta: GeoMeta { - id, - metadata: args.source_range.into(), - }, - }, - }; - - let mut new_sketch = sketch.clone(); - if let Some(tag) = &tag { - new_sketch.add_tag(tag, ¤t_path); - } - - new_sketch.paths.push(current_path); - Ok(new_sketch) } @@ -389,7 +375,7 @@ async fn inner_x_line( exec_state: &mut ExecState, args: Args, ) -> Result { - inner_line([length, 0.0], sketch, tag, exec_state, args).await + inner_line(sketch, None, Some([length, 0.0]), tag, exec_state, args).await } /// Draw a line on the y-axis. @@ -429,7 +415,17 @@ async fn inner_y_line( exec_state: &mut ExecState, args: Args, ) -> Result { - inner_line([0.0, length], sketch, tag, exec_state, args).await + straight_line( + StraightLineParams { + to: Some([0.0, length]), + sketch, + tag, + end: None, + }, + exec_state, + args, + ) + .await } /// Data to draw an angled line. @@ -589,7 +585,7 @@ async fn inner_angled_line_of_x_length( let to = get_y_component(Angle::from_degrees(angle), length); - let new_sketch = inner_line(to.into(), sketch, tag, exec_state, args).await?; + let new_sketch = straight_line(StraightLineParams::relative(to.into(), sketch, tag), exec_state, args).await?; Ok(new_sketch) } @@ -626,7 +622,7 @@ pub async fn angled_line_to_x(exec_state: &mut ExecState, args: Args) -> Result< /// |> line([0, 10], %) /// |> line([-10, 0], %) /// |> close(%) -/// +/// /// example = extrude(10, exampleSketch) /// ``` #[stdlib { @@ -660,7 +656,12 @@ async fn inner_angled_line_to_x( let y_component = x_component * f64::tan(angle.to_radians()); let y_to = from.y + y_component; - let new_sketch = inner_line_to(sketch, [x_to, y_to], tag, exec_state, args).await?; + let new_sketch = straight_line( + StraightLineParams::absolute([x_to, y_to], sketch, tag), + exec_state, + args, + ) + .await?; Ok(new_sketch) } @@ -721,7 +722,7 @@ async fn inner_angled_line_of_y_length( let to = get_x_component(Angle::from_degrees(angle), length); - let new_sketch = inner_line(to.into(), sketch, tag, exec_state, args).await?; + let new_sketch = straight_line(StraightLineParams::relative(to.into(), sketch, tag), exec_state, args).await?; Ok(new_sketch) } @@ -781,7 +782,12 @@ async fn inner_angled_line_to_y( let x_component = y_component / f64::tan(angle.to_radians()); let x_to = from.x + x_component; - let new_sketch = inner_line_to(sketch, [x_to, y_to], tag, exec_state, args).await?; + let new_sketch = straight_line( + StraightLineParams::absolute([x_to, y_to], sketch, tag), + exec_state, + args, + ) + .await?; Ok(new_sketch) } @@ -854,7 +860,7 @@ async fn inner_angled_line_that_intersects( from, ); - let new_sketch = inner_line_to(sketch, to.into(), tag, exec_state, args).await?; + let new_sketch = straight_line(StraightLineParams::absolute(to.into(), sketch, tag), exec_state, args).await?; Ok(new_sketch) } @@ -1043,7 +1049,7 @@ pub async fn start_sketch_on(exec_state: &mut ExecState, args: Args) -> Result close(%) /// /// example = revolve({ axis: 'y', angle: 180 }, exampleSketch) -/// +/// /// exampleSketch002 = startSketchOn(example, 'end') /// |> startProfileAt([4.5, -5], %) /// |> line([0, 5], %) @@ -1397,10 +1403,9 @@ pub(crate) fn inner_profile_start(sketch: Sketch) -> Result<[f64; 2], KclError> /// Close the current sketch. pub async fn close(exec_state: &mut ExecState, args: Args) -> Result { - let (sketch, tag): (Sketch, Option) = args.get_sketch_and_optional_tag()?; - + let sketch = args.get_unlabeled_kw_arg("sketch")?; + let tag = args.get_kw_arg_opt("tag"); let new_sketch = inner_close(sketch, tag, exec_state, args).await?; - Ok(KclValue::Sketch { value: Box::new(new_sketch), }) @@ -1412,23 +1417,29 @@ pub async fn close(exec_state: &mut ExecState, args: Args) -> Result startProfileAt([0, 0], %) -/// |> line([10, 10], %) -/// |> line([10, 0], %) -/// |> close(%) +/// |> line([10, 10]) +/// |> line([10, 0]) +/// |> close() /// |> extrude(10, %) /// ``` /// /// ```no_run /// exampleSketch = startSketchOn('-XZ') /// |> startProfileAt([0, 0], %) -/// |> line([10, 0], %) -/// |> line([0, 10], %) -/// |> close(%) +/// |> line(end: [10, 0]) +/// |> line(end: [0, 10]) +/// |> close() /// /// example = extrude(10, exampleSketch) /// ``` #[stdlib { name = "close", + keywords = true, + unlabeled_first = true, + arg_docs = { + sketch = "The sketch you want to close", + tag = "Create a new tag which refers to this line", + } }] pub(crate) async fn inner_close( sketch: Sketch, diff --git a/src/wasm-lib/kcl/tests/cube/ast.snap b/src/wasm-lib/kcl/tests/cube/ast.snap index 39b2fd4243..521e0fd355 100644 --- a/src/wasm-lib/kcl/tests/cube/ast.snap +++ b/src/wasm-lib/kcl/tests/cube/ast.snap @@ -1,13 +1,14 @@ --- source: kcl/src/simulation_tests.rs description: Result of parsing cube.kcl +snapshot_kind: text --- { "Ok": { "body": [ { "declaration": { - "end": 322, + "end": 343, "id": { "end": 7, "name": "cube", @@ -19,421 +20,421 @@ description: Result of parsing cube.kcl "body": [ { "declaration": { - "end": 42, + "end": 50, "id": { - "end": 29, + "end": 33, "name": "l", - "start": 28, + "start": 32, "type": "Identifier" }, "init": { - "end": 42, + "end": 50, "left": { - "end": 38, - "name": "length", - "start": 32, + "end": 46, + "name": "sideLength", + "start": 36, "type": "Identifier", "type": "Identifier" }, "operator": "/", "right": { - "end": 42, + "end": 50, "raw": "2", - "start": 41, + "start": 49, "type": "Literal", "type": "Literal", "value": 2.0 }, - "start": 32, + "start": 36, "type": "BinaryExpression", "type": "BinaryExpression" }, - "start": 28, + "start": 32, "type": "VariableDeclarator" }, - "end": 42, + "end": 50, "kind": "const", - "start": 28, + "start": 32, "type": "VariableDeclaration", "type": "VariableDeclaration" }, { "declaration": { - "end": 58, + "end": 66, "id": { - "end": 46, + "end": 54, "name": "x", - "start": 45, + "start": 53, "type": "Identifier" }, "init": { "computed": false, - "end": 58, + "end": 66, "object": { - "end": 55, + "end": 63, "name": "center", - "start": 49, + "start": 57, "type": "Identifier", "type": "Identifier" }, "property": { - "end": 57, + "end": 65, "raw": "0", - "start": 56, + "start": 64, "type": "Literal", "type": "Literal", "value": 0.0 }, - "start": 49, + "start": 57, "type": "MemberExpression", "type": "MemberExpression" }, - "start": 45, + "start": 53, "type": "VariableDeclarator" }, - "end": 58, + "end": 66, "kind": "const", - "start": 45, + "start": 53, "type": "VariableDeclaration", "type": "VariableDeclaration" }, { "declaration": { - "end": 74, + "end": 82, "id": { - "end": 62, + "end": 70, "name": "y", - "start": 61, + "start": 69, "type": "Identifier" }, "init": { "computed": false, - "end": 74, + "end": 82, "object": { - "end": 71, + "end": 79, "name": "center", - "start": 65, + "start": 73, "type": "Identifier", "type": "Identifier" }, "property": { - "end": 73, + "end": 81, "raw": "1", - "start": 72, + "start": 80, "type": "Literal", "type": "Literal", "value": 1.0 }, - "start": 65, + "start": 73, "type": "MemberExpression", "type": "MemberExpression" }, - "start": 61, + "start": 69, "type": "VariableDeclarator" }, - "end": 74, + "end": 82, "kind": "const", - "start": 61, + "start": 69, "type": "VariableDeclaration", "type": "VariableDeclaration" }, { "declaration": { - "end": 98, + "end": 106, "id": { - "end": 79, + "end": 87, "name": "p0", - "start": 77, + "start": 85, "type": "Identifier" }, "init": { "elements": [ { - "end": 89, + "end": 97, "left": { "argument": { - "end": 85, + "end": 93, "name": "l", - "start": 84, + "start": 92, "type": "Identifier", "type": "Identifier" }, - "end": 85, + "end": 93, "operator": "-", - "start": 83, + "start": 91, "type": "UnaryExpression", "type": "UnaryExpression" }, "operator": "+", "right": { - "end": 89, + "end": 97, "name": "x", - "start": 88, + "start": 96, "type": "Identifier", "type": "Identifier" }, - "start": 83, + "start": 91, "type": "BinaryExpression", "type": "BinaryExpression" }, { - "end": 97, + "end": 105, "left": { "argument": { - "end": 93, + "end": 101, "name": "l", - "start": 92, + "start": 100, "type": "Identifier", "type": "Identifier" }, - "end": 93, + "end": 101, "operator": "-", - "start": 91, + "start": 99, "type": "UnaryExpression", "type": "UnaryExpression" }, "operator": "+", "right": { - "end": 97, + "end": 105, "name": "y", - "start": 96, + "start": 104, "type": "Identifier", "type": "Identifier" }, - "start": 91, + "start": 99, "type": "BinaryExpression", "type": "BinaryExpression" } ], - "end": 98, - "start": 82, + "end": 106, + "start": 90, "type": "ArrayExpression", "type": "ArrayExpression" }, - "start": 77, + "start": 85, "type": "VariableDeclarator" }, - "end": 98, + "end": 106, "kind": "const", - "start": 77, + "start": 85, "type": "VariableDeclaration", "type": "VariableDeclaration" }, { "declaration": { - "end": 121, + "end": 129, "id": { - "end": 103, + "end": 111, "name": "p1", - "start": 101, + "start": 109, "type": "Identifier" }, "init": { "elements": [ { - "end": 113, + "end": 121, "left": { "argument": { - "end": 109, + "end": 117, "name": "l", - "start": 108, + "start": 116, "type": "Identifier", "type": "Identifier" }, - "end": 109, + "end": 117, "operator": "-", - "start": 107, + "start": 115, "type": "UnaryExpression", "type": "UnaryExpression" }, "operator": "+", "right": { - "end": 113, + "end": 121, "name": "x", - "start": 112, + "start": 120, "type": "Identifier", "type": "Identifier" }, - "start": 107, + "start": 115, "type": "BinaryExpression", "type": "BinaryExpression" }, { - "end": 120, + "end": 128, "left": { - "end": 116, + "end": 124, "name": "l", - "start": 115, + "start": 123, "type": "Identifier", "type": "Identifier" }, "operator": "+", "right": { - "end": 120, + "end": 128, "name": "y", - "start": 119, + "start": 127, "type": "Identifier", "type": "Identifier" }, - "start": 115, + "start": 123, "type": "BinaryExpression", "type": "BinaryExpression" } ], - "end": 121, - "start": 106, + "end": 129, + "start": 114, "type": "ArrayExpression", "type": "ArrayExpression" }, - "start": 101, + "start": 109, "type": "VariableDeclarator" }, - "end": 121, + "end": 129, "kind": "const", - "start": 101, + "start": 109, "type": "VariableDeclaration", "type": "VariableDeclaration" }, { "declaration": { - "end": 143, + "end": 151, "id": { - "end": 126, + "end": 134, "name": "p2", - "start": 124, + "start": 132, "type": "Identifier" }, "init": { "elements": [ { - "end": 135, + "end": 143, "left": { - "end": 131, + "end": 139, "name": "l", - "start": 130, + "start": 138, "type": "Identifier", "type": "Identifier" }, "operator": "+", "right": { - "end": 135, + "end": 143, "name": "x", - "start": 134, + "start": 142, "type": "Identifier", "type": "Identifier" }, - "start": 130, + "start": 138, "type": "BinaryExpression", "type": "BinaryExpression" }, { - "end": 142, + "end": 150, "left": { - "end": 138, + "end": 146, "name": "l", - "start": 137, + "start": 145, "type": "Identifier", "type": "Identifier" }, "operator": "+", "right": { - "end": 142, + "end": 150, "name": "y", - "start": 141, + "start": 149, "type": "Identifier", "type": "Identifier" }, - "start": 137, + "start": 145, "type": "BinaryExpression", "type": "BinaryExpression" } ], - "end": 143, - "start": 129, + "end": 151, + "start": 137, "type": "ArrayExpression", "type": "ArrayExpression" }, - "start": 124, + "start": 132, "type": "VariableDeclarator" }, - "end": 143, + "end": 151, "kind": "const", - "start": 124, + "start": 132, "type": "VariableDeclaration", "type": "VariableDeclaration" }, { "declaration": { - "end": 166, + "end": 174, "id": { - "end": 148, + "end": 156, "name": "p3", - "start": 146, + "start": 154, "type": "Identifier" }, "init": { "elements": [ { - "end": 157, + "end": 165, "left": { - "end": 153, + "end": 161, "name": "l", - "start": 152, + "start": 160, "type": "Identifier", "type": "Identifier" }, "operator": "+", "right": { - "end": 157, + "end": 165, "name": "x", - "start": 156, + "start": 164, "type": "Identifier", "type": "Identifier" }, - "start": 152, + "start": 160, "type": "BinaryExpression", "type": "BinaryExpression" }, { - "end": 165, + "end": 173, "left": { "argument": { - "end": 161, + "end": 169, "name": "l", - "start": 160, + "start": 168, "type": "Identifier", "type": "Identifier" }, - "end": 161, + "end": 169, "operator": "-", - "start": 159, + "start": 167, "type": "UnaryExpression", "type": "UnaryExpression" }, "operator": "+", "right": { - "end": 165, + "end": 173, "name": "y", - "start": 164, + "start": 172, "type": "Identifier", "type": "Identifier" }, - "start": 159, + "start": 167, "type": "BinaryExpression", "type": "BinaryExpression" } ], - "end": 166, - "start": 151, + "end": 174, + "start": 159, "type": "ArrayExpression", "type": "ArrayExpression" }, - "start": 146, + "start": 154, "type": "VariableDeclarator" }, - "end": 166, + "end": 174, "kind": "const", - "start": 146, + "start": 154, "type": "VariableDeclaration", "type": "VariableDeclaration" }, @@ -443,198 +444,201 @@ description: Result of parsing cube.kcl { "arguments": [ { - "end": 193, + "end": 201, "name": "p0", - "start": 191, + "start": 199, "type": "Identifier", "type": "Identifier" } ], "callee": { - "end": 190, + "end": 198, "name": "startSketchAt", - "start": 177, + "start": 185, "type": "Identifier" }, - "end": 194, - "start": 177, + "end": 202, + "start": 185, "type": "CallExpression", "type": "CallExpression" }, { "arguments": [ { - "end": 211, - "name": "p1", - "start": 209, - "type": "Identifier", - "type": "Identifier" - }, - { - "end": 214, - "start": 213, - "type": "PipeSubstitution", - "type": "PipeSubstitution" + "type": "LabeledArg", + "label": { + "type": "Identifier", + "name": "end" + }, + "arg": { + "end": 223, + "name": "p1", + "start": 221, + "type": "Identifier", + "type": "Identifier" + } } ], "callee": { - "end": 208, - "name": "lineTo", - "start": 202, + "end": 214, + "name": "line", + "start": 210, "type": "Identifier" }, - "end": 215, - "start": 202, - "type": "CallExpression", - "type": "CallExpression" + "end": 224, + "start": 210, + "type": "CallExpressionKw", + "type": "CallExpressionKw", + "unlabeled": null }, { "arguments": [ { - "end": 232, - "name": "p2", - "start": 230, - "type": "Identifier", - "type": "Identifier" - }, - { - "end": 235, - "start": 234, - "type": "PipeSubstitution", - "type": "PipeSubstitution" + "type": "LabeledArg", + "label": { + "type": "Identifier", + "name": "end" + }, + "arg": { + "end": 245, + "name": "p2", + "start": 243, + "type": "Identifier", + "type": "Identifier" + } } ], "callee": { - "end": 229, - "name": "lineTo", - "start": 223, + "end": 236, + "name": "line", + "start": 232, "type": "Identifier" }, - "end": 236, - "start": 223, - "type": "CallExpression", - "type": "CallExpression" + "end": 246, + "start": 232, + "type": "CallExpressionKw", + "type": "CallExpressionKw", + "unlabeled": null }, { "arguments": [ { - "end": 253, - "name": "p3", - "start": 251, - "type": "Identifier", - "type": "Identifier" - }, - { - "end": 256, - "start": 255, - "type": "PipeSubstitution", - "type": "PipeSubstitution" + "type": "LabeledArg", + "label": { + "type": "Identifier", + "name": "end" + }, + "arg": { + "end": 267, + "name": "p3", + "start": 265, + "type": "Identifier", + "type": "Identifier" + } } ], "callee": { - "end": 250, - "name": "lineTo", - "start": 244, + "end": 258, + "name": "line", + "start": 254, "type": "Identifier" }, - "end": 257, - "start": 244, - "type": "CallExpression", - "type": "CallExpression" + "end": 268, + "start": 254, + "type": "CallExpressionKw", + "type": "CallExpressionKw", + "unlabeled": null }, { "arguments": [ { - "end": 274, - "name": "p0", - "start": 272, - "type": "Identifier", - "type": "Identifier" - }, - { - "end": 277, - "start": 276, - "type": "PipeSubstitution", - "type": "PipeSubstitution" + "type": "LabeledArg", + "label": { + "type": "Identifier", + "name": "end" + }, + "arg": { + "end": 289, + "name": "p0", + "start": 287, + "type": "Identifier", + "type": "Identifier" + } } ], "callee": { - "end": 271, - "name": "lineTo", - "start": 265, + "end": 280, + "name": "line", + "start": 276, "type": "Identifier" }, - "end": 278, - "start": 265, - "type": "CallExpression", - "type": "CallExpression" + "end": 290, + "start": 276, + "type": "CallExpressionKw", + "type": "CallExpressionKw", + "unlabeled": null }, { - "arguments": [ - { - "end": 293, - "start": 292, - "type": "PipeSubstitution", - "type": "PipeSubstitution" - } - ], + "arguments": [], "callee": { - "end": 291, + "end": 303, "name": "close", - "start": 286, + "start": 298, "type": "Identifier" }, - "end": 294, - "start": 286, + "end": 305, + "start": 298, "type": "CallExpression", "type": "CallExpression" }, { "arguments": [ { - "end": 316, - "name": "length", - "start": 310, - "type": "Identifier", - "type": "Identifier" - }, - { - "end": 319, - "start": 318, - "type": "PipeSubstitution", - "type": "PipeSubstitution" + "type": "LabeledArg", + "label": { + "type": "Identifier", + "name": "length" + }, + "arg": { + "end": 340, + "name": "sideLength", + "start": 330, + "type": "Identifier", + "type": "Identifier" + } } ], "callee": { - "end": 309, + "end": 320, "name": "extrude", - "start": 302, + "start": 313, "type": "Identifier" }, - "end": 320, - "start": 302, - "type": "CallExpression", - "type": "CallExpression" + "end": 341, + "start": 313, + "type": "CallExpressionKw", + "type": "CallExpressionKw", + "unlabeled": null } ], - "end": 320, - "start": 177, + "end": 341, + "start": 185, "type": "PipeExpression", "type": "PipeExpression" }, - "end": 320, - "start": 170, + "end": 341, + "start": 178, "type": "ReturnStatement", "type": "ReturnStatement" } ], - "end": 322, + "end": 343, "nonCodeMeta": { "nonCodeNodes": { "6": [ { - "end": 170, - "start": 166, + "end": 178, + "start": 174, "type": "NonCodeNode", "value": { "type": "newLine" @@ -644,15 +648,15 @@ description: Result of parsing cube.kcl }, "startNodes": [] }, - "start": 24 + "start": 28 }, - "end": 322, + "end": 343, "params": [ { "type": "Parameter", "identifier": { - "end": 14, - "name": "length", + "end": 18, + "name": "sideLength", "start": 8, "type": "Identifier" } @@ -660,9 +664,9 @@ description: Result of parsing cube.kcl { "type": "Parameter", "identifier": { - "end": 22, + "end": 26, "name": "center", - "start": 16, + "start": 20, "type": "Identifier" } } @@ -674,7 +678,7 @@ description: Result of parsing cube.kcl "start": 3, "type": "VariableDeclarator" }, - "end": 322, + "end": 343, "kind": "fn", "start": 0, "type": "VariableDeclaration", @@ -682,76 +686,91 @@ description: Result of parsing cube.kcl }, { "declaration": { - "end": 349, + "end": 392, "id": { - "end": 330, + "end": 351, "name": "myCube", - "start": 324, + "start": 345, "type": "Identifier" }, "init": { "arguments": [ { - "end": 340, - "raw": "40", - "start": 338, - "type": "Literal", - "type": "Literal", - "value": 40.0 + "type": "LabeledArg", + "label": { + "type": "Identifier", + "name": "sideLength" + }, + "arg": { + "end": 374, + "raw": "40", + "start": 372, + "type": "Literal", + "type": "Literal", + "value": 40.0 + } }, { - "elements": [ - { - "end": 344, - "raw": "0", - "start": 343, - "type": "Literal", - "type": "Literal", - "value": 0.0 - }, - { - "end": 347, - "raw": "0", - "start": 346, - "type": "Literal", - "type": "Literal", - "value": 0.0 - } - ], - "end": 348, - "start": 342, - "type": "ArrayExpression", - "type": "ArrayExpression" + "type": "LabeledArg", + "label": { + "type": "Identifier", + "name": "center" + }, + "arg": { + "elements": [ + { + "end": 387, + "raw": "0", + "start": 386, + "type": "Literal", + "type": "Literal", + "value": 0.0 + }, + { + "end": 390, + "raw": "0", + "start": 389, + "type": "Literal", + "type": "Literal", + "value": 0.0 + } + ], + "end": 391, + "start": 385, + "type": "ArrayExpression", + "type": "ArrayExpression" + } } ], "callee": { - "end": 337, + "end": 358, "name": "cube", - "start": 333, + "start": 354, "type": "Identifier" }, - "end": 349, - "start": 333, - "type": "CallExpression", - "type": "CallExpression" + "end": 392, + "start": 354, + "type": "CallExpressionKw", + "type": "CallExpressionKw", + "unlabeled": null }, - "start": 324, + "start": 345, "type": "VariableDeclarator" }, - "end": 349, + "end": 392, "kind": "const", - "start": 324, + "start": 345, "type": "VariableDeclaration", "type": "VariableDeclaration" } ], - "end": 350, + "end": 393, "nonCodeMeta": { "nonCodeNodes": { "0": [ { - "end": 324, - "start": 322, + "end": 345, + "start": 343, "type": "NonCodeNode", "value": { "type": "newLine" diff --git a/src/wasm-lib/kcl/tests/cube/input.kcl b/src/wasm-lib/kcl/tests/cube/input.kcl index 9ffe56eb2f..80ceb1fe13 100644 --- a/src/wasm-lib/kcl/tests/cube/input.kcl +++ b/src/wasm-lib/kcl/tests/cube/input.kcl @@ -1,5 +1,5 @@ -fn cube(length, center) { - l = length / 2 +fn cube(sideLength, center) { + l = sideLength / 2 x = center[0] y = center[1] p0 = [-l + x, -l + y] @@ -8,12 +8,12 @@ fn cube(length, center) { p3 = [l + x, -l + y] return startSketchAt(p0) - |> lineTo(p1, %) - |> lineTo(p2, %) - |> lineTo(p3, %) - |> lineTo(p0, %) - |> close(%) - |> extrude(length, %) + |> line(end = p1) + |> line(end = p2) + |> line(end = p3) + |> line(end = p0) + |> close() + |> extrude(length = sideLength) } -myCube = cube(40, [0, 0]) +myCube = cube(sideLength = 40, center = [0, 0]) diff --git a/src/wasm-lib/kcl/tests/cube/program_memory.snap b/src/wasm-lib/kcl/tests/cube/program_memory.snap index ab2d290cc0..fb6476178b 100644 --- a/src/wasm-lib/kcl/tests/cube/program_memory.snap +++ b/src/wasm-lib/kcl/tests/cube/program_memory.snap @@ -1,6 +1,7 @@ --- source: kcl/src/simulation_tests.rs description: Program memory after executing cube.kcl +snapshot_kind: text --- { "environments": [ @@ -33,421 +34,421 @@ description: Program memory after executing cube.kcl "body": [ { "declaration": { - "end": 42, + "end": 50, "id": { - "end": 29, + "end": 33, "name": "l", - "start": 28, + "start": 32, "type": "Identifier" }, "init": { - "end": 42, + "end": 50, "left": { - "end": 38, - "name": "length", - "start": 32, + "end": 46, + "name": "sideLength", + "start": 36, "type": "Identifier", "type": "Identifier" }, "operator": "/", "right": { - "end": 42, + "end": 50, "raw": "2", - "start": 41, + "start": 49, "type": "Literal", "type": "Literal", "value": 2.0 }, - "start": 32, + "start": 36, "type": "BinaryExpression", "type": "BinaryExpression" }, - "start": 28, + "start": 32, "type": "VariableDeclarator" }, - "end": 42, + "end": 50, "kind": "const", - "start": 28, + "start": 32, "type": "VariableDeclaration", "type": "VariableDeclaration" }, { "declaration": { - "end": 58, + "end": 66, "id": { - "end": 46, + "end": 54, "name": "x", - "start": 45, + "start": 53, "type": "Identifier" }, "init": { "computed": false, - "end": 58, + "end": 66, "object": { - "end": 55, + "end": 63, "name": "center", - "start": 49, + "start": 57, "type": "Identifier", "type": "Identifier" }, "property": { - "end": 57, + "end": 65, "raw": "0", - "start": 56, + "start": 64, "type": "Literal", "type": "Literal", "value": 0.0 }, - "start": 49, + "start": 57, "type": "MemberExpression", "type": "MemberExpression" }, - "start": 45, + "start": 53, "type": "VariableDeclarator" }, - "end": 58, + "end": 66, "kind": "const", - "start": 45, + "start": 53, "type": "VariableDeclaration", "type": "VariableDeclaration" }, { "declaration": { - "end": 74, + "end": 82, "id": { - "end": 62, + "end": 70, "name": "y", - "start": 61, + "start": 69, "type": "Identifier" }, "init": { "computed": false, - "end": 74, + "end": 82, "object": { - "end": 71, + "end": 79, "name": "center", - "start": 65, + "start": 73, "type": "Identifier", "type": "Identifier" }, "property": { - "end": 73, + "end": 81, "raw": "1", - "start": 72, + "start": 80, "type": "Literal", "type": "Literal", "value": 1.0 }, - "start": 65, + "start": 73, "type": "MemberExpression", "type": "MemberExpression" }, - "start": 61, + "start": 69, "type": "VariableDeclarator" }, - "end": 74, + "end": 82, "kind": "const", - "start": 61, + "start": 69, "type": "VariableDeclaration", "type": "VariableDeclaration" }, { "declaration": { - "end": 98, + "end": 106, "id": { - "end": 79, + "end": 87, "name": "p0", - "start": 77, + "start": 85, "type": "Identifier" }, "init": { "elements": [ { - "end": 89, + "end": 97, "left": { "argument": { - "end": 85, + "end": 93, "name": "l", - "start": 84, + "start": 92, "type": "Identifier", "type": "Identifier" }, - "end": 85, + "end": 93, "operator": "-", - "start": 83, + "start": 91, "type": "UnaryExpression", "type": "UnaryExpression" }, "operator": "+", "right": { - "end": 89, + "end": 97, "name": "x", - "start": 88, + "start": 96, "type": "Identifier", "type": "Identifier" }, - "start": 83, + "start": 91, "type": "BinaryExpression", "type": "BinaryExpression" }, { - "end": 97, + "end": 105, "left": { "argument": { - "end": 93, + "end": 101, "name": "l", - "start": 92, + "start": 100, "type": "Identifier", "type": "Identifier" }, - "end": 93, + "end": 101, "operator": "-", - "start": 91, + "start": 99, "type": "UnaryExpression", "type": "UnaryExpression" }, "operator": "+", "right": { - "end": 97, + "end": 105, "name": "y", - "start": 96, + "start": 104, "type": "Identifier", "type": "Identifier" }, - "start": 91, + "start": 99, "type": "BinaryExpression", "type": "BinaryExpression" } ], - "end": 98, - "start": 82, + "end": 106, + "start": 90, "type": "ArrayExpression", "type": "ArrayExpression" }, - "start": 77, + "start": 85, "type": "VariableDeclarator" }, - "end": 98, + "end": 106, "kind": "const", - "start": 77, + "start": 85, "type": "VariableDeclaration", "type": "VariableDeclaration" }, { "declaration": { - "end": 121, + "end": 129, "id": { - "end": 103, + "end": 111, "name": "p1", - "start": 101, + "start": 109, "type": "Identifier" }, "init": { "elements": [ { - "end": 113, + "end": 121, "left": { "argument": { - "end": 109, + "end": 117, "name": "l", - "start": 108, + "start": 116, "type": "Identifier", "type": "Identifier" }, - "end": 109, + "end": 117, "operator": "-", - "start": 107, + "start": 115, "type": "UnaryExpression", "type": "UnaryExpression" }, "operator": "+", "right": { - "end": 113, + "end": 121, "name": "x", - "start": 112, + "start": 120, "type": "Identifier", "type": "Identifier" }, - "start": 107, + "start": 115, "type": "BinaryExpression", "type": "BinaryExpression" }, { - "end": 120, + "end": 128, "left": { - "end": 116, + "end": 124, "name": "l", - "start": 115, + "start": 123, "type": "Identifier", "type": "Identifier" }, "operator": "+", "right": { - "end": 120, + "end": 128, "name": "y", - "start": 119, + "start": 127, "type": "Identifier", "type": "Identifier" }, - "start": 115, + "start": 123, "type": "BinaryExpression", "type": "BinaryExpression" } ], - "end": 121, - "start": 106, + "end": 129, + "start": 114, "type": "ArrayExpression", "type": "ArrayExpression" }, - "start": 101, + "start": 109, "type": "VariableDeclarator" }, - "end": 121, + "end": 129, "kind": "const", - "start": 101, + "start": 109, "type": "VariableDeclaration", "type": "VariableDeclaration" }, { "declaration": { - "end": 143, + "end": 151, "id": { - "end": 126, + "end": 134, "name": "p2", - "start": 124, + "start": 132, "type": "Identifier" }, "init": { "elements": [ { - "end": 135, + "end": 143, "left": { - "end": 131, + "end": 139, "name": "l", - "start": 130, + "start": 138, "type": "Identifier", "type": "Identifier" }, "operator": "+", "right": { - "end": 135, + "end": 143, "name": "x", - "start": 134, + "start": 142, "type": "Identifier", "type": "Identifier" }, - "start": 130, + "start": 138, "type": "BinaryExpression", "type": "BinaryExpression" }, { - "end": 142, + "end": 150, "left": { - "end": 138, + "end": 146, "name": "l", - "start": 137, + "start": 145, "type": "Identifier", "type": "Identifier" }, "operator": "+", "right": { - "end": 142, + "end": 150, "name": "y", - "start": 141, + "start": 149, "type": "Identifier", "type": "Identifier" }, - "start": 137, + "start": 145, "type": "BinaryExpression", "type": "BinaryExpression" } ], - "end": 143, - "start": 129, + "end": 151, + "start": 137, "type": "ArrayExpression", "type": "ArrayExpression" }, - "start": 124, + "start": 132, "type": "VariableDeclarator" }, - "end": 143, + "end": 151, "kind": "const", - "start": 124, + "start": 132, "type": "VariableDeclaration", "type": "VariableDeclaration" }, { "declaration": { - "end": 166, + "end": 174, "id": { - "end": 148, + "end": 156, "name": "p3", - "start": 146, + "start": 154, "type": "Identifier" }, "init": { "elements": [ { - "end": 157, + "end": 165, "left": { - "end": 153, + "end": 161, "name": "l", - "start": 152, + "start": 160, "type": "Identifier", "type": "Identifier" }, "operator": "+", "right": { - "end": 157, + "end": 165, "name": "x", - "start": 156, + "start": 164, "type": "Identifier", "type": "Identifier" }, - "start": 152, + "start": 160, "type": "BinaryExpression", "type": "BinaryExpression" }, { - "end": 165, + "end": 173, "left": { "argument": { - "end": 161, + "end": 169, "name": "l", - "start": 160, + "start": 168, "type": "Identifier", "type": "Identifier" }, - "end": 161, + "end": 169, "operator": "-", - "start": 159, + "start": 167, "type": "UnaryExpression", "type": "UnaryExpression" }, "operator": "+", "right": { - "end": 165, + "end": 173, "name": "y", - "start": 164, + "start": 172, "type": "Identifier", "type": "Identifier" }, - "start": 159, + "start": 167, "type": "BinaryExpression", "type": "BinaryExpression" } ], - "end": 166, - "start": 151, + "end": 174, + "start": 159, "type": "ArrayExpression", "type": "ArrayExpression" }, - "start": 146, + "start": 154, "type": "VariableDeclarator" }, - "end": 166, + "end": 174, "kind": "const", - "start": 146, + "start": 154, "type": "VariableDeclaration", "type": "VariableDeclaration" }, @@ -457,198 +458,201 @@ description: Program memory after executing cube.kcl { "arguments": [ { - "end": 193, + "end": 201, "name": "p0", - "start": 191, + "start": 199, "type": "Identifier", "type": "Identifier" } ], "callee": { - "end": 190, + "end": 198, "name": "startSketchAt", - "start": 177, + "start": 185, "type": "Identifier" }, - "end": 194, - "start": 177, + "end": 202, + "start": 185, "type": "CallExpression", "type": "CallExpression" }, { "arguments": [ { - "end": 211, - "name": "p1", - "start": 209, - "type": "Identifier", - "type": "Identifier" - }, - { - "end": 214, - "start": 213, - "type": "PipeSubstitution", - "type": "PipeSubstitution" + "type": "LabeledArg", + "label": { + "type": "Identifier", + "name": "end" + }, + "arg": { + "end": 223, + "name": "p1", + "start": 221, + "type": "Identifier", + "type": "Identifier" + } } ], "callee": { - "end": 208, - "name": "lineTo", - "start": 202, + "end": 214, + "name": "line", + "start": 210, "type": "Identifier" }, - "end": 215, - "start": 202, - "type": "CallExpression", - "type": "CallExpression" + "end": 224, + "start": 210, + "type": "CallExpressionKw", + "type": "CallExpressionKw", + "unlabeled": null }, { "arguments": [ { - "end": 232, - "name": "p2", - "start": 230, - "type": "Identifier", - "type": "Identifier" - }, - { - "end": 235, - "start": 234, - "type": "PipeSubstitution", - "type": "PipeSubstitution" + "type": "LabeledArg", + "label": { + "type": "Identifier", + "name": "end" + }, + "arg": { + "end": 245, + "name": "p2", + "start": 243, + "type": "Identifier", + "type": "Identifier" + } } ], "callee": { - "end": 229, - "name": "lineTo", - "start": 223, + "end": 236, + "name": "line", + "start": 232, "type": "Identifier" }, - "end": 236, - "start": 223, - "type": "CallExpression", - "type": "CallExpression" + "end": 246, + "start": 232, + "type": "CallExpressionKw", + "type": "CallExpressionKw", + "unlabeled": null }, { "arguments": [ { - "end": 253, - "name": "p3", - "start": 251, - "type": "Identifier", - "type": "Identifier" - }, - { - "end": 256, - "start": 255, - "type": "PipeSubstitution", - "type": "PipeSubstitution" + "type": "LabeledArg", + "label": { + "type": "Identifier", + "name": "end" + }, + "arg": { + "end": 267, + "name": "p3", + "start": 265, + "type": "Identifier", + "type": "Identifier" + } } ], "callee": { - "end": 250, - "name": "lineTo", - "start": 244, + "end": 258, + "name": "line", + "start": 254, "type": "Identifier" }, - "end": 257, - "start": 244, - "type": "CallExpression", - "type": "CallExpression" + "end": 268, + "start": 254, + "type": "CallExpressionKw", + "type": "CallExpressionKw", + "unlabeled": null }, { "arguments": [ { - "end": 274, - "name": "p0", - "start": 272, - "type": "Identifier", - "type": "Identifier" - }, - { - "end": 277, - "start": 276, - "type": "PipeSubstitution", - "type": "PipeSubstitution" + "type": "LabeledArg", + "label": { + "type": "Identifier", + "name": "end" + }, + "arg": { + "end": 289, + "name": "p0", + "start": 287, + "type": "Identifier", + "type": "Identifier" + } } ], "callee": { - "end": 271, - "name": "lineTo", - "start": 265, + "end": 280, + "name": "line", + "start": 276, "type": "Identifier" }, - "end": 278, - "start": 265, - "type": "CallExpression", - "type": "CallExpression" + "end": 290, + "start": 276, + "type": "CallExpressionKw", + "type": "CallExpressionKw", + "unlabeled": null }, { - "arguments": [ - { - "end": 293, - "start": 292, - "type": "PipeSubstitution", - "type": "PipeSubstitution" - } - ], + "arguments": [], "callee": { - "end": 291, + "end": 303, "name": "close", - "start": 286, + "start": 298, "type": "Identifier" }, - "end": 294, - "start": 286, + "end": 305, + "start": 298, "type": "CallExpression", "type": "CallExpression" }, { "arguments": [ { - "end": 316, - "name": "length", - "start": 310, - "type": "Identifier", - "type": "Identifier" - }, - { - "end": 319, - "start": 318, - "type": "PipeSubstitution", - "type": "PipeSubstitution" + "type": "LabeledArg", + "label": { + "type": "Identifier", + "name": "length" + }, + "arg": { + "end": 340, + "name": "sideLength", + "start": 330, + "type": "Identifier", + "type": "Identifier" + } } ], "callee": { - "end": 309, + "end": 320, "name": "extrude", - "start": 302, + "start": 313, "type": "Identifier" }, - "end": 320, - "start": 302, - "type": "CallExpression", - "type": "CallExpression" + "end": 341, + "start": 313, + "type": "CallExpressionKw", + "type": "CallExpressionKw", + "unlabeled": null } ], - "end": 320, - "start": 177, + "end": 341, + "start": 185, "type": "PipeExpression", "type": "PipeExpression" }, - "end": 320, - "start": 170, + "end": 341, + "start": 178, "type": "ReturnStatement", "type": "ReturnStatement" } ], - "end": 322, + "end": 343, "nonCodeMeta": { "nonCodeNodes": { "6": [ { - "end": 170, - "start": 166, + "end": 178, + "start": 174, "type": "NonCodeNode", "value": { "type": "newLine" @@ -658,15 +662,15 @@ description: Program memory after executing cube.kcl }, "startNodes": [] }, - "start": 24 + "start": 28 }, - "end": 322, + "end": 343, "params": [ { "type": "Parameter", "identifier": { - "end": 14, - "name": "length", + "end": 18, + "name": "sideLength", "start": 8, "type": "Identifier" } @@ -674,9 +678,9 @@ description: Program memory after executing cube.kcl { "type": "Parameter", "identifier": { - "end": 22, + "end": 26, "name": "center", - "start": 16, + "start": 20, "type": "Identifier" } } @@ -719,7 +723,7 @@ description: Program memory after executing cube.kcl { "sourceRange": [ 7, - 322, + 343, 0 ] } @@ -734,8 +738,8 @@ description: Program memory after executing cube.kcl "faceId": "[uuid]", "id": "[uuid]", "sourceRange": [ - 202, - 215, + 210, + 224, 0 ], "tag": null, @@ -745,8 +749,8 @@ description: Program memory after executing cube.kcl "faceId": "[uuid]", "id": "[uuid]", "sourceRange": [ - 223, - 236, + 232, + 246, 0 ], "tag": null, @@ -756,8 +760,8 @@ description: Program memory after executing cube.kcl "faceId": "[uuid]", "id": "[uuid]", "sourceRange": [ - 244, - 257, + 254, + 268, 0 ], "tag": null, @@ -767,8 +771,8 @@ description: Program memory after executing cube.kcl "faceId": "[uuid]", "id": "[uuid]", "sourceRange": [ - 265, - 278, + 276, + 290, 0 ], "tag": null, @@ -783,8 +787,8 @@ description: Program memory after executing cube.kcl "__geoMeta": { "id": "[uuid]", "sourceRange": [ - 202, - 215, + 210, + 224, 0 ] }, @@ -803,8 +807,8 @@ description: Program memory after executing cube.kcl "__geoMeta": { "id": "[uuid]", "sourceRange": [ - 223, - 236, + 232, + 246, 0 ] }, @@ -823,8 +827,8 @@ description: Program memory after executing cube.kcl "__geoMeta": { "id": "[uuid]", "sourceRange": [ - 244, - 257, + 254, + 268, 0 ] }, @@ -843,8 +847,8 @@ description: Program memory after executing cube.kcl "__geoMeta": { "id": "[uuid]", "sourceRange": [ - 265, - 278, + 276, + 290, 0 ] }, @@ -863,8 +867,8 @@ description: Program memory after executing cube.kcl "__geoMeta": { "id": "[uuid]", "sourceRange": [ - 286, - 294, + 298, + 305, 0 ] }, @@ -919,8 +923,8 @@ description: Program memory after executing cube.kcl "__geoMeta": { "id": "[uuid]", "sourceRange": [ - 177, - 194, + 185, + 202, 0 ] } @@ -928,8 +932,8 @@ description: Program memory after executing cube.kcl "__meta": [ { "sourceRange": [ - 177, - 194, + 185, + 202, 0 ] } @@ -941,8 +945,8 @@ description: Program memory after executing cube.kcl "__meta": [ { "sourceRange": [ - 177, - 194, + 185, + 202, 0 ] }