English 中文(简体)
声明的汇编阶段
原标题:declaration capture phase in compilation

诸如C和C++等语言依赖先期申报,以解决在类型或功能申报方面的紧急情况。 在C#中,由于申报的捕获阶段分两个阶段,因此不需要再作说明;一个显示符号名称,另一个实际进行标识施工。

是否有文号名称捕获阶段的标准名称? i 假设声明的捕获将留待解决宣言中所有标志的传统阶段。

问题回答

C#汇编者实际上拥有一个申报阶段,其构成符号表。 The Roslyn C#汇编者并不十分清楚,因为并非所有工作都是在大的冲积阶段进行的。 相反,每一符号都是按要求单独建造的。 然而,在将 s类的类型和成员申报转换成符号方面,仍然有步骤。 具有约束力的阶段在逻辑上之后,在提及类型和成员名称时,使用已申报的文号表加以解决。

我认为,这两个阶段是所谓的。

  1. parsing
  2. binding

假释是同义词。 具有约束力的是将含义分配给识别符号和名称。

C++也可以这样做。 只是定义不在于此。

我发现,埃里克·利佩尔担任这一博客职务,对我所期待的是什么作了最佳解释:

The C# language does not require that declarations occur before usages, which has two impacts, again, on the user and on the compiler writer. The impact on the user is that you don’t get to recompile just the IL that changed when you change a file; the whole assembly is recompiled. Fortunately the C# compiler is sufficiently fast that this is seldom a huge issue. (Another way to look at this is that the “granularity” of recompilation in C# is at the project level, not the file level.)

The impact on the compiler writer is that we have to have a “two pass” compiler. In the first pass, we look for declarations and ignore bodies. Once we have gleaned all the information from the declarations that we would have got from the headers in C++, we take a second pass over the code and generate the IL for the bodies.

......

We then do a "declaration" pass where we make notes about the location of every namespace and type declaration in the program. At this point we re done looking at the source code for the first phase; every subsequent pass is over the set of "symbols" deduced from the declarations.

We then do a pass where we verify that all the types declared have no cycles in their base types. We need to do this first because in every subsequent pass we need to be able to walk up type hierarchies without having to deal with cycles.

http://blogs.msdn.com/b/ericfallert/archive/02/04/how-many-passes.aspx” rel=“nofollow”http://blogs.msdn.com/b/ericfallert/archive/204/how-many-passes.aspx





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签