Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

obj.class returning unexpected values #10

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

obj.class returning unexpected values #10

treed opened this issue Jul 16, 2009 · 8 comments

Comments

@treed
Copy link
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.)

@treed
Copy link
Contributor Author

treed commented Jul 16, 2009

This is also evident in range.t

@treed
Copy link
Contributor Author

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.

@tene
Copy link
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.

@treed
Copy link
Contributor Author

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.

@treed
Copy link
Contributor Author

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

@treed
Copy link
Contributor Author

treed commented Jul 25, 2009

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

@treed
Copy link
Contributor Author

treed commented Jul 25, 2009

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

@treed
Copy link
Contributor Author

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
Projects
None yet
Development

No branches or pull requests

2 participants