obj.class returning unexpected values #10

Open
treed opened this Issue Jul 16, 2009 · 8 comments

Comments

Projects
None yet
2 participants
Contributor

treed commented Jul 16, 2009

.class on Proc is not Proc. It's probably CardinalProc, but I haven't looked. Unsure how to go about this one. (Shows up in proc.t.)

Contributor

treed commented Jul 16, 2009

This is also evident in range.t

Contributor

treed commented Jul 21, 2009

Okay. I've done some research now. Took me some time because I had to fix a bug first to even try this. .class on a Proc is "Proc()", but only if you declare it as a proc. A bare proc (literal?) is a Sub, which has no .class.

A Range is coming across as CardinalRange, though. Unsure whether the better way to fix this is to simply rename the class, or get .class to lie.

Collaborator

tene commented Jul 25, 2009

  1. hll_map Sub
  2. Now that Cardinal is in its own .HLL, you should be able to get rid of all the crap CardinalFoo names, because no more namespace conflicts with core parrot types.
Contributor

treed commented Jul 25, 2009

The last issue is that it'll be appending () to the names, which I think is solveable by adding to_s to the Metaclass that other metaclasses inherit from. Then having Object.class use that.

Contributor

treed commented Jul 25, 2009

Okay, wow. hll_mapping Sub resulted in cardinal throwing sigbus for any attempt at execution. Did I do something particularly weird here?

diff --git a/src/classes/Proc.pir b/src/classes/Proc.pir
index 0073b1f..5034529 100644
--- a/src/classes/Proc.pir
+++ b/src/classes/Proc.pir
@@ -20,9 +20,14 @@ Perform initializations and create the Proc class
 .namespace ['Proc']

 .sub 'onload' :anon :init :load
-    .local pmc cardinalmeta
+    .local pmc cardinalmeta, core_type, hll_type, interp
     $P0 = get_hll_global ['CardinalObject'], '!CARDINALMETA'
     cardinalmeta = $P0.'new_class'('Proc', 'parent'=>'CardinalObject', 'attr'=>'!block')
+
+    core_type = get_class 'Sub'
+    hll_type = get_class 'Proc'
+    interp = getinterp
+    interp.'hll_map'(core_type, hll_type)
 .end

 .sub 'get_bool' :vtable
Contributor

treed commented Jul 25, 2009

Could be that Proc doesn't actually subclass Sub, but it still shouldn't be crashing.

Contributor

treed commented Jul 25, 2009

Issue #27 concerns a rewrite of Proc which should help with this.

Contributor

treed commented Aug 8, 2009

Alright, so here's the updated status:

Waiting on #27 for the Proc rewrite.
Waiting on #34 for the s/CardinalFoo/Foo/
Waiting on #35 for the "Foo()" to "Foo" thing.

Once those are done, this issue can be closed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment