简体   繁体   English

F#编译器是单通道编译器吗?

[英]Is F# compiler a single-pass compiler?

I look around the web and only find 1 mention about F# using one pass compilation in a personal blog, not in official docs. 我浏览网页,只在个人博客中使用一次通过汇编 ,而不是在官方文档中找到关于F#的 1个提及。

From my experiences so far it seems that F# uses one pass compilation such that you can only reference types or functions which have been defined either earlier in the file you're currently in or appear in a file which is specified earlier in the compilation order. 根据我迄今为止的经验,似乎F#使用一次传递编译,这样您只能引用先前在您当前所在文件中定义的类型或函数,或者出现在编译顺序中先前指定的文件中。

Is this statement true? 这个陈述是真的吗?

You'd need to define what a "pass" means in order to answer this question. 您需要定义“通过”的含义才能回答这个问题。

Many compilers are what are termed multi "phase" which means the distinct stages in the transformation of the source text into executable machine code or IL code. 许多编译器被称为多“阶段”,这意味着将源文本转换为可执行机器代码或IL代码的不同阶段。

I think the term "pass" is outdated and refers to very early compilers that may have read the actual source files more than once as part of their processing, real commercial grade compilers almost certainly don't do this or need to do this. 我认为术语“通过”已经过时,并且指的是非常早期的编译器可能已经多次读取实际源文件作为其处理的一部分,真正的商业级编译器几乎肯定不会这样做或需要这样做。

For example I worked on a PL/1 (aka PL/I) compiler for Windows many years ago and that went through several phases, these were: 例如,我多年前在Windows上使用PL / 1(也就是PL / I)编译器,经历了几个阶段,它们是:

  • parse - consume source file(s) and create parse tree 解析 - 使用源文件并创建解析树
  • declarations - resolve identifiers in parse tree to declared names 声明 - 将解析树中的标识符解析为声明的名称
  • optimize - analyze the parse tree and restructure it optimally. 优化 - 分析解析树并以最佳方式对其进行重组。
  • codegen - analyze the parse tree and generate an OBJ file. codegen - 分析解析树并生成OBJ文件。

Most compilers today pretty much do this (whether in distinct phases or not - but they do the same work). 今天大多数编译器都是这样做的(无论是否处于不同的阶段 - 但他们做同样的工作)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM