Skip to content

Commit c75c31a

Browse files
committed
Remove trait support
1 parent 651ee71 commit c75c31a

File tree

12 files changed

+13
-488
lines changed

12 files changed

+13
-488
lines changed

CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ set(TEA_HEADER_FILES
8484
include/tea_stmt.h
8585
include/tea_fn.h
8686
include/tea_struct.h
87-
include/tea_trait.h
87+
8888
)
8989

9090
set(TEA_SOURCE_FILES
@@ -99,7 +99,7 @@ set(TEA_SOURCE_FILES
9999
src/tea_stmt.c
100100
src/tea_fn.c
101101
src/tea_struct.c
102-
src/tea_trait.c
102+
103103
)
104104

105105
add_library(tea_lang

examples/018_traits.tea

Lines changed: 0 additions & 161 deletions
This file was deleted.

include/tea_ast.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,7 @@ typedef enum {
4141
TEA_N_FIELD_ACC,
4242
TEA_N_OPT_TYPE,
4343
TEA_N_NULL,
44-
TEA_N_TRAIT,
45-
TEA_N_TRAIT_METHOD,
46-
TEA_N_TRAIT_IMPL,
47-
TEA_N_TRAIT_IMPL_ITEM,
44+
4845
} tea_node_type_t;
4946

5047
typedef struct tea_node {

include/tea_scope.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,7 @@ typedef struct {
88
rtl_list_entry_t fns;
99
rtl_list_entry_t nfns;
1010
rtl_list_entry_t structs;
11-
rtl_list_entry_t traits;
12-
rtl_list_entry_t impls;
11+
1312
rtl_list_entry_t vars;
1413
} tea_ctx_t;
1514

include/tea_trait.h

Lines changed: 0 additions & 33 deletions
This file was deleted.

src/tea_ast.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -158,14 +158,7 @@ const char *tea_node_type_name(const tea_node_type_t type)
158158
return "OPTIONAL_TYPE";
159159
case TEA_N_NULL:
160160
return "NULL";
161-
case TEA_N_TRAIT:
162-
return "TRAIT";
163-
case TEA_N_TRAIT_METHOD:
164-
return "TRAIT_METHOD";
165-
case TEA_N_TRAIT_IMPL:
166-
return "TRAIT_IMPL";
167-
case TEA_N_TRAIT_IMPL_ITEM:
168-
return "TRAIT_IMPL_ITEM";
161+
169162
default:
170163
return "UNKNOWN";
171164
}

src/tea_fn.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#include "tea_expr.h"
44
#include "tea_stmt.h"
55
#include "tea_struct.h"
6-
#include "tea_trait.h"
6+
77

88
#include <stdlib.h>
99
#include <string.h>
@@ -271,11 +271,7 @@ tea_val_t tea_eval_fn_call(tea_ctx_t *ctx, tea_scope_t *scp,
271271
function_name = field_token->buf;
272272
function = tea_ctx_find_fn(&struct_declaration->fns, function_name);
273273

274-
// If not found in struct methods, try trait methods
275-
if (!function) {
276-
function =
277-
tea_resolve_trait_method(ctx, variable->val.obj->type, function_name);
278-
}
274+
279275
} else {
280276
const tea_tok_t *token = node->tok;
281277
if (token) {

src/tea_interp.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@ void tea_interp_init(tea_ctx_t *ctx, const char *fname)
1212
rtl_list_init(&ctx->fns);
1313
rtl_list_init(&ctx->nfns);
1414
rtl_list_init(&ctx->structs);
15-
rtl_list_init(&ctx->traits);
16-
rtl_list_init(&ctx->impls);
15+
1716
rtl_list_init(&ctx->vars);
1817
}
1918

src/tea_stmt.c

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#include "tea_expr.h"
33
#include "tea_fn.h"
44
#include "tea_struct.h"
5-
#include "tea_trait.h"
5+
66

77
#include <stdlib.h>
88

@@ -405,10 +405,6 @@ bool tea_exec(tea_ctx_t *ctx, tea_scope_t *scp, const tea_node_t *node,
405405
return tea_interp_struct_decl(ctx, node);
406406
case TEA_N_IMPL_BLK:
407407
return tea_interp_impl_blk(ctx, node);
408-
case TEA_N_TRAIT:
409-
return tea_interp_trait_decl(ctx, node);
410-
case TEA_N_TRAIT_IMPL:
411-
return tea_interp_trait_impl(ctx, node);
412408
case TEA_N_PROG:
413409
case TEA_N_STMT:
414410
case TEA_N_FN_ARGS:

src/tea_token.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ static const tea_kw_entry_t tea_keywords[] = {
1111
{ "break", TEA_TOKEN_BREAK }, { "continue", TEA_TOKEN_CONTINUE },
1212
{ "struct", TEA_TOKEN_STRUCT }, { "impl", TEA_TOKEN_IMPL },
1313
{ "return", TEA_TOKEN_RETURN }, { "new", TEA_TOKEN_NEW },
14-
{ "null", TEA_TOKEN_NULL }, { "trait", TEA_TOKEN_TRAIT },
15-
{ "for", TEA_TOKEN_FOR }, { NULL, 0 }
14+
{ "null", TEA_TOKEN_NULL }, { NULL, 0 }
1615
};
1716

1817
static bool equals(const char *a, const char *b, const int n)
@@ -66,10 +65,7 @@ const char *tea_tok_name(const int token_type)
6665
return "RETURN";
6766
case TEA_TOKEN_NEW:
6867
return "NEW";
69-
case TEA_TOKEN_TRAIT:
70-
return "TRAIT";
71-
case TEA_TOKEN_FOR:
72-
return "FOR";
68+
7369
case TEA_TOKEN_IDENT:
7470
return "IDENT";
7571
case TEA_TOKEN_LPAREN:

0 commit comments

Comments
 (0)