From a8e667a8fabfda873d6b7552ce4c7b2fa7967560 Mon Sep 17 00:00:00 2001 From: Brendan Hansen Date: Fri, 17 Jul 2020 23:21:39 -0500 Subject: [PATCH] Code cleanup and uniformity --- onyx | Bin 254608 -> 254608 bytes src/onyxchecker.c | 56 ++++++++++++++++++++++++---------------------- 2 files changed, 29 insertions(+), 27 deletions(-) diff --git a/onyx b/onyx index 1aceef52da59ee69696deda612c369b9df42f195..ccc9e93004e4a2f09bf42ac628b28351e302d621 100755 GIT binary patch delta 1088 zcmY+DT}YE*6vv;BX0uxJWACQZcWzGIUM(ROeG%lvm~%?XESQm@h`G^45Yr^gl@>{n zxNe>ZqmL^=t3lC33B(k=h@kK9P^74>S?_Dg*`b-XZj}wk`n{;>H``TAs@44N146XLI{id z9p}xkM#VWFv(rv7;$t#D%&3@$eF+E+3p?sJ0tWj91BSJbl1v%IULZGAGkY!wjSM;B zu9UH-n%QW*I8@Cn+yG!Vf*}3_(HI3#+Q>{{Bir-00=VRk17Bzb&1=2(<8=Mr>~#}hHk1T@wKm@QUJtt*&39wH<||2u;a*C2jiCsimRpSy_q z^Ji)+9lj5yduq2zXhn|1++&;7J$gKTJ*FI85Bsj1W%cu_lqH71A9fcy%>d~c0v z?=#~KN(Ai>A`xKrtQ$rFnV=eF+y?7Su@GPu8WcYR%&{f7E!`F^W6-B%OvKz@*8&}E z+nR?JjKs=gm?I(rweT(*#gST8RJqTr)zhN%;H*QILChNuSF|4MAnc%7E3ZKr#>CBH zyq3w#3+;m|T;6nh-2xxJm%dYDTcBkJpfxTdrt?r?s{`1x3V%b`LyPgT!b1{Oi#$BTUe_kM(dcIB~_$`>{kCzQu1{ji_GVJI$5bR zEbH`rx~e9fxld=(hjg@G=M+s6-%qXLjsy?IDI_z$O$(DVW**_RG+Alomnl`mTmf$b xx1x|Q(qdtdxk4RcyUgv>EkZIcqD7)x<~6iLOw0Tp-6@XScr)Dd!p0{b{sn>`@iqVe delta 1088 zcmY+DTSydP6vyYBkF_<|*4&GmHS4aLyOSv`WmcGpg|6#X+m-E#qTxypfkpLD4s;<4 z5+{fgVc4T|6^axq2rKlV7om$GR7=nWf}kD>it2o`yG8Tz&G(((`Tl4A=S<&Yd*5UG z&{K3)y}wkkyYKUii&w^$d@8Np89o2{-mMQfc@oBskM<0Y_Q0k4&_(eE^v>==Uw46` zpb_?;ar4?mry9@)`)RNNRnd+%n&5qDJNi>t!oPkNW9=AvlPl9&l+tXKU!qLf8qw#7 z;-VB8_ZtB-u#Q$Wq8HZE?nW#SISd|_U=Ggz56r>kbd^Du4V?+QygQ*Nr7Py~+YhkO zE1B~HiZeL_3(UY`njPkxUtsx{b7BsMzHrW(Fqi%X7G_F6i)NtaZ|NO#`5?(;k0g^& zmLbRU%)rvWq^FP%CYgL9$w?^5kls|F>bH{tX-B_2=w>pn34JBq5RjxWMs$DDWk!~r zV+VyXq?g>47M`X}O}I?7aYip^qX$js6v)5}1{?@! z+=paL7?*WzUk>jNyOayr$QxxiRFv*T@Uw(N6~%Jcxy@NthlF2B0gsLLFkI$I4@Eqfl(u`S zI!!pn@HMNVEW9pjblNx7=fpoXed j;e*u_S49!5pu?(Yf>ku8ircW64td2czUP@&+type == NULL) node->type = type_build_from_ast(state->allocator, node->type_node); } -static b32 check_return(SemState* state, AstReturn* retnode) { +CHECK(return, AstReturn* retnode) { if (retnode->expr) { if (check_expression(state, retnode->expr)) return 1; @@ -46,7 +48,7 @@ static b32 check_return(SemState* state, AstReturn* retnode) { return 0; } -static b32 check_if(SemState* state, AstIf* ifnode) { +CHECK(if, AstIf* ifnode) { if (check_expression(state, ifnode->cond)) return 1; if (!type_is_bool(ifnode->cond->type)) { @@ -63,7 +65,7 @@ static b32 check_if(SemState* state, AstIf* ifnode) { return 0; } -static b32 check_while(SemState* state, AstWhile* whilenode) { +CHECK(while, AstWhile* whilenode) { if (check_expression(state, whilenode->cond)) return 1; if (!type_is_bool(whilenode->cond->type)) { @@ -112,7 +114,7 @@ no_match: return NULL; } -static b32 check_call(SemState* state, AstCall* call) { +CHECK(call, AstCall* call) { AstFunction* callee = (AstFunction *) call->callee; if (callee->kind == Ast_Kind_Symbol) { @@ -255,7 +257,7 @@ static b32 check_call(SemState* state, AstCall* call) { return 0; } -static b32 check_binaryop(SemState* state, AstBinaryOp* binop) { +CHECK(binaryop, AstBinaryOp* binop) { if (check_expression(state, binop->left)) return 1; if (check_expression(state, binop->right)) return 1; @@ -352,7 +354,7 @@ static b32 check_binaryop(SemState* state, AstBinaryOp* binop) { return 0; } -static b32 check_array_access(SemState* state, AstArrayAccess* aa) { +CHECK(array_access, AstArrayAccess* aa) { check_expression(state, aa->addr); check_expression(state, aa->expr); @@ -379,7 +381,7 @@ static b32 check_array_access(SemState* state, AstArrayAccess* aa) { return 0; } -static b32 check_expression(SemState* state, AstTyped* expr) { +CHECK(expression, AstTyped* expr) { if (expr->kind > Ast_Kind_Type_Start && expr->kind < Ast_Kind_Type_End) { onyx_message_add(state->msgs, ONYX_MESSAGE_TYPE_LITERAL, @@ -462,7 +464,7 @@ static b32 check_expression(SemState* state, AstTyped* expr) { return retval; } -static b32 check_global(SemState* state, AstGlobal* global) { +CHECK(global, AstGlobal* global) { fill_in_type(state, (AstTyped *) global); if (global->type == NULL) { @@ -478,7 +480,7 @@ static b32 check_global(SemState* state, AstGlobal* global) { return 0; } -static b32 check_statement(SemState* state, AstNode* stmt) { +CHECK(statement, AstNode* stmt) { switch (stmt->kind) { case Ast_Kind_Return: return check_return(state, (AstReturn *) stmt); case Ast_Kind_If: return check_if(state, (AstIf *) stmt); @@ -495,7 +497,7 @@ static b32 check_statement(SemState* state, AstNode* stmt) { } } -static b32 check_statement_chain(SemState* state, AstNode* start) { +CHECK(statement_chain, AstNode* start) { while (start) { if (check_statement(state, start)) return 1; start = start->next; @@ -504,7 +506,7 @@ static b32 check_statement_chain(SemState* state, AstNode* start) { return 0; } -static b32 check_block(SemState* state, AstBlock* block) { +CHECK(block, AstBlock* block) { if (check_statement_chain(state, block->body)) return 1; forll(AstLocal, local, block->locals->last_local, prev_local) { @@ -520,7 +522,7 @@ static b32 check_block(SemState* state, AstBlock* block) { return 0; } -static b32 check_function(SemState* state, AstFunction* func) { +CHECK(function, AstFunction* func) { for (AstLocal *param = func->params; param != NULL; param = (AstLocal *) param->next) { fill_in_type(state, (AstTyped *) param); @@ -585,7 +587,7 @@ static b32 check_function(SemState* state, AstFunction* func) { return 0; } -static b32 check_overloaded_function(SemState* state, AstOverloadedFunction* func) { +CHECK(overloaded_function, AstOverloadedFunction* func) { bh_arr_each(AstTyped *, node, func->overloads) { if ((*node)->kind == Ast_Kind_Overloaded_Function) { onyx_message_add(state->msgs, @@ -609,7 +611,7 @@ static b32 check_overloaded_function(SemState* state, AstOverloadedFunction* fun return 0; } -static b32 check_node(SemState* state, AstNode* node) { +CHECK(node, AstNode* node) { switch (node->kind) { case Ast_Kind_Function: return check_function(state, (AstFunction *) node); case Ast_Kind_Overloaded_Function: return check_overloaded_function(state, (AstOverloadedFunction *) node); -- 2.25.1