在Javac的源代码中,从类型到符号到其类型的遍历的目的是什么?
在javac
的源代码中,我看到了此形式的成语:
Type t = ...;
// Now let's say I want to, say, get its supertype. The idiom seems to be:
Object o = t.tsym.type.supertype_field;
// ...rather than:
Object o = t.supertype_field;
我知道某些type
s and 符号
s s是循环依赖性。也就是说,例如,每个非编码> clasStype 具有classSymbol
,每个非eRror classSymbol
具有clasStype < /code>,即使从逻辑上类型的符号之前(在构造期间,所有内容都被扭曲以彼此指向)。
我还朦胧地理解,在编译过程中可能存在各种错误,因此给定的类型
实际上可能是errortype
,我想可能具有与之关联的不同信息。
通过说t.tsym.type.something
而不仅仅是t.something
,可以实现什么样的规范化?
如果(减少心理负载)我假装错误永远不存在(因此,clasStype
s具有classSymbol
s,反之亦然),什么时候有实质性的差异访问T.Something
和t.tsym.type.something
?
有一个具体示例共享/class/com/com/sun/tools/javac/code/types.java#l2531“ rel =“ nofollow noreferrer”> supertype(type)
method 。
In the source code for javac
, I have seen idioms of this form:
Type t = ...;
// Now let's say I want to, say, get its supertype. The idiom seems to be:
Object o = t.tsym.type.supertype_field;
// ...rather than:
Object o = t.supertype_field;
I understand that certain Type
s and Symbol
s are circular dependencies. That is, every non-error ClassType
, for example, has a ClassSymbol
, and every non-error ClassSymbol
has a ClassType
, even though logically types precede symbols (during construction everything is twiddled to point to each other).
I also understand hazily that there may be various errors during compilation such that a given Type
may actually be an ErrorType
and I suppose may have different information associated with it.
What kind of canonicalizing is being accomplished by saying t.tsym.type.something
rather than just t.something
?
If (to reduce mental load) I pretend that errors never exist (so all, say, ClassType
s have ClassSymbol
s and vice versa), when is there a substantive difference between accessing t.something
and t.tsym.type.something
?
There is a concrete example in the supertype(Type)
method.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论