Skip to content

Commit 890f3a4

Browse files
committed
Syntax: remove more redundant enum prefixes
* remove prefixes in merged code * remove prefixes in conditional expressions
1 parent bf7842b commit 890f3a4

File tree

8 files changed

+34
-36
lines changed

8 files changed

+34
-36
lines changed

analyser/module_analyser_member.c2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ fn QualType Analyser.analyseMemberExpr(Analyser* ma, Expr** e_ptr, u32 side) {
160160
}
161161
//FunctionDecl* fd = (FunctionDecl*)ef);
162162
// Note: not always CallExpr here, but use CallKind enum since same meaning
163-
ck = (valtype == NValue) ? CallKind.StaticTypeFunc : CallKind.TypeFunc;
163+
ck = (valtype == NValue) ? StaticTypeFunc : TypeFunc;
164164
d = ef;
165165
baseType = ef.getType();
166166
if (!ma.scope.checkAccess(d, loc)) return QualType_Invalid;

ast/ast_evaluator.c2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -557,7 +557,7 @@ fn Cont FallthroughStmt.eval(FallthroughStmt* s, Evaluator* sf) { return Normal;
557557

558558
fn Cont LabelStmt.eval(LabelStmt* s, Evaluator* sf) {
559559
Stmt* s1 = s.getStmt();
560-
return s1 ? s1.eval(sf) : Cont.Normal;
560+
return s1 ? s1.eval(sf) : Normal;
561561
}
562562

563563
fn Cont GotoStmt.eval(GotoStmt* s, Evaluator* sf) {

ast/unary_operator.c2

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,7 @@ public type UnaryOperator struct @(opaque) {
5757

5858
public fn UnaryOperator* UnaryOperator.create(ast_context.Context* c, SrcLoc loc, UnaryOpcode kind, Expr* inner) {
5959
UnaryOperator* e = c.alloc(sizeof(UnaryOperator));
60-
e.base.init(UnaryOperator, loc, 0, 0, kind <= PreDec,
61-
kind == Deref ? ValType.LValue : ValType.RValue);
60+
e.base.init(UnaryOperator, loc, 0, 0, kind <= PreDec, kind == Deref ? LValue : RValue);
6261
e.base.base.unaryOperatorBits.kind = kind;
6362
e.inner = inner;
6463
#if AstStatistics

ast/utils.c2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,7 @@ public fn void setTypePublicUsed(QualType qt) {
307307
}
308308

309309
public fn BuiltinKind getNativeKind() {
310-
return globals.wordsize == 8 ? BuiltinKind.UInt64 : BuiltinKind.UInt32;
310+
return globals.wordsize == 8 ? UInt64 : UInt32;
311311
}
312312

313313
Color col_Stmt = Color.Bmagenta;

common/yaml/yaml_tokenizer.c2

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ fn void Tokenizer.lex_quoted_string(Tokenizer* t, Token* result, char delim) {
253253
}
254254
t.cur++;
255255
}
256-
result.kind = (delim == '"') ? TokenKind.Double_Quoted_Scalar : TokenKind.Single_Quoted_Scalar;
256+
result.kind = (delim == '"') ? Double_Quoted_Scalar : Single_Quoted_Scalar;
257257
result.text_idx = t.data.add_text(start, (u32)(t.cur - start));
258258
t.cur++; // skip terminating delimiter
259259
}

compiler/c2recipe_parser.c2

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ fn void Parser.lex(Parser* p, Token* result) {
273273
// lex until whitespace
274274
const char* start = p.cur;
275275
while (*p.cur && !ctype.isspace(*p.cur)) p.cur++;
276-
result.kind = p.new_line ? Kind.File : Kind.Text;
276+
result.kind = p.new_line ? File : Text;
277277
if (*p.cur == 0) result.kind = Eof;
278278
p.new_line = false;
279279
u32 len = (u32)(p.cur - start);
@@ -329,7 +329,7 @@ fn void Parser.lex(Parser* p, Token* result) {
329329
const char* start = p.cur;
330330
while (*p.cur && !ctype.isspace(*p.cur)) p.cur++;
331331
// TODO check EOF
332-
result.kind = p.new_line ? Kind.File : Kind.Text;
332+
result.kind = p.new_line ? File : Text;
333333
p.new_line = false;
334334
u32 len = (u32)(p.cur - start);
335335
result.value = p.pool.add(start, len, true);
@@ -518,7 +518,7 @@ fn void Parser.parsePlugin(Parser* p, bool is_global) {
518518
p.consumeToken();
519519

520520
u32 options = 0;
521-
if (p.token.kind == Kind.PluginOptions) {
521+
if (p.token.kind == PluginOptions) {
522522
options = p.token.value;
523523
p.consumeToken();
524524
}
@@ -750,7 +750,7 @@ fn void Parser.parseTarget(Parser* p) {
750750
p.consumeToken();
751751
p.expect(Text, "expect export");
752752

753-
while (p.token.kind == Kind.Text) {
753+
while (p.token.kind == Text) {
754754
p.target.addExport(p.token.value);
755755
p.consumeToken();
756756
}
@@ -787,7 +787,7 @@ fn void Parser.parseTarget(Parser* p) {
787787
p.target.addLib(libname, kind);
788788
p.consumeToken();
789789

790-
while (p.token.kind == Kind.Text) p.consumeToken();
790+
while (p.token.kind == Text) p.consumeToken();
791791
break;
792792
case AsmFile:
793793
if (files_started) p.error("$asm must come before files");
@@ -849,7 +849,7 @@ fn void Parser.parseBackend(Parser* p) {
849849
}
850850

851851
fn void Parser.parseBackEndOptions(Parser* p) {
852-
while (p.token.kind == Kind.Text) {
852+
while (p.token.kind == Text) {
853853
const char* option = p.pool.idx2str(p.token.value);
854854
switch (option) {
855855
case "no-build":

parser/c2_parser.c2

Lines changed: 21 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -292,7 +292,7 @@ fn void Parser.parseModule(Parser* p) {
292292
p.consumeToken();
293293
if (p.tok.kind == KW_extern) {
294294
p.consumeToken();
295-
if (p.tok.kind == Kind.StringLiteral) {
295+
if (p.tok.kind == StringLiteral) {
296296
const char* extern_name = p.pool.idx2str(p.tok.text_idx);
297297
if (p.tok.text_len != 1 || *extern_name != 'C') {
298298
p.error("unsupported extern module language tag '%s'", extern_name);
@@ -600,7 +600,7 @@ fn bool Parser.parseFunctionParams(Parser* p, DeclList* params, bool is_public,
600600
}
601601

602602
// Accept (void) argument list in c_mode
603-
if (p.tokenizer.c_mode && p.tok.kind == Kind.KW_void && p.peekToken(1) == Kind.RParen) {
603+
if (p.tokenizer.c_mode && p.tok.kind == KW_void && p.peekToken(1) == RParen) {
604604
p.consumeToken();
605605
p.consumeToken();
606606
return false;
@@ -758,17 +758,17 @@ fn void Parser.parseVarDecl(Parser* p, bool is_public) {
758758
}
759759
p.consumeToken();
760760

761-
if (p.tok.kind == Kind.LParen) {
761+
if (p.tok.kind == LParen) {
762762
if (!p.tokenizer.c_mode) {
763763
p.error("function definitions require the 'fn' keyword");
764764
}
765765
p.parseFunctionDecl2(name, loc, is_public, &ref);
766766
return;
767767
}
768768

769-
if (p.tok.kind == Kind.Dot) {
770-
if (p.peekToken(1) == Kind.Identifier) {
771-
if (p.peekToken(2) == Kind.LParen) {
769+
if (p.tok.kind == Dot) {
770+
if (p.peekToken(1) == Identifier) {
771+
if (p.peekToken(2) == LParen) {
772772
// Either a function definition or an init call
773773
if (!p.tokenizer.c_mode)
774774
p.error("global variables cannot have an init call");
@@ -888,32 +888,32 @@ fn Kind Parser.convertCType(Parser* p) {
888888
case KW_char:
889889
if (has_signed == 1) {
890890
has_signed = 0;
891-
kind = Kind.KW_i8;
891+
kind = KW_i8;
892892
} else
893893
if (has_unsigned == 1) {
894894
has_unsigned = 0;
895-
kind = Kind.KW_u8;
895+
kind = KW_u8;
896896
} else {
897-
kind = Kind.KW_char;
897+
kind = KW_char;
898898
}
899899
break;
900900
case KW_int:
901901
break;
902902
case KW_ssize_t:
903-
kind = Kind.KW_isize;
903+
kind = KW_isize;
904904
break;
905905
case KW_size_t:
906-
kind = Kind.KW_usize;
906+
kind = KW_usize;
907907
break;
908908
case KW_float:
909-
kind = Kind.KW_f32;
909+
kind = KW_f32;
910910
break;
911911
case KW_double:
912912
if (has_long == 1) {
913913
// long double -> double
914914
has_long = 0;
915915
}
916-
kind = Kind.KW_f64;
916+
kind = KW_f64;
917917
break;
918918
case KW_short:
919919
has_short++;
@@ -931,18 +931,18 @@ fn Kind Parser.convertCType(Parser* p) {
931931
skip--; // no C type, keep last qualifier
932932
break;
933933
}
934-
if (kind == Kind.KW_i32) {
934+
if (kind == KW_i32) {
935935
if (has_short == 1) {
936-
kind = Kind.KW_i16;
936+
kind = KW_i16;
937937
has_short = 0;
938938
} else
939939
if (has_long == 2) {
940-
kind = Kind.KW_i64;
940+
kind = KW_i64;
941941
has_long = 0;
942942
} else
943943
if (has_long == 1) {
944944
if (getWordSize() == 8)
945-
kind = Kind.KW_i64;
945+
kind = KW_i64;
946946
has_long = 0;
947947
}
948948
if (has_signed == 1) {
@@ -1131,15 +1131,15 @@ fn void Parser.parseExternDecl(Parser* p) {
11311131
bool was_interface = p.is_interface;
11321132
p.is_interface = true;
11331133

1134-
if (p.tok.kind == Kind.StringLiteral) {
1134+
if (p.tok.kind == StringLiteral) {
11351135
if (p.tok.text_len != 1 || *p.pool.idx2str(p.tok.text_idx) != 'C') {
11361136
p.error("extern must be followed by \"C\" and a block");
11371137
}
11381138
p.consumeToken();
11391139
p.tokenizer.c_mode++; // must set before consuming the token
1140-
p.expectAndConsume(Kind.LBrace);
1141-
while (p.tok.kind != Kind.RBrace) {
1142-
if (p.tok.kind == Kind.Eof)
1140+
p.expectAndConsume(LBrace);
1141+
while (p.tok.kind != RBrace) {
1142+
if (p.tok.kind == Eof)
11431143
p.error("unterminated extern \"C\" block");
11441144
p.parseTopLevel();
11451145
}

parser/c2_parser_expr.c2

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -278,7 +278,7 @@ fn Expr* Parser.parseCastExpr(Parser* p, bool /*isUnaryExpr*/, bool /*isAddrOfOp
278278
p.consumeToken();
279279
break;
280280
case 3: // FloatLiteral
281-
BuiltinKind kind = p.tok.suffix_F ? BuiltinKind.Float32 : BuiltinKind.Float64;
281+
BuiltinKind kind = p.tok.suffix_F ? Float32 : Float64;
282282
res = p.builder.actOnFloatLiteral(p.tok.loc, p.tok.len, p.tok.float_value, p.tok.getRadix(), kind);
283283
p.consumeToken();
284284
break;
@@ -702,8 +702,7 @@ fn Expr* Parser.parseEnumMinMax(Parser* p, bool is_min) {
702702
u32 src_len = p.tok.loc + 1 - loc;
703703
p.expectAndConsume(RParen);
704704

705-
return p.builder.actOnBuiltinExpr(loc, src_len, expr,
706-
is_min ? BuiltinExprKind.EnumMin : BuiltinExprKind.EnumMax);
705+
return p.builder.actOnBuiltinExpr(loc, src_len, expr, is_min ? EnumMin : EnumMax);
707706
}
708707

709708
fn Expr* Parser.parseOffsetOfExpr(Parser* p) {

0 commit comments

Comments
 (0)