[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Pnet-developers] Problems in ternary with upcasting
From: |
Rhys Weatherley |
Subject: |
Re: [Pnet-developers] Problems in ternary with upcasting |
Date: |
Fri, 04 Jul 2003 20:08:40 +1000 |
User-agent: |
KMail/1.4.3 |
On Friday 04 July 2003 06:31 pm, Gopal V wrote:
> Any suggestions anyone ?
Currently, "ValidateStack" checks to see if A can be coerced to B, or B can be
coerced to A for a type-O validation (verify_branch.c). This is how it is
defined in the C# language, but it looks like the runtime engine needs to be
a little more flexible.
The verifier probably needs to be changed to search up the object hierarchy
for a common parent type. It shouldn't be too hard to do. Something like
this:
TryCommonType(A, B) ->
if A can be coerced to B, return B
if B does not have a parent, then return "Object"
otherwise TryCommonType(A, parent(B))
CommonType(A, B) ->
A1 = TryCommonType(A, B)
A2 = TryCommonType(B, A)
if A1 can be coerced to A2, then return A1
otherwise return A2
Note: the last step of CommonType returns the lowest type in the hierarchy
that is common. Otherwise it will always return "Object" (if we assume that
"Object" is top-most in the hierarchy).
It may also be necessary to check for interface inheritance. I'm not too sure
on that front. Some experimentation will be required probably.
Cheers,
Rhys.