This is the mail archive of the
kawa@sourceware.org
mailing list for the Kawa project.
Re: Google Summer of Code
- From: Andrea Bernardini <andrebask at gmail dot com>
- To: kawa at sourceware dot org
- Date: Wed, 26 Mar 2014 11:00:49 +0100
- Subject: Re: Google Summer of Code
- Authentication-results: sourceware.org; auth=none
- References: <20140305094242 dot 349492d0 at debian-andrebask> <5316F956 dot 8040303 at gmail dot com> <20140305132208 dot 3081f8dc at debian-andrebask> <m2lhwo48vi dot fsf at gmail dot com> <5319088C dot 5060401 at bothner dot com> <7B118191-4144-4937-B679-89392D5463EE at theptrgroup dot com> <20140316012026 dot 4e0ebfef at debian-andrebask> <53269580 dot 8040205 at bothner dot com> <20140320204856 dot 5aa0b4d3 at debian-andrebask> <532BAA5F dot 3000606 at bothner dot com>
Il giorno Thu, 20 Mar 2014 19:56:31 -0700
Per Bothner <per@bothner.com> ha scritto:
> On 03/20/2014 12:48 PM, Andrea Bernardini wrote:
> > Il giorno Sun, 16 Mar 2014 23:26:08 -0700
> > Per Bothner <per@bothner.com> ha scritto:
>
> It is certainly possible, but using a type-specific Case Syntax class
> doesn't seem practical.
Ok. I'm not using the Case Syntax class any more.
> That's the right basic idea. However, 'clauses' is not an expression;
> it's not a set of expressions. Perhaps best to try something similar
> to how TryExpr contains a set of CatchClauses.
Right, that implementation was wrong, as a clause is of the form
((datum*) exp+).
Now I'm able to create a CaseExp in the Scheme code, containing an
array of CaseClause. Each case clause contains an array of Object
(the datum*) and an Expression (the clause body).
I also tried to implement the compile method in CaseExp, but i got this
error:
java.lang.Error: popType called with empty stack
at gnu.bytecode.CodeAttr.popType(CodeAttr.java:442)
at gnu.bytecode.SwitchState.switchValuePushed(SwitchState.java:76)
at gnu.bytecode.CodeAttr.startSwitch(CodeAttr.java:2505)
Code:
>public void compile(Compilation comp, Target target) {
> System.out.print("Compiling CaseExp\n");
>
> CodeAttr code = comp.getCode();
> key.compile(comp, target);
> SwitchState sw = code.startSwitch();
>
> for (int i = 0; i < clauses.length; i++) {
> clauses[i].compile(sw, comp,
> target);
>}
> if (elseClause != null)
> elseClause.compile(sw, comp, target);
>}
I think the problem is that the key Expression is not found on the
stack when startSwitch is called. How can I push the key on the stack?
Looking at the IfExp.compile implementation I found a similar code:
>ConditionalTarget ctarget
> = new ConditionalTarget(trueLabel, falseLabel, language);
>test.compile(comp, ctarget);
>code.emitIfThen();
Do I have to create a particular Target to compile the case key?
>
> If CaseClause extends LetExp in the same way as CatchClause, then
> you can translate '=> expression' as something like
> '(let ((dummy (match ...))) (expression dummy))'
I choose not to use a LetExp as we have no bindings in the case clauses.
To avoid writing a lot of code here, I published the git repository:
bit.ly/1g0ajsl
Andrea