Ticket #216 (closed bug: fixed)

Opened 13 years ago

Last modified 13 years ago

can't override the RPA HLL map from PIR?

Reported by: coke Owned by: whiteknight
Priority: normal Milestone:
Component: imcc Version:
Severity: high Keywords: tcl blocker
Cc: Language:
Patch status: Platform: all

Description (last modified by coke) (diff)

tcl currently subclasses ResizablePMCArray in a PMC, so that this:

.HLL 'Tcl'
.namespace []

.sub '&list'
  .param pmc argv :slurpy
  .return(argv)
.end

when invoked, is given an argv of type TclList instead of ResizablePMCArray

Trying to convert that PMC to a PIR subclass, I find I can't get that override working. Here's some sample PIR to demonstrate the problem:

.HLL 'Foo'
.HLL_map 'ResizablePMCArray' = 'RPA'

.sub main
  $P1 = get_class 'ResizablePMCArray'
  $P0 = subclass $P1, 'RPA'
  joe('a','b','c')
.end


.sub joe
  .param pmc argv :slurpy
  $S0 = typeof argv
  say $S0
.end

That prints out ResizablePMCArray instead of RPA.

Change History

Changed 13 years ago by coke

  • description modified (diff)

Changed 13 years ago by whiteknight

  • owner set to whiteknight
  • platform set to all
  • component changed from none to imcc

Changed 13 years ago by whiteknight

Okay, I think I've found where the problem is. in compilers/imcc/imcc.y:953, the .HLL_map code calls pmc_type() using the name provided in the .HLL_map directive. Unfortunately, when the directive is called, the type hasn't yet been registered.

IMCC calls pmc_type() which returns 0 as the type number of the HLL type. When we look up the type in the HLL registry later, this obviously fails and the type id number for ResizablePMCArray is returned instead.

I'm not entirely sure how to get around this yet. I'll think about it.

Changed 13 years ago by whiteknight

As a work around, I suggest you use this mechanism that was recommended to me by NotFound++. This works properly for classes generated at runtime (Which .HLL_map does not do).

.HLL 'Foo'

.sub main
  $P1 = get_class 'ResizablePMCArray'
  $P0 = subclass $P1, 'RPA'
  $P2 = getinterp
  $P2.'hll_map'($P1, $P0)
  joe('a','b','c')
.end

.sub joe
  .param pmc argv :slurpy
  $S0 = typeof argv
  say $S0
.end

Changed 13 years ago by whiteknight

  • status changed from new to closed
  • resolution set to fixed

I'm going to close this ticket now, since we have the .'hll_map'() method to resolve this problem. The real issue is the behavior of .HLL_map, which doesn't do what you think it should do. We can create a second ticket to resolve that issue since it's separate.

Note: See TracTickets for help on using tickets.