I'm using a DSL to return a closure expression and it's accepting it (after some minor modifications to the compiler pod) but now it gets me to this wonderful looking error:
sys::Err: java.lang.VerifyError: (class: fan/couroutine_test/co1, method: doCall signature: ()V) Falling off the end of the code
I created a gist with my changes to the compiler and my code to output the closure.
Void test1() {
x := Coroutine<| echo("This is a test!"); return |>
x()
}
Clearly there's still some processing to be done on this closure, maybe I need to add a return statement or something special like that?
brianFri 2 Mar 2012
Closures are by far the most complicated aspect of the compiler and have to be run through many steps.
It would be a lot simpler if you could have the closure be an argument to your Dsl. Do you think you could do this:
Void test1() {
x := Coroutine<||> { echo("This is a test!"); return }
x()
}
We can always clean-up syntax, but then the closure would just be a normal closure processed by compiler. Your Coroutine would have to evaluate to something that took an it-block as an argument.
dobesvSat 3 Mar 2012
Hi brian,
Unfortunately I want to transform the closure into a state machine of some sort, I'm not using it verbatim. I don't think having it passed as a parameter would make it feasible to do that.
dobesvSat 3 Mar 2012
Actually I seem to have the closure part working now, I just needed to call the Normalize phase on the closure and make sure it was added to compiler.closures
I updated the gist with the new version, in case anyone is curious.
Now onto the hard part of transforming the closure into a state machine of some sort!
dobesv Fri 2 Mar 2012
I'm using a DSL to return a closure expression and it's accepting it (after some minor modifications to the compiler pod) but now it gets me to this wonderful looking error:
I created a gist with my changes to the compiler and my code to output the closure.
https://gist.github.com/1959419
The source I'm using to test is currently:
Clearly there's still some processing to be done on this closure, maybe I need to add a return statement or something special like that?
brian Fri 2 Mar 2012
Closures are by far the most complicated aspect of the compiler and have to be run through many steps.
It would be a lot simpler if you could have the closure be an argument to your Dsl. Do you think you could do this:
We can always clean-up syntax, but then the closure would just be a normal closure processed by compiler. Your Coroutine would have to evaluate to something that took an it-block as an argument.
dobesv Sat 3 Mar 2012
Hi brian,
Unfortunately I want to transform the closure into a state machine of some sort, I'm not using it verbatim. I don't think having it passed as a parameter would make it feasible to do that.
dobesv Sat 3 Mar 2012
Actually I seem to have the closure part working now, I just needed to call the Normalize phase on the closure and make sure it was added to compiler.closures
I updated the gist with the new version, in case anyone is curious.
Now onto the hard part of transforming the closure into a state machine of some sort!