{"version":3,"file":"expr.mjs","names":[],"sources":["../../src/ast/expr.ts"],"sourcesContent":["import type {\n    Expression,\n    NullLiteral,\n    Program,\n    VariableDeclaration,\n    VariableDeclarator,\n} from \"oxc-parser\";\n\nimport type { CompilerContext } from \"#/contexts/compiler\";\n\nimport { Visitor } from \"oxc-parser\";\n\ntype FindInlineExpressionOptions = {\n    context: CompilerContext;\n    program: Program;\n    name: string;\n};\n\nconst findInlineExpression = (\n    options: FindInlineExpressionOptions,\n): Expression | undefined => {\n    let result: Expression | undefined = void 0;\n\n    const visitor = new Visitor({\n        VariableDeclaration: (node: VariableDeclaration): void => {\n            for (let i: number = 0; i < node.declarations.length; i++) {\n                const decl: VariableDeclarator | undefined =\n                    node.declarations[i];\n\n                if (!decl) continue;\n\n                if (decl.id.type !== \"Identifier\") continue;\n\n                if (decl.id.name !== options.name) continue;\n\n                if (decl.init === null) {\n                    result = {\n                        type: \"Literal\",\n                        value: null,\n                        raw: null,\n                        start: 0,\n                        end: 0,\n                    } satisfies NullLiteral;\n                    return void 0;\n                }\n\n                result = decl.init;\n            }\n        },\n    });\n\n    visitor.visit(options.program);\n\n    return result;\n};\n\nexport type { FindInlineExpressionOptions };\nexport { findInlineExpression };\n"],"mappings":";;AAkBA,MAAM,wBACF,YACyB;CACzB,IAAI,SAAiC,KAAK;CA8B1C,IA5BoB,QAAQ,EACxB,sBAAsB,SAAoC;EACtD,KAAK,IAAI,IAAY,GAAG,IAAI,KAAK,aAAa,QAAQ,KAAK;GACvD,MAAM,OACF,KAAK,aAAa;GAEtB,IAAI,CAAC,MAAM;GAEX,IAAI,KAAK,GAAG,SAAS,cAAc;GAEnC,IAAI,KAAK,GAAG,SAAS,QAAQ,MAAM;GAEnC,IAAI,KAAK,SAAS,MAAM;IACpB,SAAS;KACL,MAAM;KACN,OAAO;KACP,KAAK;KACL,OAAO;KACP,KAAK;IACT;IACA;GACJ;GAEA,SAAS,KAAK;EAClB;CACJ,EACJ,CAEM,CAAC,CAAC,MAAM,QAAQ,OAAO;CAE7B,OAAO;AACX"}