AttrContext
info属性类型为AttrContext或AttrContextEnv。主要看AtrContext即可。定义了如下关键参数:
/** Contains information specific to the attribute and enter * passes, to be used in place of the generic field in environments. * */ public class AttrContext { /** The scope of local symbols. */ public Scope scope = null; /** The number of enclosing `static' modifiers. */ public int staticLevel = 0; /** Is this an environment for a this(...) or super(...) call? */ public boolean isSelfCall = false; /** Are we evaluating the selector of a `super' or type name? */ public boolean selectSuper = false; /** Are arguments to current function applications boxed into an array for varargs? */ public boolean varArgs = false; /** A list of type variables that are all-quantifed in current context. */ public List<Type> typeVars = List.nil(); /** A record of the lint/SuppressWarnings currently in effect */ public Lint lint; /** The variable whose initializer is being attributed * useful for detecting self-references in variable initializers */ public Symbol enclVar = null; // ... }
获取这个AtrContext的对象可调用dup()方法,如下:
/** Duplicate this context, replacing scope field and copying all others. */ public AttrContext dup(Scope scope) { AttrContext info = new AttrContext(); info.scope = scope; info.staticLevel = staticLevel; info.isSelfCall = isSelfCall; info.selectSuper = selectSuper; info.varArgs = varArgs; info.typeVars = typeVars; info.lint = lint; info.enclVar = enclVar; return info; }
调用的地方如下截图。
另外一个dup()方法代码如下:
/** Duplicate this context, copying all fields. */ public AttrContext dup() { return dup(scope); }
调用的地方如下截图。
1、staticLevel属性
只有变量、方法或者静态块时才会对staticLevel进行加1操作,对于静态类时不对此值进行操作。
不能在静态或者非静态方法或者静态/非静态块中出现static修饰的变量与类,如:
Object o = new Object(){ // The field b cannot be declared static in a non-static inner type, // unless initialized with a constant expression static int b = 2; }; class InnerD{ // The member type InnerE cannot be declared static; // static types can only be declared in static or top level types static class InnerE{} } static{ static int a = 1; static class InnerA{} } public void methodA(){ static int a = 1; static class InnerA{} }
2、selectSuper属性
英文注释:Are we evaluating the selector of a `super' or type name?
举例如下:
public class TestScope { class A{ public void t() throws CloneNotSupportedException{ TestScope.super.clone(); } } }
当在Attr类的visitSelect中对TestScope.super进行标记时,则这个属性会设置为true
3、typeVars属性
这个属性写入的地方如下:
读取值的地方如下:
AttrContext的更多相关文章
- Annotate类
在Annotate类中有个Annotator接口,定义如下: /** A client that has annotations to add registers an annotator, * th ...
- Attr.checkId()方法
1.符号sym是TYP02 举个例子,如下: package bazola; class Point { // ... } class Tree<A> { class AttrVisito ...
- Scope及其子类介绍
之前写的文章: 关于作用域范围Scope Scope及相关的子类如下: 同时有些Scope还继承了Scope.ScopeListener类,如下: 1.StarImportScope及ImportSc ...
- Check类的validate方法解读
此方法的实现如下: public void validate(JCTree tree, Env<AttrContext> env, boolean checkRaw) { Validato ...
- Javac之Environment
关于Env的源代码如下: /** A class for environments, instances of which are passed as * arguments to tree visi ...
- Javac之关于方法的调用1
方法的调用从Attr类的visitApply()方法进入,如下: /** Visitor method for method invocations. * NOTE: The method part ...
- javac的Resolve类解读
方法1:isInitializer() /** An environment is an "initializer" if it is a constructor or * an ...
- JDK8在泛型类型推导上的变化
概述 JDK8升级,大部分问题可能在编译期就碰到了,但是有些时候比较蛋疼,编译期没有出现问题,但是在运行期就出了问题,比如今天要说的这个话题,所以大家再升级的时候还是要多测测再上线,当然JDK8给我们 ...
随机推荐
- event对象的clientX,offsetX,screenX,pageX和offsetTop,offsetHeight等等
先总结下区别: event.clientX.event.clientY 鼠标相对于浏览器窗口可视区域的X,Y坐标(窗口坐标),可视区域不包括工具栏和滚动条.IE事件和标准事件都定义了这2个属性 eve ...
- ubuntu16.4中开启vncserver进行远程桌面
使用x11vnc作为vncserver端 1 安装x11vnc $ sudo apt-get update $ sudo apt-get install x11vnc 2 生成密码 $ x11vnc ...
- noip第10课作业
1. 统计不同类型字符出现次数 [问题描述] 输入一个字符串(假设长度不超过1000个字符),统计其中大写,小写,数字,其他字符出现的次数. [样例输入]Hello,what are you ...
- MFC中开发ocx控件,html容器收不到ocx的事件Event
问题背景: MFC开发ocx控件,主窗口就是ctrl类,主窗口类中调度接口和事件映射添加,执行OK,外部html容器中接收事件成功,如下: ctrl.h中声明事件映射函数 void EVTPENSIG ...
- matlab toolboxes 大全
MATLAB Toolboxes top (Top) Audio - Astronomy - BiomedicalInformatics - Chemometrics - Chaos - Chemi ...
- Nginx an upstream response is buffered to a temporary file
1.错误日志:warn:an upstream response is buffered to a temporary file 解决办法:增加fastcgi_buffers 8 4K; fa ...
- WebAPI Token 验证
WebAPI Token 验证 登录端 //HttpContext.Current.Session.Timeout = 10; ////生成Ticket //FormsAuthenticationTi ...
- C# 获取每一个像素点的RGB
int x, y; x = e.X; y = e.Y; Color pixel = MyImage.GetPixel(x, y); byte R = pixel.R; byte G = pixel.G ...
- winform 批量控件取值赋值
以前写winform 最多写几个文本框,最近需要入录一个人员信息,那好几十个字段,一下子干蒙了,这要是一个个取值赋值都写到明天了,于是就自己写了个方法,也不是什么高大上的,就是很简单很普通很low的方 ...
- php重写session的存储机制
重写session的存储机制 Session数据区 默认以 文件的形式存储与服务器操作系统临时目录中! 当 session数据区过多时,文件形式的存储,操作速度变慢.磁盘的读写(IO,input/ou ...