1.tokens

"int"                   "int"

<SPACES>                " "

<IDENTIFIER>            "global_a"

<SPACES>                " "

"="                     "="

<SPACES>                " "

<INTEGER>               "5"

";"                     ";"

<SPACES>                "\r\n"

"long"                  "long"

<SPACES>                " "

<IDENTIFIER>            "global_b"

";"                     ";"

<SPACES>                "\r\n"

"char"                  "char"

<SPACES>                " "

"*"                     "*"

<SPACES>                " "

<IDENTIFIER>            "global_c"

<SPACES>                " "

"="                     "="

<SPACES>                " "

"\""                    "\"HelloWorld!\""

";"                     ";"

<SPACES>                "\r\n"

"int"                   "int"

"["                     "["

<INTEGER>               "5"

"]"                     "]"

<SPACES>                " "

<IDENTIFIER>            "global_array"

";"                     ";"

<SPACES>                "\r\n"

"struct"                "struct"

<SPACES>                " "

<IDENTIFIER>            "point"

<SPACES>                " "

<IDENTIFIER>            "global_struct"

";"                     ";"

<SPACES>                "\r\n"

"struct"                "struct"

<SPACES>                " "

<IDENTIFIER>            "point"

"{"                     "{"

<SPACES>                "\r\n   "

"int"                   "int"

<SPACES>                " "

<IDENTIFIER>            "x"

";"                     ";"

<SPACES>                "\r\n   "

"int"                   "int"

<SPACES>                " "

<IDENTIFIER>            "y"

";"                     ";"

<SPACES>                "\r\n"

"}"                     "}"

";"                     ";"

<SPACES>                "\r\n"

"int"                   "int"

<SPACES>                " "

<IDENTIFIER>            "func"

"("                     "("

"int"                   "int"

<SPACES>                " "

<IDENTIFIER>            "m"

","                     ","

<SPACES>                " "

"int"                   "int"

<SPACES>                " "

<IDENTIFIER>            "n"

")"                     ")"

"{"                     "{"

<SPACES>                "\r\n   "

"int"                   "int"

<SPACES>                " "

<IDENTIFIER>            "local_a"

<SPACES>                " "

"="                     "="

<SPACES>                " "

<INTEGER>               "4"

";"                     ";"

<SPACES>                "\r\n   "

<IDENTIFIER>            "local_a"

<SPACES>                " "

"="                     "="

<SPACES>                " "

<IDENTIFIER>            "m"

";"                     ";"

<SPACES>                "\r\n   "

<IDENTIFIER>            "local_a"

<SPACES>                " "

"="                     "="

<SPACES>                " "

<IDENTIFIER>            "n"

";"                     ";"

<SPACES>                "\r\n   "

"return"                "return"

<SPACES>                " "

<IDENTIFIER>            "local_a"

";"                     ";"

<SPACES>                "\r\n"

"}"                     "}"

<SPACES>                "\r\n"

"int"                   "int"

<SPACES>                " "

<IDENTIFIER>            "main"

"("                     "("

"int"                   "int"

<SPACES>                " "

<IDENTIFIER>            "argc"

","                     ","

<SPACES>                " "

"char"                  "char"

"*"                     "*"

"*"                     "*"

<SPACES>                " "

<IDENTIFIER>            "argv"

")"                     ")"

"{"                     "{"

<SPACES>                "\r\n   "

<IDENTIFIER>            "func"

"("                     "("

<INTEGER>               "2"

","                     ","

<INTEGER>               "3"

")"                     ")"

";"                     ";"

<SPACES>                "\r\n   "

"return"                "return"

<SPACES>                " "

<INTEGER>               "0"

";"                     ";"

<SPACES>                "\r\n"

"}"                     "}"

<SPACES>                "\r\n"

<EOF>                   ""

2.抽象语法树

<<AST>> (helloworld.cb:1)

variables:

<<DefinedVariable>> (helloworld.cb:1)

name: "global_a"

isPrivate: false

typeNode: int

initializer:

<<IntegerLiteralNode>> (helloworld.cb:1)

typeNode: int

value: 5

<<DefinedVariable>> (helloworld.cb:2)

name: "global_b"

isPrivate: false

typeNode: long

initializer: null

<<DefinedVariable>> (helloworld.cb:3)

name: "global_c"

isPrivate: false

typeNode: char*

initializer:

<<StringLiteralNode>> (helloworld.cb:3)

value: "HelloWorld!"

<<DefinedVariable>> (helloworld.cb:4)

name: "global_array"

isPrivate: false

typeNode: int[5]

initializer: null

<<DefinedVariable>> (helloworld.cb:5)

name: "global_struct"

isPrivate: false

typeNode: struct point

initializer: null

functions:

<<DefinedFunction>> (helloworld.cb:10)

name: "func"

isPrivate: false

params:

parameters:

<<Parameter>> (helloworld.cb:10)

name: "m"

typeNode: int

<<Parameter>> (helloworld.cb:10)

name: "n"

typeNode: int

body:

<<BlockNode>> (helloworld.cb:10)

variables:

<<DefinedVariable>> (helloworld.cb:11)

name: "local_a"

isPrivate: false

typeNode: int

initializer:

<<IntegerLiteralNode>> (helloworld.cb:11)

typeNode: int

value: 4

stmts:

<<ExprStmtNode>> (helloworld.cb:12)

expr:

<<AssignNode>> (helloworld.cb:12)

lhs:

<<VariableNode>> (helloworld.cb:12)

name: "local_a"

rhs:

<<VariableNode>> (helloworld.cb:12)

name: "m"

<<ExprStmtNode>> (helloworld.cb:13)

expr:

<<AssignNode>> (helloworld.cb:13)

lhs:

<<VariableNode>> (helloworld.cb:13)

name: "local_a"

rhs:

<<VariableNode>> (helloworld.cb:13)

name: "n"

<<ReturnNode>> (helloworld.cb:14)

expr:

<<VariableNode>> (helloworld.cb:14)

name: "local_a"

<<DefinedFunction>> (helloworld.cb:16)

name: "main"

isPrivate: false

params:

parameters:

<<Parameter>> (helloworld.cb:16)

name: "argc"

typeNode: int

<<Parameter>> (helloworld.cb:16)

name: "argv"

typeNode: char**

body:

<<BlockNode>> (helloworld.cb:16)

variables:

stmts:

<<ExprStmtNode>> (helloworld.cb:17)

expr:

<<FuncallNode>> (helloworld.cb:17)

expr:

<<VariableNode>> (helloworld.cb:17)

name: "func"

args:

<<IntegerLiteralNode>> (helloworld.cb:17)

typeNode: int

value: 2

<<IntegerLiteralNode>> (helloworld.cb:17)

typeNode: int

value: 3

<<ReturnNode>> (helloworld.cb:18)

expr:

<<IntegerLiteralNode>> (helloworld.cb:18)

typeNode: int

value: 0

3.中间代码

<<IR>> (helloworld.cb:1)

variables:

<<DefinedVariable>> (helloworld.cb:1)

name: global_a

isPrivate: false

type: int

initializer:

<<Int>>

type: INT32

value: 5

<<DefinedVariable>> (helloworld.cb:2)

name: global_b

isPrivate: false

type: long

initializer: null

<<DefinedVariable>> (helloworld.cb:3)

name: global_c

isPrivate: false

type: char*

initializer:

<<Str>>

type: INT32

entry: net.loveruby.cflat.entity.ConstantEntry@13fd745

<<DefinedVariable>> (helloworld.cb:4)

name: global_array

isPrivate: false

type: int[5]

initializer: null

<<DefinedVariable>> (helloworld.cb:5)

name: global_struct

isPrivate: false

type: struct point

initializer: null

functions:

<<DefinedFunction>> (helloworld.cb:10)

name: func

isPrivate: false

type: int(int, int)

body:

<<Assign>> (helloworld.cb:11)

lhs:

<<Addr>>

type: INT32

entity: local_a

rhs:

<<Int>>

type: INT32

value: 4

<<Assign>> (helloworld.cb:12)

lhs:

<<Addr>>

type: INT32

entity: local_a

rhs:

<<Var>>

type: INT32

entity: m

<<Assign>> (helloworld.cb:13)

lhs:

<<Addr>>

type: INT32

entity: local_a

rhs:

<<Var>>

type: INT32

entity: n

<<Return>> (helloworld.cb:14)

expr:

<<Var>>

type: INT32

entity: local_a

<<DefinedFunction>> (helloworld.cb:16)

name: main

isPrivate: false

type: int(int, char**)

body:

<<ExprStmt>> (helloworld.cb:17)

expr:

<<Call>>

type: INT32

expr:

<<Addr>>

type: INT32

entity: func

args:

<<Int>>

type: INT32

value: 2

<<Int>>

type: INT32

value: 3

<<Return>> (helloworld.cb:18)

expr:

<<Int>>

type: INT32

value: 0

4.汇编代码

.file "helloworld.cb"

.data

.globl global_a

.align 4

.type global_a,@object

.size global_a,4

global_a:

.long 5

.globl global_c

.align 4

.type global_c,@object

.size global_c,4

global_c:

.long .LC0

.section .rodata

.LC0:

.string "HelloWorld!"

.text

.globl func

.type func,@function

func:

pushl %ebp

movl %esp, %ebp

subl $4, %esp

movl $4, %eax

movl %eax, -4(%ebp)

movl 8(%ebp), %eax

movl %eax, -4(%ebp)

movl 12(%ebp), %eax

movl %eax, -4(%ebp)

movl -4(%ebp), %eax

jmp .L0

.L0:

movl %ebp, %esp

popl %ebp

ret

.size func,.-func

.globl main

.type main,@function

main:

pushl %ebp

movl %esp, %ebp

movl $3, %eax

pushl %eax

movl $2, %eax

pushl %eax

call func

addl $8, %esp

movl $0, %eax

jmp .L1

.L1:

movl %ebp, %esp

popl %ebp

ret

.size main,.-main

.comm global_b,4,4

.comm global_array,20,4

.comm global_struct,8,8

《深入理解Android虚拟机内存管理》示例程序编译阶段生成的各种语法树完整版的更多相关文章

  1. 自己写的书《深入理解Android虚拟机内存管理》,不出版只是写着玩

    百度网盘地址:https://pan.baidu.com/s/1jI4xZgE 我给起的书名叫做<深入理解Android虚拟机内存管理>.本书分为两个部分,前半部分主要是我对Linux0. ...

  2. 深入理解Java虚拟机—内存管理机制

    前面说过了类的加载机制,里面讲到了类的初始化中时用到了一部分内存管理的知识,这里让我们来看下Java虚拟机是如何管理内存的. 先让我们来看张图 有些文章中对线程隔离区还称之为线程独占区,其实是一个意思 ...

  3. 理解Android虚拟机体系结构

    1 什么是Dalvik虚拟机 Dalvik是Google公司自己设计用于Android平台的Java虚拟机,它是Android平台的重要组成部分,支持dex格式(Dalvik Executable)的 ...

  4. 理解Android虚拟机体系结构(转)

    1 什么是Dalvik虚拟机 Dalvik是Google公司自己设计用于Android平台的Java虚拟机,它是Android平台的重要组成部分,支持dex格式(Dalvik Executable)的 ...

  5. Android 之 内存管理-查看内存泄露(三)

    概述 在android的开发中,要时刻主要内存的分配和垃圾回收,因为系统为每一个dalvik虚拟机分配的内存是有限的,在google的G1中,分配的最大堆大小只有16M,后来的机器一般都为24M,实在 ...

  6. 深入理解C语言内存管理

    之前在学Java的时候对于Java虚拟机中的内存分布有一定的了解,但是最近在看一些C,发现居然自己对于C语言的内存分配了解的太少. 问题不能拖,我这就来学习一下吧,争取一次搞定. 在任何程序设计环境及 ...

  7. Android Dalvikvm 内存管理理解

    网上非常多文件介绍了 jvm 内存管理的理论,但在 Dalvikvm 中,到底是怎样实现的. 这几天猛看了 Dalvikvm 的源码,说一下我的理解: 在大层面上讲跟理论一样,jvm 把内存分成了一些 ...

  8. 深入理解java虚拟机---java虚拟机内存管理(五)

    1.深入理解java虚拟机 总图: 1.线程共享区: 2.线程独占区: 1.程序计数器 理解为当前线程锁执行的字节码的行号指示器,程序计数器没有内存异常错误.

  9. davlik虚拟机内存管理之一——内存分配

    转载自http://www.miui.com/thread-74715-1-1.html dalvik虚拟机是Google在Android平台上的Java虚拟机的实现,内存管理是dalvik虚拟机中的 ...

随机推荐

  1. JavaScript初步学习----基本使用,简单事件,修改样式,数据类型

    JavaScript基本使用 JavaScript原名叫livescript,是一门动态类型,弱类型基于原型的脚本语言   用于页面特效,前后交替,后台开发(node)   JavaScript写在s ...

  2. Centos 7开启网卡打开DHCP自动获取IP

    在Windows10上安装了CentOS7的Hyper-V虚拟机. 虽然配置了可访问外网的网卡(Win8.1 Hyper-V 共享本机IP上网),但是默认安装的CentOS是没有开启配置网卡信息的,也 ...

  3. Postgres 数据库字符集更改 ERROR: new encoding (UTF8) is incompatible

    https://blog.csdn.net/hkyw000/article/details/52817422 http://www.cnblogs.com/taosim/articles/438329 ...

  4. PHP中echo和print的区别

    这篇文章主要介绍了PHP中echo和print的区别,针对二者使用中常见的用法区别进行了较为深入的总结与分析,需要的朋友可以参考下 一般来说,PHP中动态输出HTML内容,是通过print 和 ech ...

  5. WGS84坐标系图层转火星坐标系(是整个图层转哟,不是转单点坐标)

    开篇唠叨(着急的略过) 大天朝“火星坐标系”小科普:是一种国家保密插件,对真实坐标系统进行人为的加偏处理,将真实的坐标加密成虚假的坐标,加密后的坐标被称为火星坐标系统.所有的电子地图所有的导航设备,都 ...

  6. jquery easyui datagrid实现数据改动

    1.单击选中待改动行 watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQv/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA= ...

  7. Android中检測字符编码(GB2312,ASCII,UTF8,UNICODE,TOTAL——ENCODINGS)方法(一)

    package com.android.filebrowser;   import java.io.*; import java.net.*;   public class FileEncodingD ...

  8. JS0基础学习笔记(1)

    为了须要,最近開始学习JS相关知识.基本的方式是通过看视频以及查阅相关手冊.并动手实践,亲手写出每一个小案例,以下是相关代码(每一个案例用分隔线隔开). <!DOCTYPE html> & ...

  9. React-Router 中文简明教程(上)

    概述 说起 前端路由,如果你用过前端 MV* 框架构建 SPA 应用(单页面应用),对此一定不陌生. 传统开发中的 路由,是由服务端根据不同的用户请求地址 URL,返回不同内容的页面,而前端路由则将这 ...

  10. RCF:一个相当不错的C++分布式RPC框架

    RCF(远程调用框架)是一个可以移植的C++进程间通信框架,使用C++语言特性,提供了一个简单高效的编写分布式C++软件的途径.RCF利用编译时多态清晰分开了接口和实现. 和传统的RPC框架如CORB ...