aboutsummaryrefslogtreecommitdiff
path: root/src/ls_kw_impl_GOSUB_RETURN.c
diff options
context:
space:
mode:
authorAlexis Lockwood2021-06-27 18:39:09 -0400
committerAlexis Lockwood2021-06-27 18:39:09 -0400
commit3204af5b4f995d699e0a83f86942693a5550d906 (patch)
tree3815e95b57582739312c98e76d75510490eae3a3 /src/ls_kw_impl_GOSUB_RETURN.c
parent0550cf6ca455d4fcad2ac4bf17ea2697df582b63 (diff)
Get rid of 'ctx' term
Diffstat (limited to 'src/ls_kw_impl_GOSUB_RETURN.c')
-rw-r--r--src/ls_kw_impl_GOSUB_RETURN.c76
1 files changed, 38 insertions, 38 deletions
diff --git a/src/ls_kw_impl_GOSUB_RETURN.c b/src/ls_kw_impl_GOSUB_RETURN.c
index 1d3d45d..fa4b3da 100644
--- a/src/ls_kw_impl_GOSUB_RETURN.c
+++ b/src/ls_kw_impl_GOSUB_RETURN.c
@@ -24,23 +24,23 @@
// --- PRIVATE VARIABLES -------------------------------------------------------
// --- PUBLIC FUNCTIONS --------------------------------------------------------
-void ls_kw_fun_GOSUB(ls_context_t * ctx)
+void ls_kw_fun_GOSUB(ls_t * self)
{
- ctx->callstack->body.sctx_call.pc = ctx->pc;
+ self->callstack->body.sctx_call.pc = self->pc;
ls_token_t tok;
- ls_lex(ctx, &tok);
+ ls_lex(self, &tok);
if (tok.ty != LS_TOK_WORD)
- ls_throw_err(ctx, LS_SYNTAX_ERROR);
+ ls_throw_err(self, LS_SYNTAX_ERROR);
char ident[LS_IDENT_LEN];
memcpy(ident, tok.body.word_val, LS_IDENT_LEN);
- ls_value_t * frame = ls_alloc(ctx);
+ ls_value_t * frame = ls_alloc(self);
*frame = (ls_value_t) {
.ty = LS_TY_SCTX_CALL,
- .prev = ctx->callstack,
+ .prev = self->callstack,
.next = NULL,
.body.sctx_call = {
.pc = LS_ADDR_NULL,
@@ -48,15 +48,15 @@ void ls_kw_fun_GOSUB(ls_context_t * ctx)
},
};
- ctx->callstack = frame;
- ctx->callstack->body.sctx_call.pc = ctx->pc;
+ self->callstack = frame;
+ self->callstack->body.sctx_call.pc = self->pc;
- ls_lex(ctx, &tok);
+ ls_lex(self, &tok);
if (tok.ty == LS_TOK_OPERATOR && tok.body.oper_val == OPER_LPAREN)
{
for (;;)
{
- ls_lex(ctx, &tok);
+ ls_lex(self, &tok);
if (tok.ty == LS_TOK_WORD)
{
@@ -64,16 +64,16 @@ void ls_kw_fun_GOSUB(ls_context_t * ctx)
memcpy(arg_ident, tok.body.word_val,
LS_IDENT_LEN);
- ls_lex(ctx, &tok);
+ ls_lex(self, &tok);
if (!(tok.ty == LS_TOK_OPERATOR &&
tok.body.oper_val == OPER_EQ))
- ls_throw_err(ctx, LS_SYNTAX_ERROR);
+ ls_throw_err(self, LS_SYNTAX_ERROR);
ls_value_t val;
- ls_eval_expr(ctx, &val, NULL);
+ ls_eval_expr(self, &val, NULL);
- ls_value_t * var = ls_new_var(ctx, arg_ident);
- ls_write_var(ctx, var, &val);
+ ls_value_t * var = ls_new_var(self, arg_ident);
+ ls_write_var(self, var, &val);
}
else if (tok.ty == LS_TOK_COMMA)
continue;
@@ -81,65 +81,65 @@ void ls_kw_fun_GOSUB(ls_context_t * ctx)
&& tok.body.oper_val == OPER_RPAREN)
break;
else
- ls_throw_err(ctx, LS_SYNTAX_ERROR);
+ ls_throw_err(self, LS_SYNTAX_ERROR);
}
- ls_lex(ctx, &tok);
+ ls_lex(self, &tok);
}
// AS is parsed by RETURN, just check that the line is actually valid
if (tok.ty == LS_TOK_KEYWORD && tok.body.keyword_val == LS_KW_AS)
{
- ls_lex(ctx, &tok);
+ ls_lex(self, &tok);
if (tok.ty != LS_TOK_WORD)
- ls_throw_err(ctx, LS_SYNTAX_ERROR);
+ ls_throw_err(self, LS_SYNTAX_ERROR);
- ls_lex(ctx, &tok);
+ ls_lex(self, &tok);
}
if (tok.ty != LS_TOK_STATEMENT_SEP && tok.ty != LS_TOK_NONE)
- ls_throw_err(ctx, LS_SYNTAX_ERROR);
+ ls_throw_err(self, LS_SYNTAX_ERROR);
- ls_goto_ident(ctx, ident);
+ ls_goto_ident(self, ident);
}
-void ls_kw_fun_RETURN(ls_context_t * ctx)
+void ls_kw_fun_RETURN(ls_t * self)
{
ls_token_t tok;
ls_value_t val = {.ty = LS_TY_INT, .body.integer.value = 0};
- ls_lex(ctx, &tok);
+ ls_lex(self, &tok);
if (!LS_TOK_EOS(tok))
- ls_eval_expr(ctx, &val, &tok);
+ ls_eval_expr(self, &val, &tok);
// Free the scope
ls_value_t * next;
- for (ls_value_t * i = ctx->callstack->next; i; i = next)
+ for (ls_value_t * i = self->callstack->next; i; i = next)
{
next = i->next;
- ls_free(ctx, i);
+ ls_free(self, i);
}
- ls_value_t * frame = ctx->callstack->prev;
- ls_addr_t pc = ctx->callstack->body.sctx_call.pc;
- ls_free(ctx, ctx->callstack);
- ctx->callstack = frame;
- ctx->pc = pc;
+ ls_value_t * frame = self->callstack->prev;
+ ls_addr_t pc = self->callstack->body.sctx_call.pc;
+ ls_free(self, self->callstack);
+ self->callstack = frame;
+ self->pc = pc;
while (!LS_TOK_EOS(tok))
{
if (tok.ty == LS_TOK_KEYWORD
&& tok.body.keyword_val == LS_KW_AS)
{
- ls_lex(ctx, &tok);
+ ls_lex(self, &tok);
if (tok.ty != LS_TOK_WORD)
// This was already checked!
- ls_throw_err(ctx, LS_INTERNAL_ERROR);
- ls_value_t * var = ls_find_var(ctx, tok.body.word_val);
+ ls_throw_err(self, LS_INTERNAL_ERROR);
+ ls_value_t * var = ls_find_var(self, tok.body.word_val);
if (!var)
- var = ls_new_var(ctx, tok.body.word_val);
- ls_write_var(ctx, var, &val);
+ var = ls_new_var(self, tok.body.word_val);
+ ls_write_var(self, var, &val);
}
- ls_lex(ctx, &tok);
+ ls_lex(self, &tok);
}
}