stage1 支持指针运算 提供新的类型检查计算
This commit is contained in:
1 parent
be41a82d55
commit
06f3884c30
12 files changed
+572
-321
No files matched your search
+6
-4
@@ -50,6 +50,8 @@ const char *spl_unary_op_name(spl_unary_op_t op) {
|
||||
return "bitnot";
|
||||
case SPL_UNARY_OP_ADDRESS:
|
||||
return "addr";
|
||||
case SPL_UNARY_OP_DEREF:
|
||||
return "deref";
|
||||
default:
|
||||
return "?";
|
||||
}
|
||||
@@ -840,7 +842,7 @@ static spl_ast_node_ref_t parse_type_base(parser_t *p) {
|
||||
}
|
||||
|
||||
/* 内建类型和普通路径 */
|
||||
if (bt->type == TOK_IDENT) {
|
||||
if (bt->type == TOK_IDENT || bt->type == KW_BOOL) {
|
||||
const char *name = bt->lexeme;
|
||||
usize len = bt->len;
|
||||
/* 内建类型关键字 */
|
||||
@@ -1353,7 +1355,7 @@ static spl_ast_node_ref_t parse_postfix(parser_t *p) {
|
||||
expr = ref;
|
||||
} else if (next->type == TOK_MUL) {
|
||||
advance(p);
|
||||
spl_ast_node_ref_t ref = mk_unary(p, t, SPL_UNARY_OP_ADDRESS, expr);
|
||||
spl_ast_node_ref_t ref = mk_unary(p, t, SPL_UNARY_OP_DEREF, expr);
|
||||
expr = ref;
|
||||
} else {
|
||||
SPL_FATAL(next, "expected identifier or '*' after '.'");
|
||||
@@ -1416,13 +1418,13 @@ static spl_ast_node_ref_t parse_primary(parser_t *p) {
|
||||
case TOK_INT_LITERAL: {
|
||||
advance(p);
|
||||
spl_ast_node_ref_t ref = new_node(p, SPL_AST_EXPR_INT_LIT, t);
|
||||
node_at(p->ast, ref)->int_lit.val = parse_int_literal(t);
|
||||
node_at(p->ast, ref)->int_lit.bits = parse_int_literal(t); // FIXME
|
||||
return ref;
|
||||
}
|
||||
case TOK_FLOAT_LITERAL: {
|
||||
advance(p);
|
||||
spl_ast_node_ref_t ref = new_node(p, SPL_AST_EXPR_FLOAT_LIT, t);
|
||||
node_at(p->ast, ref)->float_lit.val = parse_float_literal(t);
|
||||
node_at(p->ast, ref)->float_lit.bits = parse_float_literal(t); // FIXME
|
||||
return ref;
|
||||
}
|
||||
case TOK_CHAR_LITERAL: {
|
||||
|
||||
Reference in new issue
Block a user