rm createCallExpressionStdLib

This commit is contained in:
Adam Chalmers
2025-04-28 11:17:11 -05:00
parent 199947b2e0
commit 61830e6f0a
5 changed files with 29 additions and 41 deletions

View File

@ -140,23 +140,6 @@ export function createPipeSubstitution(): Node<PipeSubstitution> {
}
}
export function createCallExpressionStdLib(
name: string,
args: CallExpression['arguments']
): Node<CallExpression> {
return {
type: 'CallExpression',
start: 0,
end: 0,
moduleId: 0,
outerAttrs: [],
preComments: [],
commentStart: 0,
callee: createLocalName(name),
arguments: args,
}
}
export const nonCodeMetaEmpty = () => {
return { nonCodeNodes: {}, startNodes: [], start: 0, end: 0 }
}

View File

@ -5,7 +5,6 @@ import type { NonCodeMeta } from '@rust/kcl-lib/bindings/NonCodeMeta'
import {
createArrayExpression,
createCallExpressionStdLib,
createCallExpressionStdLibKw,
createExpressionStatement,
createIdentifier,
@ -612,7 +611,7 @@ export function revolveSketch(
if (err(_node3)) return _node3
const { node: variableDeclarator, shallowPath: pathToDecleration } = _node3
const revolveCall = createCallExpressionStdLib('revolve', [
const revolveCall = createCallExpressionStdLibKw('revolve', [
createObjectExpression({
angle: angle,
// TODO: hard coded 'X' axis for revolve MVP, should be changed.

View File

@ -22,7 +22,6 @@ import type {
Program,
} from '@src/lang/wasm'
import {
createCallExpressionStdLib,
createArrayExpression,
createLocalName,
createCallExpressionStdLibKw,
@ -194,12 +193,15 @@ export function createTagExpressions(
// Modify the tag based on selectionType
if (artifact.type === 'sweepEdge' && artifact.subType === 'opposite') {
tagCall = createCallExpressionStdLib('getOppositeEdge', [tagCall])
} else if (
artifact.type === 'sweepEdge' &&
artifact.subType === 'adjacent'
) {
tagCall = createCallExpressionStdLib('getNextAdjacentEdge', [tagCall])
tagCall = createCallExpressionStdLibKw(
'getNextAdjacentEdge',
tagCall,
[]
)
}
return tagCall
}

View File

@ -3,7 +3,8 @@ import type { Name } from '@rust/kcl-lib/bindings/Name'
import {
createArrayExpression,
createCallExpression,
createCallExpressionStdLib,
createCallExpressionStdLibKw,
createLabeledArg,
createLiteral,
createPipeSubstitution,
} from '@src/lang/create'
@ -28,6 +29,7 @@ import { assertParse, recast } from '@src/lang/wasm'
import { initPromise } from '@src/lang/wasmUtils'
import { enginelessExecutor } from '@src/lib/testHelpers'
import { err } from '@src/lib/trap'
import { ARG_END_ABSOLUTE } from '@src/lang/constants'
beforeAll(async () => {
await initPromise
@ -721,20 +723,23 @@ describe('Testing specific sketch getNodeFromPath workflow', () => {
variables: {},
pathToNode: sketchPathToNode,
expressions: [
createCallExpressionStdLib(
'lineTo', // We are forcing lineTo!
[
createCallExpressionStdLibKw('line', null, [
createLabeledArg(
ARG_END_ABSOLUTE,
createArrayExpression([
createCallExpressionStdLib('profileStartX', [
createCallExpressionStdLibKw(
'profileStartX',
createPipeSubstitution(),
]),
createCallExpressionStdLib('profileStartY', [
[]
),
createCallExpressionStdLibKw(
'profileStartY',
createPipeSubstitution(),
]),
]),
createPipeSubstitution(),
]
),
[]
),
])
),
]),
],
})
if (err(modifiedAst)) throw modifiedAst
@ -748,7 +753,7 @@ describe('Testing specific sketch getNodeFromPath workflow', () => {
|> xLine(length = -0.15)
|> line([-0.02, 0.21], %)
|> line([-0.08, 0.05], %)
|> lineTo([profileStartX(%), profileStartY(%)], %)
|> line(endAbsolute = [profileStartX(%), profileStartY(%)])
`
expect(recasted).toEqual(expectedCode)
})

View File

@ -9,7 +9,6 @@ import {
import {
createArrayExpression,
createBinaryExpression,
createCallExpressionStdLib,
createCallExpressionStdLibKw,
createLabeledArg,
createLiteral,
@ -64,16 +63,16 @@ export const getRectangleCallExpressions = (
),
angledLine(
createBinaryExpression([
createCallExpressionStdLib('segAng', [createLocalName(tag)]),
createCallExpressionStdLibKw('segAng', createLocalName(tag), []),
'+',
createLiteral(90),
]), // 90 offset from the previous line
createLiteral(0) // This will be the height of the rectangle
),
angledLine(
createCallExpressionStdLib('segAng', [createLocalName(tag)]), // same angle as the first line
createCallExpressionStdLibKw('segAng', createLocalName(tag), []), // same angle as the first line
createUnaryExpression(
createCallExpressionStdLib('segLen', [createLocalName(tag)]),
createCallExpressionStdLibKw('segLen', createLocalName(tag), []),
'-'
) // negative height
),
@ -120,7 +119,7 @@ export function updateRectangleSketch(
'angle',
secondEdge,
createBinaryExpression([
createCallExpressionStdLib('segAng', [createLocalName(tag)]),
createCallExpressionStdLibKw('segAng', createLocalName(tag), []),
Math.sign(y) === Math.sign(x) ? '+' : '-',
createLiteral(90),
])
@ -198,7 +197,7 @@ export function updateCenterRectangleSketch(
}
oldAngleOperator = oldAngle.operator
const newAngle = createBinaryExpression([
createCallExpressionStdLib('segAng', [createLocalName(tag)]),
createCallExpressionStdLibKw('segAng', createLocalName(tag), []),
oldAngleOperator,
createLiteral(90),
])