You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Namespace 'namespace '
|-Typedecl 'class' X
\-Typedecl 'class' X
\-Class 'class X'
\-Fundecl 'void (X *)' m
\-Parameter 'X *' this
Currently, we are building this representation the following way:
We create a Typedecl node with the name X and the type class (Typedecl(X) : class) for the forward declaration (the init of this Typedecl is null).
We create a new Typedecl node for the definition, which has the same name and type (Typedecl(X) : class) but the init field is the actual class type with all the info from the definiton.
This approach is problematic, for the following reason. We get different types for the forward declaration, and the definition.
The type of the forward declaration: AsType(Typedecl(X))
The type of the definition: class X (from the init field of the second Typedecl)
Ideally, we want both the forward declaration and the definition to have the same type. One option would be, to also create an empty class for the forward declaration, but in that case we would either end up having two class types of the same name, or (in case they both refer to the same type that has all its details filled) we cannot tell which declaration is a forward declaration and which one is a definition.
Alternatively, I could also use AsType(Typedecl(X)) for the definition to have the same type, but it would also end up producing different types as we are talking about different Typedecl nodes.
How should we solve this? Do I miss something?
The text was updated successfully, but these errors were encountered:
To my understanding the Type of the declaration (Typedecl) itself is not the Class node but rather the built in 'class' primitive. If you're referring to usages of the Type in other declarations such as Var or Parameter before and after the definition I think we have had a similar discussion in the past. I'm not sure if we came to a final decision on which approach to use but I think there was more leaning towards following the semantics of the language and referring to an incomplete type (AsType(Typedecl(X))) rather than referring to the defined class (or creating an empty class). The user would then use a call a free function to compare the equality of types (which you would have to do for your proposal as well, give different Class nodes are used).
This was a while ago so Gaby or Gor may have a better recollection of the discussion.
Consider the following code:
It will produce the following IPR:
Currently, we are building this representation the following way:
Typedecl
node with the nameX
and the typeclass
(Typedecl(X) : class
) for the forward declaration (theinit
of thisTypedecl
is null).Typedecl
node for the definition, which has the same name and type (Typedecl(X) : class
) but theinit
field is the actual class type with all the info from the definiton.This approach is problematic, for the following reason. We get different types for the forward declaration, and the definition.
The type of the forward declaration:
AsType(Typedecl(X))
The type of the definition:
class X
(from the init field of the second Typedecl)Ideally, we want both the forward declaration and the definition to have the same type. One option would be, to also create an empty class for the forward declaration, but in that case we would either end up having two class types of the same name, or (in case they both refer to the same type that has all its details filled) we cannot tell which declaration is a forward declaration and which one is a definition.
Alternatively, I could also use
AsType(Typedecl(X))
for the definition to have the same type, but it would also end up producing different types as we are talking about differentTypedecl
nodes.How should we solve this? Do I miss something?
The text was updated successfully, but these errors were encountered: