Skip to content

Commit 90bbe66

Browse files
committed
fix for lambdas and support for lambda syntax without parenthesis
1 parent 442e575 commit 90bbe66

File tree

2 files changed

+37
-20
lines changed

2 files changed

+37
-20
lines changed

Resources/OSL Utils.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -697,6 +697,10 @@ class OSLUtils {
697697
if (!node) return node;
698698
if (node.type === "inl") {
699699
const params = (node?.left?.parameters || []).map(p => p.data).join(",");
700+
const right = node.right;
701+
if (typeof right.data === "string" && !right.data.trim().startsWith("(\n")) {
702+
right.data = `(\nreturn ${right.data}\n)`;
703+
}
700704
return {
701705
type: "fnc",
702706
data: "function",
@@ -705,7 +709,7 @@ class OSLUtils {
705709
type: "str",
706710
data: params
707711
},
708-
this.generateAST({ CODE: node.right.data, START: 0 })[0]
712+
this.generateAST({ CODE: right.data, START: 0 })[0]
709713
],
710714
}
711715
}

lol.json

Lines changed: 32 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -809,27 +809,40 @@
809809
"data": ""
810810
},
811811
{
812-
"type": "mtd",
812+
"type": "blk",
813813
"data": [
814-
{
815-
"type": "var",
816-
"data": "v",
817-
"source": "v"
818-
},
819-
{
820-
"type": "mtv",
821-
"data": "item",
822-
"parameters": [
823-
{
824-
"type": "num",
825-
"data": 1,
826-
"source": "1"
827-
}
828-
],
829-
"source": "[1]"
830-
}
814+
[
815+
{
816+
"type": "cmd",
817+
"data": "return",
818+
"source": "return (v.[1])"
819+
},
820+
{
821+
"type": "mtd",
822+
"data": [
823+
{
824+
"type": "var",
825+
"data": "v",
826+
"source": "v"
827+
},
828+
{
829+
"type": "mtv",
830+
"data": "item",
831+
"parameters": [
832+
{
833+
"type": "num",
834+
"data": 1,
835+
"source": "1"
836+
}
837+
],
838+
"source": "[1]"
839+
}
840+
],
841+
"source": "(v.[1])"
842+
}
843+
]
831844
],
832-
"source": "(v.[1])"
845+
"source": "(\nreturn (v.[1])\n)"
833846
}
834847
]
835848
}

0 commit comments

Comments
 (0)