mirror of
https://github.com/irmen/prog8.git
synced 2025-02-27 03:29:22 +00:00
fix issues with calling the defer handler
This commit is contained in:
parent
a6159702da
commit
7585b6ef6f
@ -144,7 +144,7 @@ private fun integrateDefers(subdefers: Map<PtSub, List<PtDefer>>, program: PtPro
|
|||||||
newRet.add(popCall)
|
newRet.add(popCall)
|
||||||
val group = PtNodeGroup()
|
val group = PtNodeGroup()
|
||||||
group.add(pushCall)
|
group.add(pushCall)
|
||||||
group.add(PtBuiltinFunctionCall(invokeDefersRoutineName, true, false, DataType.UNDEFINED, ret.position))
|
group.add(PtFunctionCall(ret.definingSub()!!.scopedName+"."+invokeDefersRoutineName, true, DataType.UNDEFINED, ret.position))
|
||||||
group.add(newRet)
|
group.add(newRet)
|
||||||
group.parent = ret.parent
|
group.parent = ret.parent
|
||||||
val idx = ret.parent.children.indexOf(ret)
|
val idx = ret.parent.children.indexOf(ret)
|
||||||
@ -158,7 +158,7 @@ private fun integrateDefers(subdefers: Map<PtSub, List<PtDefer>>, program: PtPro
|
|||||||
val idx = sub.children.indexOfLast { it !is PtDefer }
|
val idx = sub.children.indexOfLast { it !is PtDefer }
|
||||||
val ret = PtReturn(sub.position)
|
val ret = PtReturn(sub.position)
|
||||||
sub.add(idx+1, ret)
|
sub.add(idx+1, ret)
|
||||||
val invokedefer = PtBuiltinFunctionCall(invokeDefersRoutineName, true, false, DataType.UNDEFINED, sub.position)
|
val invokedefer = PtFunctionCall(sub.scopedName+"."+invokeDefersRoutineName, true, DataType.UNDEFINED, sub.position)
|
||||||
sub.add(idx+1, invokedefer)
|
sub.add(idx+1, invokedefer)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ internal fun makePushPopFunctionCalls(value: PtExpression): Pair<PtFunctionCall,
|
|||||||
|
|
||||||
val pushFunc = if(pushFloat) "floats.push" else if(pushWord) "sys.pushw" else "sys.push"
|
val pushFunc = if(pushFloat) "floats.push" else if(pushWord) "sys.pushw" else "sys.push"
|
||||||
val popFunc = if(pushFloat) "floats.pop" else if(pushWord) "sys.popw" else "sys.pop"
|
val popFunc = if(pushFloat) "floats.pop" else if(pushWord) "sys.popw" else "sys.pop"
|
||||||
val pushCall = PtFunctionCall(pushFunc, true, value.type, value.position)
|
val pushCall = PtFunctionCall(pushFunc, true, DataType.UNDEFINED, value.position)
|
||||||
if(pushTypecast!=null) {
|
if(pushTypecast!=null) {
|
||||||
val typecast = PtTypeCast(pushTypecast, value.position).also {
|
val typecast = PtTypeCast(pushTypecast, value.position).also {
|
||||||
it.add(value)
|
it.add(value)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user