加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

scala编译阶段的顺序是什么?

发布时间:2020-12-16 09:43:27 所属栏目:安全 来源:网络整理
导读:我想提高我对Scala编译阶段的看法。我知道在编译器中必须发生某些事情,但是并不知道它们发生的顺序以及顺序如何影响我的编程。 我正确的说,以下是编译器完整的列表吗? 解析程序 类型检查 擦除 隐式转换 生成字节码 优化 如果是,这些阶段的顺序是什么?
我想提高我对Scala编译阶段的看法。我知道在编译器中必须发生某些事情,但是并不知道它们发生的顺序以及顺序如何影响我的编程。

我正确的说,以下是编译器完整的列表吗?

>解析程序
>类型检查
>擦除
>隐式转换
>生成字节码
>优化

如果是,这些阶段的顺序是什么?
这个顺序如何影响程序员,尤其是类型级程序员?

解决方法

您可以通过使用scalac -Xshow-阶段来查看阶段,顺序和说明。

在2.11中,使用-Xshow-stages -Ydebug来显示启用和禁用的阶段。

这是它的2.10.0:

? scalac -Xshow-phases

             phase name  id  description
             ----------  --  -----------
                 parser   1  parse source into ASTs,perform simple desugaring
                  namer   2  resolve names,attach symbols to named trees
         packageobjects   3  load package objects
                  typer   4  the meat and potatoes: type the trees
                 patmat   5  translate match expressions
         superaccessors   6  add super accessors in traits and nested classes
             extmethods   7  add extension methods for inline classes
                pickler   8  serialize symbol tables
              refchecks   9  reference/override checking,translate nested objects
           selectiveanf  10  
           selectivecps  11  
                uncurry  12  uncurry,translate function values to anonymous classes
              tailcalls  13  replace tail calls by jumps
             specialize  14  @specialized-driven class and method specialization
          explicitouter  15  this refs to outer pointers,translate patterns
                erasure  16  erase types,add interfaces for traits
            posterasure  17  clean up erased inline classes
               lazyvals  18  allocate bitmaps,translate lazy vals into lazified defs
             lambdalift  19  move nested functions to top level
           constructors  20  move field definitions into constructors
                flatten  21  eliminate inner classes
                  mixin  22  mixin composition
                cleanup  23  platform-specific cleanups,generate reflective calls
                  icode  24  generate portable intermediate code
                inliner  25  optimization: do inlining
inlineExceptionHandlers  26  optimization: inline exception handlers
               closelim  27  optimization: eliminate uncalled closures
                    dce  28  optimization: eliminate dead code
                    jvm  29  generate JVM bytecode
               terminal  30  The last phase in the compiler chain

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读