美文网首页
[Swift]语法树

[Swift]语法树

作者: 欧皇ff | 来源:发表于2020-04-29 11:28 被阅读0次
  • 生成语法书
swiftc -dump-ast main.swift
//输出
import Foundation
       ^
(source_file "main.swift"
  (import_decl range=[main.swift:9:1 - line:9:8] 'Foundation')
  (top_level_code_decl range=[main.swift:11:1 - line:11:22]
    (brace_stmt range=[main.swift:11:1 - line:11:22]
      (call_expr type='()' location=main.swift:11:1 range=[main.swift:11:1 - line:11:22] nothrow arg_labels=_:
        (declref_expr type='(Any..., String, String) -> ()' location=main.swift:11:1 range=[main.swift:11:1 - line:11:1] decl=Swift.(file).print(_:separator:terminator:) function_ref=single)
        (tuple_expr implicit type='(Any..., separator: String, terminator: String)' location=main.swift:11:6 range=[main.swift:11:6 - line:11:22] names='',separator,terminator
          (vararg_expansion_expr implicit type='[Any]' location=main.swift:11:7 range=[main.swift:11:7 - line:11:7]
            (array_expr implicit type='[Any]' location=main.swift:11:7 range=[main.swift:11:7 - line:11:7] initializer=**NULL**
              (erasure_expr implicit type='Any' location=main.swift:11:7 range=[main.swift:11:7 - line:11:7]
                (string_literal_expr type='String' location=main.swift:11:7 range=[main.swift:11:7 - line:11:7] encoding=utf8 value="Hello, World!" builtin_initializer=Swift.(file).String extension.init(_builtinStringLiteral:utf8CodeUnitCount:isASCII:) initializer=**NULL**))))
          (default_argument_expr implicit type='String' location=main.swift:11:6 range=[main.swift:11:6 - line:11:6] default_args_owner=Swift.(file).print(_:separator:terminator:) param=1)
          (default_argument_expr implicit type='String' location=main.swift:11:6 range=[main.swift:11:6 - line:11:6] default_args_owner=Swift.(file).print(_:separator:terminator:) param=2))))))
  • 生成最简洁的SIL代码
swiftc -emit-sil main.swift
  • 生成LLVM IR代码
swiftc -emit-ir main.swift -o main.ll
  • 生成汇编代码
swiftc -emit-assembly main.swift -o main.s

相关文章

网友评论

      本文标题:[Swift]语法树

      本文链接:https://www.haomeiwen.com/subject/jgrqwhtx.html