bugKawa - Bugs: bug #23606, define-simple-class breaks in...

 
 

bug #23606: define-simple-class breaks in conjunction with define-syntax. define-class breaks in a different way still.

Submitted by:  None
Submitted on:  Mon 16 Jun 2008 05:44:54 PM UTC  
 
Category: Code generationSeverity: 3 - Normal
Item Group: Run-time exceptionStatus: Fixed
Privacy: PublicAssigned to: Per Bothner <bothner>
Open/Closed: Closed

Add a New Comment(Rich Markup)
   

You are not logged in

Please log in, so followups can be emailed to you.

 

Fri 20 Jun 2008 06:35:02 PM UTC, comment #2:

I checked in another fix so the define-class case works similarly to the define-simple-class case. I.e. you get the same 'unbound location stepit' in both cases.

Per Bothner <bothner>
Project AdministratorIn charge of this item.
Wed 18 Jun 2008 06:53:32 AM UTC, comment #1:

The "unbound location stepit" is because of macro hygiene: The stepit in the macro is a different identifier than the stepit in the define-agent invocation. Thus the call (stepit) is resolved in the global Scheme environment - where it is unbound.

"To see what's happening, I compiled to a class file. On examination, it appears that in the second situation, 'step' is not compiling to a method -- it's compiling to a field."

I don't see any sign of that.

I'll take a look at the popType error.

Per Bothner <bothner>
Project AdministratorIn charge of this item.
Mon 16 Jun 2008 05:44:54 PM UTC, original submission:

If I create an object like this:

(define-simple-class <bar> ()
((step)
(stepit))
((stepit)
(write "bar works great")))

(set! b (<bar>))
(b:step)

... everything works fine. But if I take part of it and move it into a macro using define-syntax like this:

(define-syntax define-agent
(syntax-rules ()
((_ agent-name rest ...)
(define-simple-class agent-name ()
((step)
(stepit))
rest ... ))))

(define-agent <foo>
((stepit)
(write "foo doesn't work")))

(set! f (<foo>))
(f:step)

I get the following error:

unbound location stepit
at gnu.mapping.Location.get(Location.java:67)
at foo.step(stdin:21)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
at java.lang.reflect.Method.invoke(Method.java:585)
at gnu.expr.PrimProcedure.apply(PrimProcedure.java:254)
at gnu.mapping.CallContext.runUntilDone(CallContext.java:251)
at gnu.expr.ModuleExp.evalModule(ModuleExp.java:309)
at kawa.Shell.run(Shell.java:275)
at kawa.Shell.run(Shell.java:186)
at kawa.Shell.run(Shell.java:167)
at kawa.repl.main(repl.java:870)

To see what's happening, I compiled to a class file. On examination, it appears that in the second situation, 'step' is not compiling to a method -- it's compiling to a field. That wouldn't be right.

I then tried using define-class instead of define-simple-class:

(define-syntax define-agent-2
(syntax-rules ()
((_ agent-name rest ...)
(define-class agent-name ()
((step)
(stepit))
rest ... ))))

(define-agent-2 <baz>
((stepit)
(write "baz doesn't work")))

(set! bz (<baz>))
(bz:step)

... but when I do that I get a compile error:

internal compile error - caught java.lang.Error: emitInvokeXxx static flag mis-match method.flags=1
gnu.bytecode.CodeAttr.emitInvokeMethod(CodeAttr.java:1304)
gnu.bytecode.CodeAttr.emitInvokeStatic(CodeAttr.java:1355)
gnu.expr.ClassExp.compileMembers(ClassExp.java:615)
gnu.expr.ClassInitializer.<init>(ClassInitializer.java:16)
gnu.expr.ClassExp.compileSetField(ClassExp.java:758)
gnu.expr.SetExp.compile(SetExp.java:170)
gnu.expr.Expression.compileNotePosition(Expression.java:157)
gnu.expr.Expression.compileWithPosition(Expression.java:143)
gnu.expr.LambdaExp.compileBody(LambdaExp.java:1586)
gnu.expr.Compilation.generateBytecode(Compilation.java:2028)
gnu.expr.Compilation.process(Compilation.java:1902)
gnu.expr.ModuleInfo.loadByStages(ModuleInfo.java:315)
gnu.expr.ModuleExp.evalToClass(ModuleExp.java:73)
gnu.expr.ModuleExp.evalModule(ModuleExp.java:228)
kawa.Shell.run(Shell.java:275)
kawa.Shell.run(Shell.java:186)
kawa.Shell.run(Shell.java:167)
kawa.repl.main(repl.java:870)

I then tried just using define-class directly without define-syntax:

(define-class quux ()
((step)
(stepit))
((stepit)
(write "quux doesn't work")))

(set! q (<quux>))
(q:step)

... and interestingly enough I get ANOTHER DIFFERENT compile-time error:

internal compile error - caught java.lang.Error: popType called with empty stack quux$class.step(quux)java.lang.Object
gnu.bytecode.CodeAttr.popType(CodeAttr.java:316)
gnu.bytecode.CodeAttr.emitInvokeMethod(CodeAttr.java:1316)
gnu.expr.PrimProcedure.compileInvoke(PrimProcedure.java:543)
gnu.expr.PrimProcedure.compile(PrimProcedure.java:525)
gnu.expr.PrimProcedure.compile(PrimProcedure.java:494)
gnu.expr.ApplyExp.compile(ApplyExp.java:171)
gnu.expr.ApplyExp.compile(ApplyExp.java:110)
gnu.expr.Expression.compileNotePosition(Expression.java:157)
gnu.expr.Expression.compileWithPosition(Expression.java:143)
gnu.expr.LambdaExp.compileBody(LambdaExp.java:1586)
gnu.expr.ClassExp.compileMembers(ClassExp.java:525)
gnu.expr.ClassInitializer.<init>(ClassInitializer.java:16)
gnu.expr.ClassExp.compileSetField(ClassExp.java:758)
gnu.expr.SetExp.compile(SetExp.java:170)
gnu.expr.Expression.compileNotePosition(Expression.java:157)
gnu.expr.Expression.compileWithPosition(Expression.java:143)
gnu.expr.LambdaExp.compileBody(LambdaExp.java:1586)
gnu.expr.Compilation.generateBytecode(Compilation.java:2028)
gnu.expr.Compilation.process(Compilation.java:1902)
gnu.expr.ModuleInfo.loadByStages(ModuleInfo.java:315)
gnu.expr.ModuleExp.evalToClass(ModuleExp.java:73)
gnu.expr.ModuleExp.evalModule(ModuleExp.java:228)
kawa.Shell.run(Shell.java:275)
kawa.Shell.run(Shell.java:186)
kawa.Shell.run(Shell.java:167)
kawa.repl.main(repl.java:870)

Anonymous

 

(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach File(s):
   
   
Comment:
   

No files currently attached

 

Depends on the following items: None found

Items that depend on this one: None found

 

Carbon-Copy List
  • -unavailable- added by bothner (Posted a comment)
  •  

    Do you think this task is very important?
    If so, you can click here to add your encouragement to it.
    This task has 0 encouragements so far.

    Only logged-in users can vote.

     

    Please enter the title of George Orwell's famous dystopian book (it's a date):

     

     

    Follow 3 latest changes.

    Date Changed By Updated Field Previous Value => Replaced By
    Fri 20 Jun 2008 06:35:02 PM UTCbothnerStatusNone=>Fixed
      Open/ClosedOpen=>Closed
    Wed 18 Jun 2008 06:53:32 AM UTCbothnerAssigned toNone=>bothner

    Back to the top


    Powered by Savane 3.1-cleanup1