| ... | ... | @@ -1490,6 +1490,20 @@ static OnePossibleValue type_val_resolve_has_one_possible_value(CodeGen *g, ZigV |
| 1490 | 1490 | } |
| 1491 | 1491 | |
| 1492 | 1492 | ZigType *analyze_type_expr(CodeGen *g, Scope *scope, AstNode *node) { |
| 1493 | Error err; |
| 1494 | // Hot path for simple identifiers, to avoid unnecessary memory allocations. |
| 1495 | if (node->type == NodeTypeSymbol) { |
| 1496 | Buf *variable_name = node->data.symbol_expr.symbol; |
| 1497 | if (buf_eql_str(variable_name, "_")) |
| 1498 | goto abort_hot_path; |
| 1499 | ZigType *primitive_type; |
| 1500 | if ((err = get_primitive_type(g, variable_name, &primitive_type))) { |
| 1501 | goto abort_hot_path; |
| 1502 | } else { |
| 1503 | return primitive_type; |
| 1504 | } |
| 1505 | abort_hot_path:; |
| 1506 | } |
| 1493 | 1507 | ZigValue *result = analyze_const_value(g, scope, node, g->builtin_types.entry_type, |
| 1494 | 1508 | nullptr, UndefBad); |
| 1495 | 1509 | if (type_is_invalid(result->type)) |