forked from NUDT-compiler/nudt-compiler-cpp
parent
310c93feac
commit
affccfb27c
@ -0,0 +1,166 @@
|
||||
========== test/test_case/functional/09_func_defn.sy ==========
|
||||
compUnit
|
||||
|-- decl
|
||||
| `-- varDecl
|
||||
| |-- bType
|
||||
| | `-- Int: int
|
||||
| |-- varDef
|
||||
| | `-- Ident: a
|
||||
| `-- Semi: ;
|
||||
|-- funcDef
|
||||
| |-- funcType
|
||||
| | `-- Int: int
|
||||
| |-- Ident: func
|
||||
| |-- L_PAREN: (
|
||||
| |-- funcFParams
|
||||
| | `-- funcFParam
|
||||
| | |-- bType
|
||||
| | | `-- Int: int
|
||||
| | `-- Ident: p
|
||||
| |-- R_PAREN: )
|
||||
| `-- block
|
||||
| |-- L_BRACE: {
|
||||
| |-- blockItem
|
||||
| | `-- stmt
|
||||
| | |-- lVal
|
||||
| | | `-- Ident: p
|
||||
| | |-- Assign: =
|
||||
| | |-- exp
|
||||
| | | `-- addExp
|
||||
| | | |-- addExp
|
||||
| | | | `-- mulExp
|
||||
| | | | `-- unaryExp
|
||||
| | | | `-- primaryExp
|
||||
| | | | `-- lVal
|
||||
| | | | `-- Ident: p
|
||||
| | | |-- SubOp: -
|
||||
| | | `-- mulExp
|
||||
| | | `-- unaryExp
|
||||
| | | `-- primaryExp
|
||||
| | | `-- DECIMAL_INT: 1
|
||||
| | `-- Semi: ;
|
||||
| |-- blockItem
|
||||
| | `-- stmt
|
||||
| | |-- Return: return
|
||||
| | |-- exp
|
||||
| | | `-- addExp
|
||||
| | | `-- mulExp
|
||||
| | | `-- unaryExp
|
||||
| | | `-- primaryExp
|
||||
| | | `-- lVal
|
||||
| | | `-- Ident: p
|
||||
| | `-- Semi: ;
|
||||
| `-- R_BRACE: }
|
||||
|-- funcDef
|
||||
| |-- funcType
|
||||
| | `-- Int: int
|
||||
| |-- Ident: main
|
||||
| |-- L_PAREN: (
|
||||
| |-- R_PAREN: )
|
||||
| `-- block
|
||||
| |-- L_BRACE: {
|
||||
| |-- blockItem
|
||||
| | `-- decl
|
||||
| | `-- varDecl
|
||||
| | |-- bType
|
||||
| | | `-- Int: int
|
||||
| | |-- varDef
|
||||
| | | `-- Ident: b
|
||||
| | `-- Semi: ;
|
||||
| |-- blockItem
|
||||
| | `-- stmt
|
||||
| | |-- lVal
|
||||
| | | `-- Ident: a
|
||||
| | |-- Assign: =
|
||||
| | |-- exp
|
||||
| | | `-- addExp
|
||||
| | | `-- mulExp
|
||||
| | | `-- unaryExp
|
||||
| | | `-- primaryExp
|
||||
| | | `-- DECIMAL_INT: 10
|
||||
| | `-- Semi: ;
|
||||
| |-- blockItem
|
||||
| | `-- stmt
|
||||
| | |-- lVal
|
||||
| | | `-- Ident: b
|
||||
| | |-- Assign: =
|
||||
| | |-- exp
|
||||
| | | `-- addExp
|
||||
| | | `-- mulExp
|
||||
| | | `-- unaryExp
|
||||
| | | |-- Ident: func
|
||||
| | | |-- L_PAREN: (
|
||||
| | | |-- funcRParams
|
||||
| | | | `-- exp
|
||||
| | | | `-- addExp
|
||||
| | | | `-- mulExp
|
||||
| | | | `-- unaryExp
|
||||
| | | | `-- primaryExp
|
||||
| | | | `-- lVal
|
||||
| | | | `-- Ident: a
|
||||
| | | `-- R_PAREN: )
|
||||
| | `-- Semi: ;
|
||||
| |-- blockItem
|
||||
| | `-- stmt
|
||||
| | |-- Return: return
|
||||
| | |-- exp
|
||||
| | | `-- addExp
|
||||
| | | `-- mulExp
|
||||
| | | `-- unaryExp
|
||||
| | | `-- primaryExp
|
||||
| | | `-- lVal
|
||||
| | | `-- Ident: b
|
||||
| | `-- Semi: ;
|
||||
| `-- R_BRACE: }
|
||||
`-- EOF: <EOF>
|
||||
[DEBUG] CheckVarDef: a base_type: int is_array: 0 dim_count: 0
|
||||
[DEBUG] 符号添加完成: a type_kind: 1 is_array: 0
|
||||
[DEBUG] 进入函数: func 返回类型: int
|
||||
[DEBUG] 添加参数: p type_kind: 1
|
||||
[DEBUG] visitStmt: Assign ExpStmt
|
||||
[DEBUG] CheckExp: p-1
|
||||
[DEBUG] visitUnaryExp: p
|
||||
[DEBUG] visitPrimaryExp: p
|
||||
[DEBUG] visitUnaryExp: 1
|
||||
[DEBUG] visitPrimaryExp: 1
|
||||
[DEBUG] visitStmt: Return ExpStmt
|
||||
[DEBUG] 检测到 return 语句
|
||||
[DEBUG] visitReturnStmtInternal 被调用
|
||||
[DEBUG] 有返回值的 return
|
||||
[DEBUG] CheckExp: p
|
||||
[DEBUG] visitUnaryExp: p
|
||||
[DEBUG] visitPrimaryExp: p
|
||||
[DEBUG] 设置 current_func_has_return_ = true
|
||||
[DEBUG] 函数 func has_return: 1 return_type_is_void: 0
|
||||
[DEBUG] 进入函数: main 返回类型: int
|
||||
[DEBUG] CheckVarDef: b base_type: int is_array: 0 dim_count: 0
|
||||
[DEBUG] 符号添加完成: b type_kind: 1 is_array: 0
|
||||
[DEBUG] visitStmt: Assign ExpStmt
|
||||
[DEBUG] CheckLValue 绑定变量: a
|
||||
[DEBUG] CheckExp: 10
|
||||
[DEBUG] visitUnaryExp: 10
|
||||
[DEBUG] visitPrimaryExp: 10
|
||||
[DEBUG] visitStmt: Assign ExpStmt
|
||||
[DEBUG] CheckLValue 绑定变量: b
|
||||
[DEBUG] CheckExp: func(a)
|
||||
[DEBUG] visitUnaryExp: func(a)
|
||||
[DEBUG] 函数调用: func
|
||||
[DEBUG] CheckFuncCall: func
|
||||
[DEBUG] 处理函数调用参数:
|
||||
[DEBUG] CheckExp: a
|
||||
[DEBUG] visitUnaryExp: a
|
||||
[DEBUG] visitPrimaryExp: a
|
||||
[DEBUG] CheckLValue 绑定变量: a
|
||||
[DEBUG] 检查参数 0: 实参类型 1 形参类型 1
|
||||
[DEBUG] visitStmt: Return ExpStmt
|
||||
[DEBUG] 检测到 return 语句
|
||||
[DEBUG] visitReturnStmtInternal 被调用
|
||||
[DEBUG] 有返回值的 return
|
||||
[DEBUG] CheckExp: b
|
||||
[DEBUG] visitUnaryExp: b
|
||||
[DEBUG] visitPrimaryExp: b
|
||||
[DEBUG] CheckLValue 绑定变量: b
|
||||
[DEBUG] 设置 current_func_has_return_ = true
|
||||
[DEBUG] 函数 main has_return: 1 return_type_is_void: 0
|
||||
[error] [irgen] 变量声明缺少存储槽位: a
|
||||
|
||||
Loading…
Reference in new issue