Skip to content

Commit

Permalink
#236 small revisions
Browse files Browse the repository at this point in the history
  • Loading branch information
dibyendumajumdar committed Oct 16, 2021
1 parent ede1155 commit 5cec0fd
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 14 deletions.
16 changes: 8 additions & 8 deletions ravicomp/src/codegen.c
Original file line number Diff line number Diff line change
Expand Up @@ -2888,7 +2888,7 @@ static void emit_userdata_C_variable_store(Function *fn, Instruction *insn, Pseu
* output at top level so that declarations are shared amongst all
* functions in a chunk of Ravi code.
*/
static int emit_op_embed_C(Function *fn, Instruction *insn)
static int emit_op_C__unsafe(Function *fn, Instruction *insn)
{
// Save the buffer and switch to new one temporarily
TextBuffer saved = fn->body;
Expand Down Expand Up @@ -2929,7 +2929,7 @@ static int emit_op_embed_C(Function *fn, Instruction *insn)
return 0;
}

static int emit_op_embed_C__new(Function *fn, Instruction *insn) {
static int emit_op_C__new(Function *fn, Instruction *insn) {
LinearizerState *linearizer = fn->proc->linearizer;

TextBuffer code;
Expand Down Expand Up @@ -3200,12 +3200,12 @@ static int output_instruction(Function *fn, Instruction *insn)
rc = emit_op_init(fn, insn);
break;

case op_embed_C:
rc = emit_op_embed_C(fn, insn);
case op_C__unsafe:
rc = emit_op_C__unsafe(fn, insn);
break;

case op_embed_C__new:
rc = emit_op_embed_C__new(fn, insn);
case op_C__new:
rc = emit_op_C__new(fn, insn);
break;

default:
Expand Down Expand Up @@ -3487,7 +3487,7 @@ static void preprocess_upvalues(Proc *proc)
}

/* Emits top level C__decl contents */
static int emit_embedded_C_declarations(LinearizerState *linearizer, struct Ravi_CompilerInterface *api, TextBuffer *mb)
static int emit_C__decl(LinearizerState *linearizer, struct Ravi_CompilerInterface *api, TextBuffer *mb)
{
if (linearizer->C_declarations.buf == NULL || linearizer->C_declarations.buf[0] == 0)
return 0;
Expand Down Expand Up @@ -3564,7 +3564,7 @@ int raviX_generate_C(LinearizerState *linearizer, TextBuffer *mb, struct Ravi_Co
raviX_buffer_add_string(mb, Lua_header);

/* emit C__decl statements in ravi code */
if (emit_embedded_C_declarations(linearizer, ravi_interface, mb) != 0) {
if (emit_C__decl(linearizer, ravi_interface, mb) != 0) {
return -1;
}

Expand Down
8 changes: 4 additions & 4 deletions ravicomp/src/linearizer.c
Original file line number Diff line number Diff line change
Expand Up @@ -1545,7 +1545,7 @@ static void linearize_local_statement(Proc *proc, AstNode *stmt)

static Pseudo *linearize_builtin_expression(Proc *proc, AstNode *expr)
{
Instruction *insn = allocate_instruction(proc, op_embed_C__new, expr->line_number);
Instruction *insn = allocate_instruction(proc, op_C__new, expr->line_number);
add_instruction_operand(proc, insn, allocate_constant_pseudo(proc, allocate_string_constant(proc, expr->builtin_expr.type_name)));
Pseudo *size_expr = linearize_expression(proc, expr->builtin_expr.size_expr);
add_instruction_operand(proc, insn, size_expr);
Expand Down Expand Up @@ -2331,7 +2331,7 @@ static void linearize_embedded_C(Proc *proc, AstNode *node)
return;
}

Instruction *insn = allocate_instruction(proc, op_embed_C, node->line_number);
Instruction *insn = allocate_instruction(proc, op_C__unsafe, node->line_number);
LuaSymbol *sym;
FOR_EACH_PTR(node->embedded_C_stmt.symbols, LuaSymbol, sym)
{
Expand Down Expand Up @@ -2693,7 +2693,7 @@ static const char *op_codenames[] = {
"PUTik", "PUTsk", "TPUT", "TPUTik", "TPUTsk", "IAPUT", "IAPUTiv", "FAPUT", "FAPUTfv",
"CBR", "BR", "MOV", "MOVi", "MOVif", "MOVf", "MOVfi", "CALL", "GET",
"GETik", "GETsk", "TGET", "TGETik", "TGETsk", "IAGET", "IAGETik", "FAGET", "FAGETik",
"STOREGLOBAL", "CLOSE", "CONCAT", "INIT", "EMBED_C", "EMBED_C__NEW"};
"STOREGLOBAL", "CLOSE", "CONCAT", "INIT", "C__UNSAFE", "C__NEW"};

static void output_pseudo_list(PseudoList *list, TextBuffer *mb)
{
Expand Down Expand Up @@ -2726,7 +2726,7 @@ static void output_instruction(Instruction *insn, TextBuffer *mb, const char *pr
if (insn->operands) {
output_pseudo_list(insn->operands, mb);
}
if (insn->opcode == op_embed_C) {
if (insn->opcode == op_C__unsafe) {
// special handling as we don't want to output all the C code
raviX_buffer_add_string(mb, " { C code }");
}
Expand Down
4 changes: 2 additions & 2 deletions ravicomp/src/linearizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@ enum opcode {
op_close,
op_concat,
op_init,
op_embed_C,
op_embed_C__new
op_C__unsafe,
op_C__new
};

/*
Expand Down

0 comments on commit 5cec0fd

Please sign in to comment.