summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJo-Philipp Wich <jo@mein.io>2021-07-09 19:58:37 +0200
committerJo-Philipp Wich <jo@mein.io>2021-07-11 15:49:14 +0200
commitff52440341bcb8c61105ff144bfcb210315207e4 (patch)
treeb7eb1c47cb8034e5188b86f480e3e61f44ee6ced
parent1d60418132460c23b216a2f8a9e0ea8897d32ea4 (diff)
treewide: consolidate typedef naming
Ensure that all custom typedef and vector declaration type names end with a "_t" suffix. Signed-off-by: Jo-Philipp Wich <jo@mein.io>
-rw-r--r--chunk.c34
-rw-r--r--chunk.h18
-rw-r--r--compiler.c356
-rw-r--r--compiler.h46
-rw-r--r--lexer.c92
-rw-r--r--lexer.h16
-rw-r--r--lib.c154
-rw-r--r--lib.h16
-rw-r--r--lib/fs.c74
-rw-r--r--lib/math.c24
-rw-r--r--lib/ubus.c22
-rw-r--r--lib/uci.c58
-rw-r--r--main.c10
-rw-r--r--module.h6
-rw-r--r--source.c18
-rw-r--r--source.h10
-rw-r--r--types.c42
-rw-r--r--types.h104
-rw-r--r--value.c32
-rw-r--r--value.h16
-rw-r--r--vm.c252
-rw-r--r--vm.h34
22 files changed, 715 insertions, 719 deletions
diff --git a/chunk.c b/chunk.c
index 7d3e498..8b2c447 100644
--- a/chunk.c
+++ b/chunk.c
@@ -20,7 +20,7 @@
#include "types.h"
#include "util.h"
-#define OFFSETINFO_BITS (sizeof(((uc_offsetinfo *)NULL)->entries[0]) * 8)
+#define OFFSETINFO_BITS (sizeof(((uc_offsetinfo_t *)NULL)->entries[0]) * 8)
#define OFFSETINFO_BYTE_BITS 3
#define OFFSETINFO_INSN_BITS (OFFSETINFO_BITS - OFFSETINFO_BYTE_BITS)
#define OFFSETINFO_MAX_BYTES ((1 << OFFSETINFO_BYTE_BITS) - 1)
@@ -31,7 +31,7 @@
void
-uc_chunk_init(uc_chunk *chunk)
+uc_chunk_init(uc_chunk_t *chunk)
{
chunk->count = 0;
chunk->entries = NULL;
@@ -50,7 +50,7 @@ uc_chunk_init(uc_chunk *chunk)
}
void
-uc_chunk_free(uc_chunk *chunk)
+uc_chunk_free(uc_chunk_t *chunk)
{
uc_vector_clear(chunk);
uc_vector_clear(&chunk->ehranges);
@@ -64,9 +64,9 @@ uc_chunk_free(uc_chunk *chunk)
}
size_t
-uc_chunk_add(uc_chunk *chunk, uint8_t byte, size_t offset)
+uc_chunk_add(uc_chunk_t *chunk, uint8_t byte, size_t offset)
{
- uc_offsetinfo *offsets = &chunk->debuginfo.offsets;
+ uc_offsetinfo_t *offsets = &chunk->debuginfo.offsets;
size_t i;
uc_vector_grow(chunk);
@@ -114,9 +114,9 @@ uc_chunk_add(uc_chunk *chunk, uint8_t byte, size_t offset)
}
void
-uc_chunk_pop(uc_chunk *chunk)
+uc_chunk_pop(uc_chunk_t *chunk)
{
- uc_offsetinfo *offsets = &chunk->debuginfo.offsets;
+ uc_offsetinfo_t *offsets = &chunk->debuginfo.offsets;
int n_insns;
assert(chunk->count > 0);
@@ -137,21 +137,21 @@ uc_chunk_pop(uc_chunk *chunk)
}
uc_value_t *
-uc_chunk_get_constant(uc_chunk *chunk, size_t idx)
+uc_chunk_get_constant(uc_chunk_t *chunk, size_t idx)
{
return uc_vallist_get(&chunk->constants, idx);
}
ssize_t
-uc_chunk_add_constant(uc_chunk *chunk, uc_value_t *val)
+uc_chunk_add_constant(uc_chunk_t *chunk, uc_value_t *val)
{
return uc_vallist_add(&chunk->constants, val);
}
size_t
-uc_chunk_debug_get_srcpos(uc_chunk *chunk, size_t off)
+uc_chunk_debug_get_srcpos(uc_chunk_t *chunk, size_t off)
{
- uc_offsetinfo *offsets = &chunk->debuginfo.offsets;
+ uc_offsetinfo_t *offsets = &chunk->debuginfo.offsets;
size_t i, inum = 0, lnum = 0;
if (!offsets->count)
@@ -166,10 +166,10 @@ uc_chunk_debug_get_srcpos(uc_chunk *chunk, size_t off)
}
void
-uc_chunk_debug_add_variable(uc_chunk *chunk, size_t from, size_t to, size_t slot, bool upval, uc_value_t *name)
+uc_chunk_debug_add_variable(uc_chunk_t *chunk, size_t from, size_t to, size_t slot, bool upval, uc_value_t *name)
{
- uc_variables *variables = &chunk->debuginfo.variables;
- uc_value_list *varnames = &chunk->debuginfo.varnames;
+ uc_variables_t *variables = &chunk->debuginfo.variables;
+ uc_value_list_t *varnames = &chunk->debuginfo.varnames;
assert(slot <= ((size_t)-1 / 2));
@@ -187,10 +187,10 @@ uc_chunk_debug_add_variable(uc_chunk *chunk, size_t from, size_t to, size_t slot
}
uc_value_t *
-uc_chunk_debug_get_variable(uc_chunk *chunk, size_t off, size_t slot, bool upval)
+uc_chunk_debug_get_variable(uc_chunk_t *chunk, size_t off, size_t slot, bool upval)
{
- uc_variables *variables = &chunk->debuginfo.variables;
- uc_value_list *varnames = &chunk->debuginfo.varnames;
+ uc_variables_t *variables = &chunk->debuginfo.variables;
+ uc_value_list_t *varnames = &chunk->debuginfo.varnames;
uc_value_t *name = NULL;
size_t i;
diff --git a/chunk.h b/chunk.h
index 2a8fa3a..458af1f 100644
--- a/chunk.h
+++ b/chunk.h
@@ -24,16 +24,16 @@
#include "util.h"
#include "types.h"
-void uc_chunk_init(uc_chunk *chunk);
-void uc_chunk_free(uc_chunk *chunk);
-size_t uc_chunk_add(uc_chunk *chunk, uint8_t byte, size_t line);
+void uc_chunk_init(uc_chunk_t *chunk);
+void uc_chunk_free(uc_chunk_t *chunk);
+size_t uc_chunk_add(uc_chunk_t *chunk, uint8_t byte, size_t line);
-ssize_t uc_chunk_add_constant(uc_chunk *chunk, uc_value_t *value);
-uc_value_t *uc_chunk_get_constant(uc_chunk *chunk, size_t idx);
-void uc_chunk_pop(uc_chunk *chunk);
+ssize_t uc_chunk_add_constant(uc_chunk_t *chunk, uc_value_t *value);
+uc_value_t *uc_chunk_get_constant(uc_chunk_t *chunk, size_t idx);
+void uc_chunk_pop(uc_chunk_t *chunk);
-size_t uc_chunk_debug_get_srcpos(uc_chunk *chunk, size_t off);
-void uc_chunk_debug_add_variable(uc_chunk *chunk, size_t from, size_t to, size_t slot, bool upval, uc_value_t *name);
-uc_value_t *uc_chunk_debug_get_variable(uc_chunk *chunk, size_t off, size_t slot, bool upval);
+size_t uc_chunk_debug_get_srcpos(uc_chunk_t *chunk, size_t off);
+void uc_chunk_debug_add_variable(uc_chunk_t *chunk, size_t from, size_t to, size_t slot, bool upval, uc_value_t *name);
+uc_value_t *uc_chunk_debug_get_variable(uc_chunk_t *chunk, size_t off, size_t slot, bool upval);
#endif /* __CHUNK_H_ */
diff --git a/compiler.c b/compiler.c
index 85616c5..9278324 100644
--- a/compiler.c
+++ b/compiler.c
@@ -22,29 +22,29 @@
#include "source.h"
#include "lib.h" /* format_error_context() */
-static void uc_compiler_compile_unary(uc_compiler *compiler, bool assignable);
-static void uc_compiler_compile_binary(uc_compiler *compiler, bool assignable);
-static void uc_compiler_compile_delete(uc_compiler *compiler, bool assignable);
-static void uc_compiler_compile_paren(uc_compiler *compiler, bool assignable);
-static void uc_compiler_compile_call(uc_compiler *compiler, bool assignable);
-static void uc_compiler_compile_post_inc(uc_compiler *compiler, bool assignable);
-static void uc_compiler_compile_constant(uc_compiler *compiler, bool assignable);
-static void uc_compiler_compile_comma(uc_compiler *compiler, bool assignable);
-static void uc_compiler_compile_labelexpr(uc_compiler *compiler, bool assignable);
-static void uc_compiler_compile_function(uc_compiler *compiler, bool assignable);
-static void uc_compiler_compile_and(uc_compiler *compiler, bool assignable);
-static void uc_compiler_compile_or(uc_compiler *compiler, bool assignable);
-static void uc_compiler_compile_dot(uc_compiler *compiler, bool assignable);
-static void uc_compiler_compile_subscript(uc_compiler *compiler, bool assignable);
-static void uc_compiler_compile_ternary(uc_compiler *compiler, bool assignable);
-static void uc_compiler_compile_array(uc_compiler *compiler, bool assignable);
-static void uc_compiler_compile_object(uc_compiler *compiler, bool assignable);
-
-static void uc_compiler_compile_declaration(uc_compiler *compiler);
-static void uc_compiler_compile_statement(uc_compiler *compiler);
-static void uc_compiler_compile_expstmt(uc_compiler *compiler);
-
-static uc_parse_rule
+static void uc_compiler_compile_unary(uc_compiler_t *compiler, bool assignable);
+static void uc_compiler_compile_binary(uc_compiler_t *compiler, bool assignable);
+static void uc_compiler_compile_delete(uc_compiler_t *compiler, bool assignable);
+static void uc_compiler_compile_paren(uc_compiler_t *compiler, bool assignable);
+static void uc_compiler_compile_call(uc_compiler_t *compiler, bool assignable);
+static void uc_compiler_compile_post_inc(uc_compiler_t *compiler, bool assignable);
+static void uc_compiler_compile_constant(uc_compiler_t *compiler, bool assignable);
+static void uc_compiler_compile_comma(uc_compiler_t *compiler, bool assignable);
+static void uc_compiler_compile_labelexpr(uc_compiler_t *compiler, bool assignable);
+static void uc_compiler_compile_function(uc_compiler_t *compiler, bool assignable);
+static void uc_compiler_compile_and(uc_compiler_t *compiler, bool assignable);
+static void uc_compiler_compile_or(uc_compiler_t *compiler, bool assignable);
+static void uc_compiler_compile_dot(uc_compiler_t *compiler, bool assignable);
+static void uc_compiler_compile_subscript(uc_compiler_t *compiler, bool assignable);
+static void uc_compiler_compile_ternary(uc_compiler_t *compiler, bool assignable);
+static void uc_compiler_compile_array(uc_compiler_t *compiler, bool assignable);
+static void uc_compiler_compile_object(uc_compiler_t *compiler, bool assignable);
+
+static void uc_compiler_compile_declaration(uc_compiler_t *compiler);
+static void uc_compiler_compile_statement(uc_compiler_t *compiler);
+static void uc_compiler_compile_expstmt(uc_compiler_t *compiler);
+
+static uc_parse_rule_t
uc_compiler_parse_rules[TK_ERROR + 1] = {
[TK_LPAREN] = { uc_compiler_compile_paren, uc_compiler_compile_call, P_CALL },
[TK_SUB] = { uc_compiler_compile_unary, uc_compiler_compile_binary, P_ADD },
@@ -91,13 +91,13 @@ uc_compiler_parse_rules[TK_ERROR + 1] = {
};
static ssize_t
-uc_compiler_declare_local(uc_compiler *compiler, uc_value_t *name, bool constant);
+uc_compiler_declare_local(uc_compiler_t *compiler, uc_value_t *name, bool constant);
static ssize_t
-uc_compiler_initialize_local(uc_compiler *compiler);
+uc_compiler_initialize_local(uc_compiler_t *compiler);
static void
-uc_compiler_init(uc_compiler *compiler, const char *name, size_t srcpos, uc_source *source, bool strict)
+uc_compiler_init(uc_compiler_t *compiler, const char *name, size_t srcpos, uc_source_t *source, bool strict)
{
uc_value_t *varname = ucv_string_new("(callee)");
uc_function_t *fn;
@@ -127,16 +127,16 @@ uc_compiler_init(uc_compiler *compiler, const char *name, size_t srcpos, uc_sour
ucv_put(varname);
}
-static uc_chunk *
-uc_compiler_current_chunk(uc_compiler *compiler)
+static uc_chunk_t *
+uc_compiler_current_chunk(uc_compiler_t *compiler)
{
uc_function_t *fn = (uc_function_t *)compiler->function;
return &fn->chunk;
}
-static uc_source *
-uc_compiler_current_source(uc_compiler *compiler)
+static uc_source_t *
+uc_compiler_current_source(uc_compiler_t *compiler)
{
uc_function_t *fn = (uc_function_t *)compiler->function;
@@ -144,7 +144,7 @@ uc_compiler_current_source(uc_compiler *compiler)
}
__attribute__((format(printf, 3, 0))) static void
-uc_compiler_syntax_error(uc_compiler *compiler, size_t off, const char *fmt, ...)
+uc_compiler_syntax_error(uc_compiler_t *compiler, size_t off, const char *fmt, ...)
{
uc_stringbuf_t *buf = compiler->parser->error;
size_t line = 0, byte = 0, len = 0;
@@ -186,7 +186,7 @@ uc_compiler_syntax_error(uc_compiler *compiler, size_t off, const char *fmt, ...
}
static size_t
-uc_compiler_set_srcpos(uc_compiler *compiler, size_t srcpos)
+uc_compiler_set_srcpos(uc_compiler_t *compiler, size_t srcpos)
{
size_t delta;
@@ -200,7 +200,7 @@ uc_compiler_set_srcpos(uc_compiler *compiler, size_t srcpos)
}
static void
-uc_compiler_parse_advance(uc_compiler *compiler)
+uc_compiler_parse_advance(uc_compiler_t *compiler)
{
ucv_put(compiler->parser->prev.uv);
compiler->parser->prev = compiler->parser->curr;
@@ -220,7 +220,7 @@ uc_compiler_parse_advance(uc_compiler *compiler)
}
static void
-uc_compiler_parse_consume(uc_compiler *compiler, uc_tokentype_t type)
+uc_compiler_parse_consume(uc_compiler_t *compiler, uc_tokentype_t type)
{
if (compiler->parser->curr.type == type) {
uc_compiler_parse_advance(compiler);
@@ -233,13 +233,13 @@ uc_compiler_parse_consume(uc_compiler *compiler, uc_tokentype_t type)
}
static bool
-uc_compiler_parse_check(uc_compiler *compiler, uc_tokentype_t type)
+uc_compiler_parse_check(uc_compiler_t *compiler, uc_tokentype_t type)
{
return (compiler->parser->curr.type == type);
}
static bool
-uc_compiler_parse_match(uc_compiler *compiler, uc_tokentype_t type)
+uc_compiler_parse_match(uc_compiler_t *compiler, uc_tokentype_t type)
{
if (!uc_compiler_parse_check(compiler, type))
return false;
@@ -250,7 +250,7 @@ uc_compiler_parse_match(uc_compiler *compiler, uc_tokentype_t type)
}
static void
-uc_compiler_parse_synchronize(uc_compiler *compiler)
+uc_compiler_parse_synchronize(uc_compiler_t *compiler)
{
compiler->parser->synchronizing = false;
@@ -279,14 +279,14 @@ uc_compiler_parse_synchronize(uc_compiler *compiler)
}
}
-static uc_parse_rule *
+static uc_parse_rule_t *
uc_compiler_parse_rule(uc_tokentype_t type)
{
return &uc_compiler_parse_rules[type];
}
static bool
-uc_compiler_parse_at_assignment_op(uc_compiler *compiler)
+uc_compiler_parse_at_assignment_op(uc_compiler_t *compiler)
{
switch (compiler->parser->curr.type) {
case TK_ASBAND:
@@ -308,9 +308,9 @@ uc_compiler_parse_at_assignment_op(uc_compiler *compiler)
}
static void
-uc_compiler_parse_precedence(uc_compiler *compiler, uc_precedence_t precedence)
+uc_compiler_parse_precedence(uc_compiler_t *compiler, uc_precedence_t precedence)
{
- uc_parse_rule *rule;
+ uc_parse_rule_t *rule;
bool assignable;
rule = uc_compiler_parse_rule(compiler->parser->curr.type);
@@ -355,7 +355,7 @@ uc_compiler_parse_precedence(uc_compiler *compiler, uc_precedence_t precedence)
}
static size_t
-uc_compiler_reladdr(uc_compiler *compiler, size_t from, size_t to)
+uc_compiler_reladdr(uc_compiler_t *compiler, size_t from, size_t to)
{
ssize_t delta = to - from;
@@ -369,9 +369,9 @@ uc_compiler_reladdr(uc_compiler *compiler, size_t from, size_t to)
}
static size_t
-uc_compiler_emit_insn(uc_compiler *compiler, size_t srcpos, enum insn_type insn)
+uc_compiler_emit_insn(uc_compiler_t *compiler, size_t srcpos, uc_vm_insn_t insn)
{
- uc_chunk *chunk = uc_compiler_current_chunk(compiler);
+ uc_chunk_t *chunk = uc_compiler_current_chunk(compiler);
size_t lineoff = uc_compiler_set_srcpos(compiler, srcpos);
compiler->last_insn = uc_chunk_add(chunk, (uint8_t)insn, lineoff);
@@ -380,7 +380,7 @@ uc_compiler_emit_insn(uc_compiler *compiler, size_t srcpos, enum insn_type insn)
}
static size_t
-uc_compiler_emit_u8(uc_compiler *compiler, size_t srcpos, uint8_t n)
+uc_compiler_emit_u8(uc_compiler_t *compiler, size_t srcpos, uint8_t n)
{
return uc_chunk_add(
uc_compiler_current_chunk(compiler),
@@ -389,7 +389,7 @@ uc_compiler_emit_u8(uc_compiler *compiler, size_t srcpos, uint8_t n)
}
static size_t
-uc_compiler_emit_s8(uc_compiler *compiler, size_t srcpos, int8_t n)
+uc_compiler_emit_s8(uc_compiler_t *compiler, size_t srcpos, int8_t n)
{
return uc_chunk_add(
uc_compiler_current_chunk(compiler),
@@ -398,9 +398,9 @@ uc_compiler_emit_s8(uc_compiler *compiler, size_t srcpos, int8_t n)
}
static size_t
-uc_compiler_emit_u16(uc_compiler *compiler, size_t srcpos, uint16_t n)
+uc_compiler_emit_u16(uc_compiler_t *compiler, size_t srcpos, uint16_t n)
{
- uc_chunk *chunk = uc_compiler_current_chunk(compiler);
+ uc_chunk_t *chunk = uc_compiler_current_chunk(compiler);
size_t lineoff = uc_compiler_set_srcpos(compiler, srcpos);
uc_chunk_add(chunk, n / 0x100, lineoff);
@@ -410,9 +410,9 @@ uc_compiler_emit_u16(uc_compiler *compiler, size_t srcpos, uint16_t n)
}
static size_t
-uc_compiler_emit_s16(uc_compiler *compiler, size_t srcpos, int16_t n)
+uc_compiler_emit_s16(uc_compiler_t *compiler, size_t srcpos, int16_t n)
{
- uc_chunk *chunk = uc_compiler_current_chunk(compiler);
+ uc_chunk_t *chunk = uc_compiler_current_chunk(compiler);
size_t lineoff = uc_compiler_set_srcpos(compiler, srcpos);
uint16_t v = n + 0x7fff;
@@ -423,9 +423,9 @@ uc_compiler_emit_s16(uc_compiler *compiler, size_t srcpos, int16_t n)
}
static size_t
-uc_compiler_emit_u32(uc_compiler *compiler, size_t srcpos, uint32_t n)
+uc_compiler_emit_u32(uc_compiler_t *compiler, size_t srcpos, uint32_t n)
{
- uc_chunk *chunk = uc_compiler_current_chunk(compiler);
+ uc_chunk_t *chunk = uc_compiler_current_chunk(compiler);
size_t lineoff = uc_compiler_set_srcpos(compiler, srcpos);
uc_chunk_add(chunk, n / 0x1000000, lineoff);
@@ -437,9 +437,9 @@ uc_compiler_emit_u32(uc_compiler *compiler, size_t srcpos, uint32_t n)
}
static size_t
-uc_compiler_emit_s32(uc_compiler *compiler, size_t srcpos, int32_t n)
+uc_compiler_emit_s32(uc_compiler_t *compiler, size_t srcpos, int32_t n)
{
- uc_chunk *chunk = uc_compiler_current_chunk(compiler);
+ uc_chunk_t *chunk = uc_compiler_current_chunk(compiler);
size_t lineoff = uc_compiler_set_srcpos(compiler, srcpos);
uint32_t v;
@@ -457,9 +457,9 @@ uc_compiler_emit_s32(uc_compiler *compiler, size_t srcpos, int32_t n)
}
static uint32_t
-uc_compiler_get_u32(uc_compiler *compiler, size_t off)
+uc_compiler_get_u32(uc_compiler_t *compiler, size_t off)
{
- uc_chunk *chunk = uc_compiler_current_chunk(compiler);
+ uc_chunk_t *chunk = uc_compiler_current_chunk(compiler);
return chunk->entries[off + 0] * 0x1000000 +
chunk->entries[off + 1] * 0x10000 +
@@ -468,9 +468,9 @@ uc_compiler_get_u32(uc_compiler *compiler, size_t off)
}
static void
-uc_compiler_set_u32(uc_compiler *compiler, size_t off, uint32_t n)
+uc_compiler_set_u32(uc_compiler_t *compiler, size_t off, uint32_t n)
{
- uc_chunk *chunk = uc_compiler_current_chunk(compiler);
+ uc_chunk_t *chunk = uc_compiler_current_chunk(compiler);
chunk->entries[off + 0] = n / 0x1000000;
chunk->entries[off + 1] = (n / 0x10000) % 0x100;
@@ -479,9 +479,9 @@ uc_compiler_set_u32(uc_compiler *compiler, size_t off, uint32_t n)
}
static size_t
-uc_compiler_emit_constant(uc_compiler *compiler, size_t srcpos, uc_value_t *val)
+uc_compiler_emit_constant(uc_compiler_t *compiler, size_t srcpos, uc_value_t *val)
{
- uc_chunk *chunk = uc_compiler_current_chunk(compiler);
+ uc_chunk_t *chunk = uc_compiler_current_chunk(compiler);
size_t cidx = uc_chunk_add_constant(chunk, val);
uc_compiler_emit_insn(compiler, srcpos, I_LOAD);
@@ -491,9 +491,9 @@ uc_compiler_emit_constant(uc_compiler *compiler, size_t srcpos, uc_value_t *val)
}
static size_t
-uc_compiler_emit_regexp(uc_compiler *compiler, size_t srcpos, uc_value_t *val)
+uc_compiler_emit_regexp(uc_compiler_t *compiler, size_t srcpos, uc_value_t *val)
{
- uc_chunk *chunk = uc_compiler_current_chunk(compiler);
+ uc_chunk_t *chunk = uc_compiler_current_chunk(compiler);
size_t cidx = uc_chunk_add_constant(chunk, val);
uc_compiler_emit_insn(compiler, srcpos, I_LREXP);
@@ -503,9 +503,9 @@ uc_compiler_emit_regexp(uc_compiler *compiler, size_t srcpos, uc_value_t *val)
}
static size_t
-uc_compiler_emit_jmp(uc_compiler *compiler, size_t srcpos, uint32_t dest)
+uc_compiler_emit_jmp(uc_compiler_t *compiler, size_t srcpos, uint32_t dest)
{
- uc_chunk *chunk = uc_compiler_current_chunk(compiler);
+ uc_chunk_t *chunk = uc_compiler_current_chunk(compiler);
uc_compiler_emit_insn(compiler, srcpos, I_JMP);
uc_compiler_emit_u32(compiler, 0, dest ? uc_compiler_reladdr(compiler, chunk->count - 1, dest) : 0);
@@ -514,9 +514,9 @@ uc_compiler_emit_jmp(uc_compiler *compiler, size_t srcpos, uint32_t dest)
}
static size_t
-uc_compiler_emit_jmpz(uc_compiler *compiler, size_t srcpos, uint32_t dest)
+uc_compiler_emit_jmpz(uc_compiler_t *compiler, size_t srcpos, uint32_t dest)
{
- uc_chunk *chunk = uc_compiler_current_chunk(compiler);
+ uc_chunk_t *chunk = uc_compiler_current_chunk(compiler);
uc_compiler_emit_insn(compiler, srcpos, I_JMPZ);
uc_compiler_emit_u32(compiler, 0, dest ? uc_compiler_reladdr(compiler, chunk->count - 1, dest) : 0);
@@ -525,9 +525,9 @@ uc_compiler_emit_jmpz(uc_compiler *compiler, size_t srcpos, uint32_t dest)
}
static ssize_t
-uc_compiler_get_jmpaddr(uc_compiler *compiler, size_t off)
+uc_compiler_get_jmpaddr(uc_compiler_t *compiler, size_t off)
{
- uc_chunk *chunk = uc_compiler_current_chunk(compiler);
+ uc_chunk_t *chunk = uc_compiler_current_chunk(compiler);
assert(chunk->entries[off] == I_JMP || chunk->entries[off] == I_JMPZ);
assert(off + 4 < chunk->count);
@@ -541,9 +541,9 @@ uc_compiler_get_jmpaddr(uc_compiler *compiler, size_t off)
}
static void
-uc_compiler_set_jmpaddr(uc_compiler *compiler, size_t off, uint32_t dest)
+uc_compiler_set_jmpaddr(uc_compiler_t *compiler, size_t off, uint32_t dest)
{
- uc_chunk *chunk = uc_compiler_current_chunk(compiler);
+ uc_chunk_t *chunk = uc_compiler_current_chunk(compiler);
size_t addr = uc_compiler_reladdr(compiler, off, dest);
assert(chunk->entries[off] == I_JMP || chunk->entries[off] == I_JMPZ);
@@ -556,11 +556,11 @@ uc_compiler_set_jmpaddr(uc_compiler *compiler, size_t off, uint32_t dest)
}
static uc_function_t *
-uc_compiler_finish(uc_compiler *compiler)
+uc_compiler_finish(uc_compiler_t *compiler)
{
- uc_chunk *chunk = uc_compiler_current_chunk(compiler);
- uc_locals *locals = &compiler->locals;
- uc_upvals *upvals = &compiler->upvals;
+ uc_chunk_t *chunk = uc_compiler_current_chunk(compiler);
+ uc_locals_t *locals = &compiler->locals;
+ uc_upvals_t *upvals = &compiler->upvals;
size_t i;
uc_compiler_emit_insn(compiler, 0, I_LNULL);
@@ -601,16 +601,16 @@ uc_compiler_finish(uc_compiler *compiler)
}
static void
-uc_compiler_enter_scope(uc_compiler *compiler)
+uc_compiler_enter_scope(uc_compiler_t *compiler)
{
compiler->scope_depth++;
}
static void
-uc_compiler_leave_scope(uc_compiler *compiler)
+uc_compiler_leave_scope(uc_compiler_t *compiler)
{
- uc_chunk *chunk = uc_compiler_current_chunk(compiler);
- uc_locals *locals = &compiler->locals;
+ uc_chunk_t *chunk = uc_compiler_current_chunk(compiler);
+ uc_locals_t *locals = &compiler->locals;
compiler->scope_depth--;
@@ -633,7 +633,7 @@ uc_compiler_leave_scope(uc_compiler *compiler)
}
static bool
-uc_compiler_is_strict(uc_compiler *compiler)
+uc_compiler_is_strict(uc_compiler_t *compiler)
{
uc_function_t *fn = (uc_function_t *)compiler->function;
@@ -641,10 +641,10 @@ uc_compiler_is_strict(uc_compiler *compiler)
}
static ssize_t
-uc_compiler_declare_local(uc_compiler *compiler, uc_value_t *name, bool constant)
+uc_compiler_declare_local(uc_compiler_t *compiler, uc_value_t *name, bool constant)
{
- uc_chunk *chunk = uc_compiler_current_chunk(compiler);
- uc_locals *locals = &compiler->locals;
+ uc_chunk_t *chunk = uc_compiler_current_chunk(compiler);
+ uc_locals_t *locals = &compiler->locals;
const char *str1, *str2;
size_t i, len1, len2;
@@ -688,9 +688,9 @@ uc_compiler_declare_local(uc_compiler *compiler, uc_value_t *name, bool constant
}
static ssize_t
-uc_compiler_initialize_local(uc_compiler *compiler)
+uc_compiler_initialize_local(uc_compiler_t *compiler)
{
- uc_locals *locals = &compiler->locals;
+ uc_locals_t *locals = &compiler->locals;
locals->entries[locals->count - 1].depth = compiler->scope_depth;
@@ -698,9 +698,9 @@ uc_compiler_initialize_local(uc_compiler *compiler)
}
static ssize_t
-uc_compiler_resolve_local(uc_compiler *compiler, uc_value_t *name, bool *constant)
+uc_compiler_resolve_local(uc_compiler_t *compiler, uc_value_t *name, bool *constant)
{
- uc_locals *locals = &compiler->locals;
+ uc_locals_t *locals = &compiler->locals;
const char *str1, *str2;
size_t i, len1, len2;
@@ -730,11 +730,11 @@ uc_compiler_resolve_local(uc_compiler *compiler, uc_value_t *name, bool *constan
}
static ssize_t
-uc_compiler_add_upval(uc_compiler *compiler, size_t idx, bool local, uc_value_t *name, bool constant)
+uc_compiler_add_upval(uc_compiler_t *compiler, size_t idx, bool local, uc_value_t *name, bool constant)
{
uc_function_t *function = (uc_function_t *)compiler->function;
- uc_upvals *upvals = &compiler->upvals;
- uc_upval *uv;
+ uc_upvals_t *upvals = &compiler->upvals;
+ uc_upval_t *uv;
size_t i;
for (i = 0, uv = upvals->entries; i < upvals->count; i++, uv = upvals->entries + i)
@@ -761,7 +761,7 @@ uc_compiler_add_upval(uc_compiler *compiler, size_t idx, bool local, uc_value_t
}
static ssize_t
-uc_compiler_resolve_upval(uc_compiler *compiler, uc_value_t *name, bool *constant)
+uc_compiler_resolve_upval(uc_compiler_t *compiler, uc_value_t *name, bool *constant)
{
ssize_t idx;
@@ -785,10 +785,10 @@ uc_compiler_resolve_upval(uc_compiler *compiler, uc_value_t *name, bool *constan
}
static void
-uc_compiler_backpatch(uc_compiler *compiler, size_t break_addr, size_t next_addr)
+uc_compiler_backpatch(uc_compiler_t *compiler, size_t break_addr, size_t next_addr)
{
- uc_patchlist *pl = compiler->patchlist;
- uc_patchlist *pp = pl->parent;
+ uc_patchlist_t *pl = compiler->patchlist;
+ uc_patchlist_t *pp = pl->parent;
volatile ssize_t jmpaddr;
size_t i;
@@ -828,11 +828,11 @@ uc_compiler_backpatch(uc_compiler *compiler, size_t break_addr, size_t next_addr
}
static void
-uc_compiler_emit_inc_dec(uc_compiler *compiler, uc_tokentype_t toktype, bool is_postfix)
+uc_compiler_emit_inc_dec(uc_compiler_t *compiler, uc_tokentype_t toktype, bool is_postfix)
{
- uc_chunk *chunk = uc_compiler_current_chunk(compiler);
+ uc_chunk_t *chunk = uc_compiler_current_chunk(compiler);
uc_value_t *varname = NULL;
- enum insn_type type;
+ uc_vm_insn_t type;
uint32_t cidx = 0;
/* determine kind of emitted load instruction and operand value (if any) */
@@ -910,7 +910,7 @@ uc_compiler_emit_inc_dec(uc_compiler *compiler, uc_tokentype_t toktype, bool is_
static void
-uc_compiler_compile_unary(uc_compiler *compiler, bool assignable)
+uc_compiler_compile_unary(uc_compiler_t *compiler, bool assignable)
{
uc_tokentype_t type = compiler->parser->prev.type;
@@ -944,7 +944,7 @@ uc_compiler_compile_unary(uc_compiler *compiler, bool assignable)
}
static void
-uc_compiler_compile_binary(uc_compiler *compiler, bool assignable)
+uc_compiler_compile_binary(uc_compiler_t *compiler, bool assignable)
{
uc_tokentype_t type = compiler->parser->prev.type;
@@ -953,10 +953,10 @@ uc_compiler_compile_binary(uc_compiler *compiler, bool assignable)
}
static void
-uc_compiler_compile_delete(uc_compiler *compiler, bool assignable)
+uc_compiler_compile_delete(uc_compiler_t *compiler, bool assignable)
{
- uc_chunk *chunk = uc_compiler_current_chunk(compiler);
- enum insn_type type;
+ uc_chunk_t *chunk = uc_compiler_current_chunk(compiler);
+ uc_vm_insn_t type;
#ifndef NO_LEGACY
/* If the delete keyword is followed by an opening paren, it might be a
@@ -1006,10 +1006,10 @@ uc_compiler_compile_delete(uc_compiler *compiler, bool assignable)
}
}
-static enum insn_type
-uc_compiler_emit_variable_rw(uc_compiler *compiler, uc_value_t *varname, uc_tokentype_t type)
+static uc_vm_insn_t
+uc_compiler_emit_variable_rw(uc_compiler_t *compiler, uc_value_t *varname, uc_tokentype_t type)
{
- enum insn_type insn;
+ uc_vm_insn_t insn;
uint32_t sub_insn;
bool constant;
ssize_t idx;
@@ -1071,13 +1071,13 @@ uc_compiler_emit_variable_rw(uc_compiler *compiler, uc_value_t *varname, uc_toke
}
static void
-uc_compiler_compile_expression(uc_compiler *compiler)
+uc_compiler_compile_expression(uc_compiler_t *compiler)
{
uc_compiler_parse_precedence(compiler, P_COMMA);
}
static bool
-uc_compiler_compile_assignment(uc_compiler *compiler, uc_value_t *var)
+uc_compiler_compile_assignment(uc_compiler_t *compiler, uc_value_t *var)
{
uc_tokentype_t type = compiler->parser->curr.type;
@@ -1093,10 +1093,10 @@ uc_compiler_compile_assignment(uc_compiler *compiler, uc_value_t *var)
}
static bool
-uc_compiler_compile_arrowfn(uc_compiler *compiler, uc_value_t *args, bool restarg)
+uc_compiler_compile_arrowfn(uc_compiler_t *compiler, uc_value_t *args, bool restarg)
{
bool array = (ucv_type(args) == UC_ARRAY);
- uc_compiler fncompiler = { 0 };
+ uc_compiler_t fncompiler = { 0 };
size_t i, pos, load_off;
uc_function_t *fn;
ssize_t slot;
@@ -1174,7 +1174,7 @@ uc_compiler_compile_arrowfn(uc_compiler *compiler, uc_value_t *args, bool restar
}
static uc_tokentype_t
-uc_compiler_compile_var_or_arrowfn(uc_compiler *compiler, bool assignable, uc_value_t *name)
+uc_compiler_compile_var_or_arrowfn(uc_compiler_t *compiler, bool assignable, uc_value_t *name)
{
uc_tokentype_t rv;
@@ -1193,7 +1193,7 @@ uc_compiler_compile_var_or_arrowfn(uc_compiler *compiler, bool assignable, uc_va
}
static void
-uc_compiler_compile_paren(uc_compiler *compiler, bool assignable)
+uc_compiler_compile_paren(uc_compiler_t *compiler, bool assignable)
{
uc_value_t *varnames = NULL, *varname;
bool maybe_arrowfn = false;
@@ -1332,11 +1332,11 @@ out:
}
static void
-uc_compiler_compile_call(uc_compiler *compiler, bool assignable)
+uc_compiler_compile_call(uc_compiler_t *compiler, bool assignable)
{
- uc_chunk *chunk = uc_compiler_current_chunk(compiler);
- uc_jmplist spreads = { 0 };
- enum insn_type type;
+ uc_chunk_t *chunk = uc_compiler_current_chunk(compiler);
+ uc_jmplist_t spreads = { 0 };
+ uc_vm_insn_t type;
size_t i, nargs = 0;
/* determine the kind of the lhs */
@@ -1388,13 +1388,13 @@ uc_compiler_compile_call(uc_compiler *compiler, bool assignable)
}
static void
-uc_compiler_compile_post_inc(uc_compiler *compiler, bool assignable)
+uc_compiler_compile_post_inc(uc_compiler_t *compiler, bool assignable)
{
uc_compiler_emit_inc_dec(compiler, compiler->parser->prev.type, true);
}
static bool
-uc_compiler_is_use_strict_pragma(uc_compiler *compiler)
+uc_compiler_is_use_strict_pragma(uc_compiler_t *compiler)
{
uc_value_t *v;
@@ -1410,7 +1410,7 @@ uc_compiler_is_use_strict_pragma(uc_compiler *compiler)
}
static void
-uc_compiler_compile_constant(uc_compiler *compiler, bool assignable)
+uc_compiler_compile_constant(uc_compiler_t *compiler, bool assignable)
{
uc_function_t *fn;
int64_t n;
@@ -1475,14 +1475,14 @@ uc_compiler_compile_constant(uc_compiler *compiler, bool assignable)
}
static void
-uc_compiler_compile_comma(uc_compiler *compiler, bool assignable)
+uc_compiler_compile_comma(uc_compiler_t *compiler, bool assignable)
{
uc_compiler_emit_insn(compiler, 0, I_POP);
uc_compiler_parse_precedence(compiler, P_ASSIGN);
}
static void
-uc_compiler_compile_labelexpr(uc_compiler *compiler, bool assignable)
+uc_compiler_compile_labelexpr(uc_compiler_t *compiler, bool assignable)
{
uc_value_t *label = ucv_get(compiler->parser->prev.uv);
@@ -1491,7 +1491,7 @@ uc_compiler_compile_labelexpr(uc_compiler *compiler, bool assignable)
}
static bool
-uc_compiler_compile_delimitted_block(uc_compiler *compiler, uc_tokentype_t endtype)
+uc_compiler_compile_delimitted_block(uc_compiler_t *compiler, uc_tokentype_t endtype)
{
while (!uc_compiler_parse_check(compiler, endtype) &&
!uc_compiler_parse_check(compiler, TK_EOF))
@@ -1501,9 +1501,9 @@ uc_compiler_compile_delimitted_block(uc_compiler *compiler, uc_tokentype_t endty
}
static void
-uc_compiler_compile_function(uc_compiler *compiler, bool assignable)
+uc_compiler_compile_function(uc_compiler_t *compiler, bool assignable)
{
- uc_compiler fncompiler = { 0 };
+ uc_compiler_t fncompiler = { 0 };
uc_value_t *name = NULL;
ssize_t slot = -1, pos;
uc_tokentype_t type;
@@ -1609,9 +1609,9 @@ uc_compiler_compile_function(uc_compiler *compiler, bool assignable)
}
static void
-uc_compiler_compile_and(uc_compiler *compiler, bool assignable)
+uc_compiler_compile_and(uc_compiler_t *compiler, bool assignable)
{
- uc_chunk *chunk = uc_compiler_current_chunk(compiler);
+ uc_chunk_t *chunk = uc_compiler_current_chunk(compiler);
size_t jmpz_off;
uc_compiler_emit_insn(compiler, 0, I_COPY);
@@ -1623,9 +1623,9 @@ uc_compiler_compile_and(uc_compiler *compiler, bool assignable)
}
static void
-uc_compiler_compile_or(uc_compiler *compiler, bool assignable)
+uc_compiler_compile_or(uc_compiler_t *compiler, bool assignable)
{
- uc_chunk *chunk = uc_compiler_current_chunk(compiler);
+ uc_chunk_t *chunk = uc_compiler_current_chunk(compiler);
size_t jmpz_off, jmp_off;
uc_compiler_emit_insn(compiler, 0, I_COPY);
@@ -1639,7 +1639,7 @@ uc_compiler_compile_or(uc_compiler *compiler, bool assignable)
}
static void
-uc_compiler_compile_dot(uc_compiler *compiler, bool assignable)
+uc_compiler_compile_dot(uc_compiler_t *compiler, bool assignable)
{
/* no regexp literal possible after property access */
compiler->parser->lex.no_regexp = true;
@@ -1654,7 +1654,7 @@ uc_compiler_compile_dot(uc_compiler *compiler, bool assignable)
}
static void
-uc_compiler_compile_subscript(uc_compiler *compiler, bool assignable)
+uc_compiler_compile_subscript(uc_compiler_t *compiler, bool assignable)
{
/* compile lhs */
uc_compiler_compile_expression(compiler);
@@ -1669,9 +1669,9 @@ uc_compiler_compile_subscript(uc_compiler *compiler, bool assignable)
}
static void
-uc_compiler_compile_ternary(uc_compiler *compiler, bool assignable)
+uc_compiler_compile_ternary(uc_compiler_t *compiler, bool assignable)
{
- uc_chunk *chunk = uc_compiler_current_chunk(compiler);
+ uc_chunk_t *chunk = uc_compiler_current_chunk(compiler);
size_t jmpz_off, jmp_off;
/* jump to false branch */
@@ -1692,7 +1692,7 @@ uc_compiler_compile_ternary(uc_compiler *compiler, bool assignable)
}
static void
-uc_compiler_compile_array(uc_compiler *compiler, bool assignable)
+uc_compiler_compile_array(uc_compiler_t *compiler, bool assignable)
{
size_t hint_off, hint_count = 0, len = 0;
@@ -1751,7 +1751,7 @@ uc_compiler_compile_array(uc_compiler *compiler, bool assignable)
}
static void
-uc_compiler_compile_object(uc_compiler *compiler, bool assignable)
+uc_compiler_compile_object(uc_compiler_t *compiler, bool assignable)
{
size_t hint_off, hint_count = 0, len = 0;
@@ -1857,7 +1857,7 @@ uc_compiler_compile_object(uc_compiler *compiler, bool assignable)
static void
-uc_compiler_declare_local_null(uc_compiler *compiler, size_t srcpos, uc_value_t *varname)
+uc_compiler_declare_local_null(uc_compiler_t *compiler, size_t srcpos, uc_value_t *varname)
{
ssize_t existing_slot = uc_compiler_declare_local(compiler, varname, false);
@@ -1874,10 +1874,10 @@ uc_compiler_declare_local_null(uc_compiler *compiler, size_t srcpos, uc_value_t
}
static size_t
-uc_compiler_declare_internal(uc_compiler *compiler, size_t srcpos, const char *name)
+uc_compiler_declare_internal(uc_compiler_t *compiler, size_t srcpos, const char *name)
{
- uc_chunk *chunk = uc_compiler_current_chunk(compiler);
- uc_locals *locals = &compiler->locals;
+ uc_chunk_t *chunk = uc_compiler_current_chunk(compiler);
+ uc_locals_t *locals = &compiler->locals;
uc_vector_grow(locals);
@@ -1890,7 +1890,7 @@ uc_compiler_declare_internal(uc_compiler *compiler, size_t srcpos, const char *n
}
static void
-uc_compiler_compile_declexpr(uc_compiler *compiler, bool constant)
+uc_compiler_compile_declexpr(uc_compiler_t *compiler, bool constant)
{
ssize_t slot;
@@ -1932,21 +1932,21 @@ uc_compiler_compile_declexpr(uc_compiler *compiler, bool constant)
}
static void
-uc_compiler_compile_local(uc_compiler *compiler)
+uc_compiler_compile_local(uc_compiler_t *compiler)
{
uc_compiler_compile_declexpr(compiler, false);
uc_compiler_parse_consume(compiler, TK_SCOL);
}
static void
-uc_compiler_compile_const(uc_compiler *compiler)
+uc_compiler_compile_const(uc_compiler_t *compiler)
{
uc_compiler_compile_declexpr(compiler, true);
uc_compiler_parse_consume(compiler, TK_SCOL);
}
static uc_tokentype_t
-uc_compiler_compile_altifblock(uc_compiler *compiler)
+uc_compiler_compile_altifblock(uc_compiler_t *compiler)
{
uc_compiler_enter_scope(compiler);
@@ -1970,12 +1970,12 @@ uc_compiler_compile_altifblock(uc_compiler *compiler)
}
static void
-uc_compiler_compile_if(uc_compiler *compiler)
+uc_compiler_compile_if(uc_compiler_t *compiler)
{
- uc_chunk *chunk = uc_compiler_current_chunk(compiler);
+ uc_chunk_t *chunk = uc_compiler_current_chunk(compiler);
size_t jmpz_off, jmp_off, i;
bool expect_endif = false;
- uc_jmplist elifs = { 0 };
+ uc_jmplist_t elifs = { 0 };
uc_tokentype_t type;
/* parse & compile condition expression */
@@ -2076,10 +2076,10 @@ uc_compiler_compile_if(uc_compiler *compiler)
}
static void
-uc_compiler_compile_while(uc_compiler *compiler)
+uc_compiler_compile_while(uc_compiler_t *compiler)
{
- uc_chunk *chunk = uc_compiler_current_chunk(compiler);
- uc_patchlist p = { .depth = compiler->scope_depth };
+ uc_chunk_t *chunk = uc_compiler_current_chunk(compiler);
+ uc_patchlist_t p = { .depth = compiler->scope_depth };
size_t cond_off, jmpz_off, end_off;
p.parent = compiler->patchlist;
@@ -2124,10 +2124,10 @@ uc_compiler_compile_while(uc_compiler *compiler)
}
static void
-uc_compiler_compile_for_in(uc_compiler *compiler, bool local, uc_token *kvar, uc_token *vvar)
+uc_compiler_compile_for_in(uc_compiler_t *compiler, bool local, uc_token_t *kvar, uc_token_t *vvar)
{
- uc_chunk *chunk = uc_compiler_current_chunk(compiler);
- uc_patchlist p = { .depth = compiler->scope_depth + 1 };
+ uc_chunk_t *chunk = uc_compiler_current_chunk(compiler);
+ uc_patchlist_t p = { .depth = compiler->scope_depth + 1 };
size_t skip_jmp, test_jmp, key_slot, val_slot;
p.parent = compiler->patchlist;
@@ -2234,11 +2234,11 @@ uc_compiler_compile_for_in(uc_compiler *compiler, bool local, uc_token *kvar, uc
}
static void
-uc_compiler_compile_for_count(uc_compiler *compiler, bool local, uc_token *var)
+uc_compiler_compile_for_count(uc_compiler_t *compiler, bool local, uc_token_t *var)
{
- uc_chunk *chunk = uc_compiler_current_chunk(compiler);
+ uc_chunk_t *chunk = uc_compiler_current_chunk(compiler);
size_t test_off = 0, incr_off, skip_off, cond_off = 0;
- uc_patchlist p = { .depth = compiler->scope_depth + 1 };
+ uc_patchlist_t p = { .depth = compiler->scope_depth + 1 };
p.parent = compiler->patchlist;
compiler->patchlist = &p;
@@ -2343,9 +2343,9 @@ uc_compiler_compile_for_count(uc_compiler *compiler, bool local, uc_token *var)
}
static void
-uc_compiler_compile_for(uc_compiler *compiler)
+uc_compiler_compile_for(uc_compiler_t *compiler)
{
- uc_token keyvar = { 0 }, valvar = { 0 };
+ uc_token_t keyvar = { 0 }, valvar = { 0 };
bool local;
uc_compiler_parse_consume(compiler, TK_LPAREN);
@@ -2395,13 +2395,13 @@ out:
}
static void
-uc_compiler_compile_switch(uc_compiler *compiler)
+uc_compiler_compile_switch(uc_compiler_t *compiler)
{
size_t i, test_jmp, skip_jmp, next_jmp, value_slot, default_off = 0;
- uc_chunk *chunk = uc_compiler_current_chunk(compiler);
- uc_patchlist p = { .depth = compiler->scope_depth };
- uc_locals *locals = &compiler->locals;
- uc_jmplist cases = { 0 };
+ uc_chunk_t *chunk = uc_compiler_current_chunk(compiler);
+ uc_patchlist_t p = { .depth = compiler->scope_depth };
+ uc_locals_t *locals = &compiler->locals;
+ uc_jmplist_t cases = { 0 };
p.parent = compiler->patchlist;
compiler->patchlist = &p;
@@ -2566,11 +2566,11 @@ uc_compiler_compile_switch(uc_compiler *compiler)
}
static void
-uc_compiler_compile_try(uc_compiler *compiler)
+uc_compiler_compile_try(uc_compiler_t *compiler)
{
- uc_chunk *chunk = uc_compiler_current_chunk(compiler);
+ uc_chunk_t *chunk = uc_compiler_current_chunk(compiler);
size_t try_from = 0, try_to = 0, jmp_off = 0, ehvar_slot = 0;
- uc_ehranges *ranges = &chunk->ehranges;
+ uc_ehranges_t *ranges = &chunk->ehranges;
try_from = chunk->count;
ehvar_slot = compiler->locals.count;
@@ -2636,12 +2636,12 @@ uc_compiler_compile_try(uc_compiler *compiler)
}
static void
-uc_compiler_compile_control(uc_compiler *compiler)
+uc_compiler_compile_control(uc_compiler_t *compiler)
{
- uc_chunk *chunk = uc_compiler_current_chunk(compiler);
+ uc_chunk_t *chunk = uc_compiler_current_chunk(compiler);
uc_tokentype_t type = compiler->parser->prev.type;
- uc_patchlist *p = compiler->patchlist;
- uc_locals *locals = &compiler->locals;
+ uc_patchlist_t *p = compiler->patchlist;
+ uc_locals_t *locals = &compiler->locals;
size_t i, pos = compiler->parser->prev.pos;
if (!p) {
@@ -2666,9 +2666,9 @@ uc_compiler_compile_control(uc_compiler *compiler)
}
static void
-uc_compiler_compile_return(uc_compiler *compiler)
+uc_compiler_compile_return(uc_compiler_t *compiler)
{
- uc_chunk *chunk = uc_compiler_current_chunk(compiler);
+ uc_chunk_t *chunk = uc_compiler_current_chunk(compiler);
size_t off = chunk->count;
uc_compiler_compile_expstmt(compiler);
@@ -2684,9 +2684,9 @@ uc_compiler_compile_return(uc_compiler *compiler)
}
static void
-uc_compiler_compile_tplexp(uc_compiler *compiler)
+uc_compiler_compile_tplexp(uc_compiler_t *compiler)
{
- uc_chunk *chunk = uc_compiler_current_chunk(compiler);
+ uc_chunk_t *chunk = uc_compiler_current_chunk(compiler);
size_t off = chunk->count;
uc_compiler_compile_expression(compiler);
@@ -2701,14 +2701,14 @@ uc_compiler_compile_tplexp(uc_compiler *compiler)
}
static void
-uc_compiler_compile_text(uc_compiler *compiler)
+uc_compiler_compile_text(uc_compiler_t *compiler)
{
uc_compiler_emit_constant(compiler, compiler->parser->prev.pos, compiler->parser->prev.uv);
uc_compiler_emit_insn(compiler, 0, I_PRINT);
}
static void
-uc_compiler_compile_block(uc_compiler *compiler)
+uc_compiler_compile_block(uc_compiler_t *compiler)
{
uc_compiler_enter_scope(compiler);
@@ -2722,7 +2722,7 @@ uc_compiler_compile_block(uc_compiler *compiler)
}
static void
-uc_compiler_compile_expstmt(uc_compiler *compiler)
+uc_compiler_compile_expstmt(uc_compiler_t *compiler)
{
/* empty statement */
if (uc_compiler_parse_match(compiler, TK_SCOL))
@@ -2752,7 +2752,7 @@ uc_compiler_compile_expstmt(uc_compiler *compiler)
}
static void
-uc_compiler_compile_statement(uc_compiler *compiler)
+uc_compiler_compile_statement(uc_compiler_t *compiler)
{
if (uc_compiler_parse_match(compiler, TK_IF))
uc_compiler_compile_if(compiler);
@@ -2783,7 +2783,7 @@ uc_compiler_compile_statement(uc_compiler *compiler)
}
static void
-uc_compiler_compile_declaration(uc_compiler *compiler)
+uc_compiler_compile_declaration(uc_compiler_t *compiler)
{
if (uc_compiler_parse_match(compiler, TK_LOCAL))
uc_compiler_compile_local(compiler);
@@ -2797,10 +2797,10 @@ uc_compiler_compile_declaration(uc_compiler *compiler)
}
uc_function_t *
-uc_compile(uc_parse_config *config, uc_source *source, char **errp)
+uc_compile(uc_parse_config_t *config, uc_source_t *source, char **errp)
{
- uc_parser parser = { .config = config };
- uc_compiler compiler = { .parser = &parser };
+ uc_parser_t parser = { .config = config };
+ uc_compiler_t compiler = { .parser = &parser };
uc_function_t *fn;
uc_lexer_init(&parser.lex, config, source);
diff --git a/compiler.h b/compiler.h
index 54f56c2..19fcf37 100644
--- a/compiler.h
+++ b/compiler.h
@@ -64,12 +64,10 @@ typedef enum {
P_PRIMARY /* (…) */
} uc_precedence_t;
-struct uc_patchlist {
+typedef struct uc_patchlist {
struct uc_patchlist *parent;
size_t depth, count, *entries;
-};
-
-typedef struct uc_patchlist uc_patchlist;
+} uc_patchlist_t;
typedef struct {
uc_value_t *name;
@@ -77,45 +75,43 @@ typedef struct {
size_t from;
bool captured;
bool constant;
-} uc_local;
+} uc_local_t;
typedef struct {
uc_value_t *name;
size_t index;
bool local;
bool constant;
-} uc_upval;
+} uc_upval_t;
-uc_declare_vector(uc_locals, uc_local);
-uc_declare_vector(uc_upvals, uc_upval);
-uc_declare_vector(uc_jmplist, size_t);
+uc_declare_vector(uc_locals_t, uc_local_t);
+uc_declare_vector(uc_upvals_t, uc_upval_t);
+uc_declare_vector(uc_jmplist_t, size_t);
typedef struct {
- uc_parse_config *config;
- uc_lexer lex;
- uc_token prev, curr;
+ uc_parse_config_t *config;
+ uc_lexer_t lex;
+ uc_token_t prev, curr;
bool synchronizing;
uc_stringbuf_t *error;
-} uc_parser;
+} uc_parser_t;
-struct uc_compiler {
+typedef struct uc_compiler {
struct uc_compiler *parent;
- uc_locals locals;
- uc_upvals upvals;
- uc_patchlist *patchlist;
+ uc_locals_t locals;
+ uc_upvals_t upvals;
+ uc_patchlist_t *patchlist;
uc_value_t *function;
- uc_parser *parser;
+ uc_parser_t *parser;
size_t scope_depth, current_srcpos, last_insn;
-};
-
-typedef struct uc_compiler uc_compiler;
+} uc_compiler_t;
typedef struct {
- void (*prefix)(uc_compiler *, bool);
- void (*infix)(uc_compiler *, bool);
+ void (*prefix)(uc_compiler_t *, bool);
+ void (*infix)(uc_compiler_t *, bool);
uc_precedence_t precedence;
-} uc_parse_rule;
+} uc_parse_rule_t;
-uc_function_t *uc_compile(uc_parse_config *config, uc_source *source, char **errp);
+uc_function_t *uc_compile(uc_parse_config_t *config, uc_source_t *source, char **errp);
#endif /* __COMPILER_H_ */
diff --git a/lexer.c b/lexer.c
index 2ba2017..8e6378a 100644
--- a/lexer.c
+++ b/lexer.c
@@ -44,7 +44,7 @@ struct token {
char pat[4];
} u;
unsigned plen;
- uc_token *(*parse)(uc_lexer *);
+ uc_token_t *(*parse)(uc_lexer_t *);
};
#define dec(o) \
@@ -54,11 +54,11 @@ struct token {
(((x) >= 'a') ? (10 + (x) - 'a') : \
(((x) >= 'A') ? (10 + (x) - 'A') : dec(x)))
-static uc_token *parse_comment(uc_lexer *);
-static uc_token *parse_string(uc_lexer *);
-static uc_token *parse_regexp(uc_lexer *);
-static uc_token *parse_number(uc_lexer *);
-static uc_token *parse_label(uc_lexer *);
+static uc_token_t *parse_comment(uc_lexer_t *);
+static uc_token_t *parse_string(uc_lexer_t *);
+static uc_token_t *parse_regexp(uc_lexer_t *);
+static uc_token_t *parse_number(uc_lexer_t *);
+static uc_token_t *parse_label(uc_lexer_t *);
static const struct token tokens[] = {
{ TK_ASLEFT, { .pat = "<<=" }, 3, NULL },
@@ -220,8 +220,8 @@ utf8enc(char **out, int *rem, int code)
/* length of the longest token in our lookup table */
#define UC_LEX_MAX_TOKEN_LEN 3
-static uc_token *
-emit_op(uc_lexer *lex, uint32_t pos, int type, uc_value_t *uv)
+static uc_token_t *
+emit_op(uc_lexer_t *lex, uint32_t pos, int type, uc_value_t *uv)
{
lex->curr.type = type;
lex->curr.uv = uv;
@@ -230,7 +230,7 @@ emit_op(uc_lexer *lex, uint32_t pos, int type, uc_value_t *uv)
return &lex->curr;
}
-static void lookbehind_append(uc_lexer *lex, const char *data, size_t len)
+static void lookbehind_append(uc_lexer_t *lex, const char *data, size_t len)
{
if (len) {
lex->lookbehind = xrealloc(lex->lookbehind, lex->lookbehindlen + len);
@@ -239,15 +239,15 @@ static void lookbehind_append(uc_lexer *lex, const char *data, size_t len)
}
}
-static void lookbehind_reset(uc_lexer *lex) {
+static void lookbehind_reset(uc_lexer_t *lex) {
free(lex->lookbehind);
lex->lookbehind = NULL;
lex->lookbehindlen = 0;
}
-static uc_token *
-lookbehind_to_text(uc_lexer *lex, uint32_t pos, int type, const char *strip_trailing_chars) {
- uc_token *rv = NULL;
+static uc_token_t *
+lookbehind_to_text(uc_lexer_t *lex, uint32_t pos, int type, const char *strip_trailing_chars) {
+ uc_token_t *rv = NULL;
if (lex->lookbehind) {
if (strip_trailing_chars) {
@@ -264,12 +264,12 @@ lookbehind_to_text(uc_lexer *lex, uint32_t pos, int type, const char *strip_trai
}
static inline size_t
-buf_remaining(uc_lexer *lex) {
+buf_remaining(uc_lexer_t *lex) {
return (lex->bufend - lex->bufstart);
}
static inline bool
-_buf_startswith(uc_lexer *lex, const char *str, size_t len) {
+_buf_startswith(uc_lexer_t *lex, const char *str, size_t len) {
return (buf_remaining(lex) >= len && !strncmp(lex->bufstart, str, len));
}
@@ -290,18 +290,18 @@ _buf_startswith(uc_lexer *lex, const char *str, size_t len) {
*/
static void
-next_lineinfo(uc_lexer *lex)
+next_lineinfo(uc_lexer_t *lex)
{
- uc_lineinfo *lines = &lex->source->lineinfo;
+ uc_lineinfo_t *lines = &lex->source->lineinfo;
uc_vector_grow(lines);
lines->entries[lines->count++] = 0x80;
}
static void
-update_lineinfo(uc_lexer *lex, size_t off)
+update_lineinfo(uc_lexer_t *lex, size_t off)
{
- uc_lineinfo *lines = &lex->source->lineinfo;
+ uc_lineinfo_t *lines = &lex->source->lineinfo;
uint8_t *entry, n;
entry = uc_vector_last(lines);
@@ -325,7 +325,7 @@ update_lineinfo(uc_lexer *lex, size_t off)
}
static void
-buf_consume(uc_lexer *lex, size_t len) {
+buf_consume(uc_lexer_t *lex, size_t len) {
size_t i, linelen;
if (!lex->source->lineinfo.count)
@@ -350,8 +350,8 @@ buf_consume(uc_lexer *lex, size_t len) {
lex->source->off += len;
}
-static uc_token *
-parse_comment(uc_lexer *lex)
+static uc_token_t *
+parse_comment(uc_lexer_t *lex)
{
const struct token *tok = lex->tok;
const char *ptr, *end;
@@ -387,7 +387,7 @@ parse_comment(uc_lexer *lex)
}
static void
-append_utf8(uc_lexer *lex, int code) {
+append_utf8(uc_lexer_t *lex, int code) {
char ustr[8], *up;
int rem;
@@ -398,13 +398,13 @@ append_utf8(uc_lexer *lex, int code) {
lookbehind_append(lex, ustr, up - ustr);
}
-static uc_token *
-parse_string(uc_lexer *lex)
+static uc_token_t *
+parse_string(uc_lexer_t *lex)
{
const struct token *tok = lex->tok;
char q = tok->u.pat[0];
char *ptr, *c;
- uc_token *rv;
+ uc_token_t *rv;
int code;
if (!buf_remaining(lex))
@@ -626,11 +626,11 @@ enum {
UC_LEX_PARSE_REGEX_FLAGS
};
-static uc_token *
-parse_regexp(uc_lexer *lex)
+static uc_token_t *
+parse_regexp(uc_lexer_t *lex)
{
bool is_reg_global = false, is_reg_icase = false, is_reg_newline = false;
- uc_token *rv;
+ uc_token_t *rv;
size_t len;
char *s;
@@ -663,7 +663,7 @@ parse_regexp(uc_lexer *lex)
break;
case UC_LEX_PARSE_REGEX_FLAGS:
- rv = (uc_token *)lex->lookbehind;
+ rv = (uc_token_t *)lex->lookbehind;
while (lex->bufstart < lex->bufend || lex->eof) {
switch (lex->eof ? EOF : lex->bufstart[0]) {
@@ -717,8 +717,8 @@ parse_regexp(uc_lexer *lex)
* -UC_ERROR_OVERLONG_STRING Label too long
*/
-static uc_token *
-parse_label(uc_lexer *lex)
+static uc_token_t *
+parse_label(uc_lexer_t *lex)
{
const struct token *tok = lex->tok;
const struct keyword *word;
@@ -763,7 +763,7 @@ parse_label(uc_lexer *lex)
*/
static inline bool
-is_numeric_char(uc_lexer *lex, char c)
+is_numeric_char(uc_lexer_t *lex, char c)
{
char prev = lex->lookbehindlen ? lex->lookbehind[lex->lookbehindlen-1] : 0;
@@ -773,11 +773,11 @@ is_numeric_char(uc_lexer *lex, char c)
return prev ? (isxdigit(c) || c == 'x' || c == 'X' || c == '.') : (isdigit(c) || c == '.');
}
-static uc_token *
-parse_number(uc_lexer *lex)
+static uc_token_t *
+parse_number(uc_lexer_t *lex)
{
const struct token *tok = lex->tok;
- uc_token *rv = NULL;
+ uc_token_t *rv = NULL;
long long int n;
char *ptr, *e;
double d;
@@ -826,15 +826,15 @@ parse_number(uc_lexer *lex)
return NULL;
}
-static uc_token *
-lex_step(uc_lexer *lex, FILE *fp)
+static uc_token_t *
+lex_step(uc_lexer_t *lex, FILE *fp)
{
uint32_t masks[] = { 0, le32toh(0x000000ff), le32toh(0x0000ffff), le32toh(0x00ffffff), le32toh(0xffffffff) };
union { uint32_t n; char str[4]; } search;
const struct token *tok;
size_t rlen, rem;
char *ptr, c;
- uc_token *rv;
+ uc_token_t *rv;
size_t i;
/* only less than UC_LEX_MAX_TOKEN_LEN unread buffer chars remaining,
@@ -1132,9 +1132,9 @@ lex_step(uc_lexer *lex, FILE *fp)
}
static void
-uc_lexer_skip_shebang(uc_lexer *lex)
+uc_lexer_skip_shebang(uc_lexer_t *lex)
{
- uc_source *source = lex->source;
+ uc_source_t *source = lex->source;
FILE *fp = source->fp;
int c1, c2;
@@ -1164,7 +1164,7 @@ uc_lexer_skip_shebang(uc_lexer *lex)
}
void
-uc_lexer_init(uc_lexer *lex, uc_parse_config *config, uc_source *source)
+uc_lexer_init(uc_lexer_t *lex, uc_parse_config_t *config, uc_source_t *source)
{
lex->state = UC_LEX_IDENTIFY_BLOCK;
@@ -1205,7 +1205,7 @@ uc_lexer_init(uc_lexer *lex, uc_parse_config *config, uc_source *source)
}
void
-uc_lexer_free(uc_lexer *lex)
+uc_lexer_free(uc_lexer_t *lex)
{
uc_source_put(lex->source);
@@ -1213,10 +1213,10 @@ uc_lexer_free(uc_lexer *lex)
free(lex->buf);
}
-uc_token *
-uc_lexer_next_token(uc_lexer *lex)
+uc_token_t *
+uc_lexer_next_token(uc_lexer_t *lex)
{
- uc_token *rv = NULL;
+ uc_token_t *rv = NULL;
while (lex->state != UC_LEX_EOF) {
rv = lex_step(lex, lex->source->fp);
diff --git a/lexer.h b/lexer.h
index 694c056..1b19b60 100644
--- a/lexer.h
+++ b/lexer.h
@@ -127,12 +127,12 @@ typedef struct {
uc_tokentype_t type;
uc_value_t *uv;
size_t pos;
-} uc_token;
+} uc_token_t;
typedef struct {
uc_lex_state_t state;
- uc_parse_config *config;
- uc_source *source;
+ uc_parse_config_t *config;
+ uc_source_t *source;
uint8_t eof:1;
uint8_t is_escape:1;
uint8_t no_regexp:1;
@@ -142,7 +142,7 @@ typedef struct {
size_t lookbehindlen;
char *lookbehind;
const void *tok;
- uc_token curr;
+ uc_token_t curr;
char esc[5];
uint8_t esclen;
int lead_surrogate;
@@ -159,13 +159,13 @@ typedef struct {
STATEMENTS = '%',
COMMENT = '#'
} block;
-} uc_lexer;
+} uc_lexer_t;
-void uc_lexer_init(uc_lexer *lex, uc_parse_config *config, uc_source *source);
-void uc_lexer_free(uc_lexer *lex);
+void uc_lexer_init(uc_lexer_t *lex, uc_parse_config_t *config, uc_source_t *source);
+void uc_lexer_free(uc_lexer_t *lex);
-uc_token *uc_lexer_next_token(uc_lexer *lex);
+uc_token_t *uc_lexer_next_token(uc_lexer_t *lex);
bool utf8enc(char **out, int *rem, int code);
diff --git a/lib.c b/lib.c
index cd0f582..ebdd1af 100644
--- a/lib.c
+++ b/lib.c
@@ -94,7 +94,7 @@ format_context_line(uc_stringbuf_t *buf, const char *line, size_t off, bool comp
}
static char *
-source_filename(uc_source *src, uint32_t line)
+source_filename(uc_source_t *src, uint32_t line)
{
const char *name = src->filename ? basename(src->filename) : "[?]";
static char buf[sizeof("xxxxxxxxx.uc:0000000000")];
@@ -109,7 +109,7 @@ source_filename(uc_source *src, uint32_t line)
}
bool
-format_source_context(uc_stringbuf_t *buf, uc_source *src, size_t off, bool compact)
+format_source_context(uc_stringbuf_t *buf, uc_source_t *src, size_t off, bool compact)
{
size_t len, rlen;
bool truncated;
@@ -155,7 +155,7 @@ format_source_context(uc_stringbuf_t *buf, uc_source *src, size_t off, bool comp
}
bool
-format_error_context(uc_stringbuf_t *buf, uc_source *src, uc_value_t *stacktrace, size_t off)
+format_error_context(uc_stringbuf_t *buf, uc_source_t *src, uc_value_t *stacktrace, size_t off)
{
uc_value_t *e, *fn, *file, *line, *byte;
const char *path;
@@ -204,7 +204,7 @@ format_error_context(uc_stringbuf_t *buf, uc_source *src, uc_value_t *stacktrace
return format_source_context(buf, src, off, false);
}
-static char *uc_cast_string(uc_vm *vm, uc_value_t **v, bool *freeable) {
+static char *uc_cast_string(uc_vm_t *vm, uc_value_t **v, bool *freeable) {
if (ucv_type(*v) == UC_STRING) {
*freeable = false;
@@ -263,7 +263,7 @@ uc_cast_int64(uc_value_t *v)
}
static void
-uc_vm_ctx_push(uc_vm *vm)
+uc_vm_ctx_push(uc_vm_t *vm)
{
uc_value_t *ctx = NULL;
@@ -274,7 +274,7 @@ uc_vm_ctx_push(uc_vm *vm)
}
static uc_value_t *
-uc_print_common(uc_vm *vm, size_t nargs, FILE *fh)
+uc_print_common(uc_vm_t *vm, size_t nargs, FILE *fh)
{
uc_value_t *item;
size_t reslen = 0;
@@ -302,13 +302,13 @@ uc_print_common(uc_vm *vm, size_t nargs, FILE *fh)
static uc_value_t *
-uc_print(uc_vm *vm, size_t nargs)
+uc_print(uc_vm_t *vm, size_t nargs)
{
return uc_print_common(vm, nargs, vm->output);
}
static uc_value_t *
-uc_length(uc_vm *vm, size_t nargs)
+uc_length(uc_vm_t *vm, size_t nargs)
{
uc_value_t *arg = uc_get_arg(0);
@@ -328,7 +328,7 @@ uc_length(uc_vm *vm, size_t nargs)
}
static uc_value_t *
-uc_index(uc_vm *vm, size_t nargs, bool right)
+uc_index(uc_vm_t *vm, size_t nargs, bool right)
{
uc_value_t *stack = uc_get_arg(0);
uc_value_t *needle = uc_get_arg(1);
@@ -371,19 +371,19 @@ uc_index(uc_vm *vm, size_t nargs, bool right)
}
static uc_value_t *
-uc_lindex(uc_vm *vm, size_t nargs)
+uc_lindex(uc_vm_t *vm, size_t nargs)
{
return uc_index(vm, nargs, false);
}
static uc_value_t *
-uc_rindex(uc_vm *vm, size_t nargs)
+uc_rindex(uc_vm_t *vm, size_t nargs)
{
return uc_index(vm, nargs, true);
}
static uc_value_t *
-uc_push(uc_vm *vm, size_t nargs)
+uc_push(uc_vm_t *vm, size_t nargs)
{
uc_value_t *arr = uc_get_arg(0);
uc_value_t *item = NULL;
@@ -401,7 +401,7 @@ uc_push(uc_vm *vm, size_t nargs)
}
static uc_value_t *
-uc_pop(uc_vm *vm, size_t nargs)
+uc_pop(uc_vm_t *vm, size_t nargs)
{
uc_value_t *arr = uc_get_arg(0);
@@ -409,7 +409,7 @@ uc_pop(uc_vm *vm, size_t nargs)
}
static uc_value_t *
-uc_shift(uc_vm *vm, size_t nargs)
+uc_shift(uc_vm_t *vm, size_t nargs)
{
uc_value_t *arr = uc_get_arg(0);
@@ -417,7 +417,7 @@ uc_shift(uc_vm *vm, size_t nargs)
}
static uc_value_t *
-uc_unshift(uc_vm *vm, size_t nargs)
+uc_unshift(uc_vm_t *vm, size_t nargs)
{
uc_value_t *arr = uc_get_arg(0);
uc_value_t *item = NULL;
@@ -435,7 +435,7 @@ uc_unshift(uc_vm *vm, size_t nargs)
}
static uc_value_t *
-uc_chr(uc_vm *vm, size_t nargs)
+uc_chr(uc_vm_t *vm, size_t nargs)
{
uc_value_t *rv = NULL;
size_t idx;
@@ -465,7 +465,7 @@ uc_chr(uc_vm *vm, size_t nargs)
}
static uc_value_t *
-uc_die(uc_vm *vm, size_t nargs)
+uc_die(uc_vm_t *vm, size_t nargs)
{
uc_value_t *msg = uc_get_arg(0);
bool freeable = false;
@@ -482,7 +482,7 @@ uc_die(uc_vm *vm, size_t nargs)
}
static uc_value_t *
-uc_exists(uc_vm *vm, size_t nargs)
+uc_exists(uc_vm_t *vm, size_t nargs)
{
uc_value_t *obj = uc_get_arg(0);
uc_value_t *key = uc_get_arg(1);
@@ -503,7 +503,7 @@ uc_exists(uc_vm *vm, size_t nargs)
}
static uc_value_t *
-uc_exit(uc_vm *vm, size_t nargs)
+uc_exit(uc_vm_t *vm, size_t nargs)
{
int64_t n = uc_cast_int64(uc_get_arg(0));
@@ -514,7 +514,7 @@ uc_exit(uc_vm *vm, size_t nargs)
}
static uc_value_t *
-uc_getenv(uc_vm *vm, size_t nargs)
+uc_getenv(uc_vm_t *vm, size_t nargs)
{
uc_value_t *key = uc_get_arg(0);
char *k = ucv_string_get(key);
@@ -524,7 +524,7 @@ uc_getenv(uc_vm *vm, size_t nargs)
}
static uc_value_t *
-uc_filter(uc_vm *vm, size_t nargs)
+uc_filter(uc_vm_t *vm, size_t nargs)
{
uc_value_t *obj = uc_get_arg(0);
uc_value_t *func = uc_get_arg(1);
@@ -561,7 +561,7 @@ uc_filter(uc_vm *vm, size_t nargs)
}
static uc_value_t *
-uc_hex(uc_vm *vm, size_t nargs)
+uc_hex(uc_vm_t *vm, size_t nargs)
{
uc_value_t *val = uc_get_arg(0);
char *e, *v;
@@ -581,7 +581,7 @@ uc_hex(uc_vm *vm, size_t nargs)
}
static uc_value_t *
-uc_int(uc_vm *vm, size_t nargs)
+uc_int(uc_vm_t *vm, size_t nargs)
{
int64_t n = uc_cast_int64(uc_get_arg(0));
@@ -592,7 +592,7 @@ uc_int(uc_vm *vm, size_t nargs)
}
static uc_value_t *
-uc_join(uc_vm *vm, size_t nargs)
+uc_join(uc_vm_t *vm, size_t nargs)
{
uc_value_t *sep = uc_get_arg(0);
uc_value_t *arr = uc_get_arg(1);
@@ -615,7 +615,7 @@ uc_join(uc_vm *vm, size_t nargs)
}
static uc_value_t *
-uc_keys(uc_vm *vm, size_t nargs)
+uc_keys(uc_vm_t *vm, size_t nargs)
{
uc_value_t *obj = uc_get_arg(0);
uc_value_t *arr = NULL;
@@ -634,7 +634,7 @@ uc_keys(uc_vm *vm, size_t nargs)
}
static uc_value_t *
-uc_lc(uc_vm *vm, size_t nargs)
+uc_lc(uc_vm_t *vm, size_t nargs)
{
char *str = ucv_to_string(vm, uc_get_arg(0));
uc_value_t *rv = NULL;
@@ -655,7 +655,7 @@ uc_lc(uc_vm *vm, size_t nargs)
}
static uc_value_t *
-uc_map(uc_vm *vm, size_t nargs)
+uc_map(uc_vm_t *vm, size_t nargs)
{
uc_value_t *obj = uc_get_arg(0);
uc_value_t *func = uc_get_arg(1);
@@ -689,7 +689,7 @@ uc_map(uc_vm *vm, size_t nargs)
}
static uc_value_t *
-uc_ord(uc_vm *vm, size_t nargs)
+uc_ord(uc_vm_t *vm, size_t nargs)
{
uc_value_t *obj = uc_get_arg(0);
uc_value_t *rv, *pos;
@@ -730,7 +730,7 @@ uc_ord(uc_vm *vm, size_t nargs)
}
static uc_value_t *
-uc_type(uc_vm *vm, size_t nargs)
+uc_type(uc_vm_t *vm, size_t nargs)
{
uc_value_t *v = uc_get_arg(0);
uc_type_t t = ucv_type(v);
@@ -756,7 +756,7 @@ uc_type(uc_vm *vm, size_t nargs)
}
static uc_value_t *
-uc_reverse(uc_vm *vm, size_t nargs)
+uc_reverse(uc_vm_t *vm, size_t nargs)
{
uc_value_t *obj = uc_get_arg(0);
uc_value_t *rv = NULL;
@@ -788,7 +788,7 @@ uc_reverse(uc_vm *vm, size_t nargs)
static struct {
- uc_vm *vm;
+ uc_vm_t *vm;
bool ex;
uc_value_t *fn;
} sort_ctx;
@@ -891,7 +891,7 @@ sort_fn(const void *k1, const void *k2)
}
static uc_value_t *
-uc_sort(uc_vm *vm, size_t nargs)
+uc_sort(uc_vm_t *vm, size_t nargs)
{
uc_value_t *arr = uc_get_arg(0);
uc_value_t *fn = uc_get_arg(1);
@@ -908,7 +908,7 @@ uc_sort(uc_vm *vm, size_t nargs)
}
static uc_value_t *
-uc_splice(uc_vm *vm, size_t nargs)
+uc_splice(uc_vm_t *vm, size_t nargs)
{
uc_value_t *arr = uc_get_arg(0);
int64_t ofs = uc_cast_int64(uc_get_arg(1));
@@ -981,7 +981,7 @@ uc_splice(uc_vm *vm, size_t nargs)
}
static uc_value_t *
-uc_split(uc_vm *vm, size_t nargs)
+uc_split(uc_vm_t *vm, size_t nargs)
{
uc_value_t *str = uc_get_arg(0);
uc_value_t *sep = uc_get_arg(1);
@@ -1040,7 +1040,7 @@ uc_split(uc_vm *vm, size_t nargs)
}
static uc_value_t *
-uc_substr(uc_vm *vm, size_t nargs)
+uc_substr(uc_vm_t *vm, size_t nargs)
{
uc_value_t *str = uc_get_arg(0);
int64_t ofs = uc_cast_int64(uc_get_arg(1));
@@ -1104,7 +1104,7 @@ uc_substr(uc_vm *vm, size_t nargs)
}
static uc_value_t *
-uc_time(uc_vm *vm, size_t nargs)
+uc_time(uc_vm_t *vm, size_t nargs)
{
time_t t = time(NULL);
@@ -1112,7 +1112,7 @@ uc_time(uc_vm *vm, size_t nargs)
}
static uc_value_t *
-uc_uc(uc_vm *vm, size_t nargs)
+uc_uc(uc_vm_t *vm, size_t nargs)
{
char *str = ucv_to_string(vm, uc_get_arg(0));
uc_value_t *rv = NULL;
@@ -1133,7 +1133,7 @@ uc_uc(uc_vm *vm, size_t nargs)
}
static uc_value_t *
-uc_uchr(uc_vm *vm, size_t nargs)
+uc_uchr(uc_vm_t *vm, size_t nargs)
{
uc_value_t *rv = NULL;
size_t idx, ulen;
@@ -1176,7 +1176,7 @@ uc_uchr(uc_vm *vm, size_t nargs)
}
static uc_value_t *
-uc_values(uc_vm *vm, size_t nargs)
+uc_values(uc_vm_t *vm, size_t nargs)
{
uc_value_t *obj = uc_get_arg(0);
uc_value_t *arr;
@@ -1195,7 +1195,7 @@ uc_values(uc_vm *vm, size_t nargs)
}
static uc_value_t *
-uc_trim_common(uc_vm *vm, size_t nargs, bool start, bool end)
+uc_trim_common(uc_vm_t *vm, size_t nargs, bool start, bool end)
{
uc_value_t *str = uc_get_arg(0);
uc_value_t *chr = uc_get_arg(1);
@@ -1235,25 +1235,25 @@ uc_trim_common(uc_vm *vm, size_t nargs, bool start, bool end)
}
static uc_value_t *
-uc_trim(uc_vm *vm, size_t nargs)
+uc_trim(uc_vm_t *vm, size_t nargs)
{
return uc_trim_common(vm, nargs, true, true);
}
static uc_value_t *
-uc_ltrim(uc_vm *vm, size_t nargs)
+uc_ltrim(uc_vm_t *vm, size_t nargs)
{
return uc_trim_common(vm, nargs, true, false);
}
static uc_value_t *
-uc_rtrim(uc_vm *vm, size_t nargs)
+uc_rtrim(uc_vm_t *vm, size_t nargs)
{
return uc_trim_common(vm, nargs, false, true);
}
static void
-uc_printf_common(uc_vm *vm, size_t nargs, uc_stringbuf_t *buf)
+uc_printf_common(uc_vm_t *vm, size_t nargs, uc_stringbuf_t *buf)
{
uc_value_t *fmt = uc_get_arg(0);
char *fp, sfmt[sizeof("%0- 123456789.123456789%")];
@@ -1466,7 +1466,7 @@ next:
}
static uc_value_t *
-uc_sprintf(uc_vm *vm, size_t nargs)
+uc_sprintf(uc_vm_t *vm, size_t nargs)
{
uc_stringbuf_t *buf = ucv_stringbuf_new();
@@ -1476,7 +1476,7 @@ uc_sprintf(uc_vm *vm, size_t nargs)
}
static uc_value_t *
-uc_printf(uc_vm *vm, size_t nargs)
+uc_printf(uc_vm_t *vm, size_t nargs)
{
uc_stringbuf_t *buf = xprintbuf_new();
size_t len;
@@ -1491,9 +1491,9 @@ uc_printf(uc_vm *vm, size_t nargs)
}
static bool
-uc_require_so(uc_vm *vm, const char *path, uc_value_t **res)
+uc_require_so(uc_vm_t *vm, const char *path, uc_value_t **res)
{
- void (*init)(uc_vm *, uc_value_t *);
+ void (*init)(uc_vm_t *, uc_value_t *);
uc_value_t *scope;
struct stat st;
void *dlh;
@@ -1530,13 +1530,13 @@ uc_require_so(uc_vm *vm, const char *path, uc_value_t **res)
}
static bool
-uc_require_ucode(uc_vm *vm, const char *path, uc_value_t *scope, uc_value_t **res)
+uc_require_ucode(uc_vm_t *vm, const char *path, uc_value_t *scope, uc_value_t **res)
{
uc_exception_type_t extype;
uc_function_t *function;
uc_value_t *prev_scope;
uc_value_t *closure;
- uc_source *source;
+ uc_source_t *source;
struct stat st;
char *err;
@@ -1587,7 +1587,7 @@ uc_require_ucode(uc_vm *vm, const char *path, uc_value_t *scope, uc_value_t **re
}
static bool
-uc_require_path(uc_vm *vm, const char *path_template, const char *name, uc_value_t **res)
+uc_require_path(uc_vm_t *vm, const char *path_template, const char *name, uc_value_t **res)
{
uc_stringbuf_t *buf = xprintbuf_new();
const char *p, *q, *last;
@@ -1641,7 +1641,7 @@ out:
}
static uc_value_t *
-uc_require(uc_vm *vm, size_t nargs)
+uc_require(uc_vm_t *vm, size_t nargs)
{
uc_value_t *val = uc_get_arg(0);
uc_value_t *search, *se, *res;
@@ -1678,7 +1678,7 @@ uc_require(uc_vm *vm, size_t nargs)
}
static uc_value_t *
-uc_iptoarr(uc_vm *vm, size_t nargs)
+uc_iptoarr(uc_vm_t *vm, size_t nargs)
{
uc_value_t *ip = uc_get_arg(0);
uc_value_t *res;
@@ -1731,7 +1731,7 @@ check_byte(uc_value_t *v)
}
static uc_value_t *
-uc_arrtoip(uc_vm *vm, size_t nargs)
+uc_arrtoip(uc_vm_t *vm, size_t nargs)
{
uc_value_t *arr = uc_get_arg(0);
union {
@@ -1779,7 +1779,7 @@ uc_arrtoip(uc_vm *vm, size_t nargs)
}
static uc_value_t *
-uc_match(uc_vm *vm, size_t nargs)
+uc_match(uc_vm_t *vm, size_t nargs)
{
uc_value_t *subject = uc_get_arg(0);
uc_value_t *pattern = uc_get_arg(1);
@@ -1833,7 +1833,7 @@ uc_match(uc_vm *vm, size_t nargs)
}
static uc_value_t *
-uc_replace_cb(uc_vm *vm, uc_value_t *func,
+uc_replace_cb(uc_vm_t *vm, uc_value_t *func,
const char *subject, regmatch_t *pmatch, size_t plen,
uc_stringbuf_t *resbuf)
{
@@ -1862,7 +1862,7 @@ uc_replace_cb(uc_vm *vm, uc_value_t *func,
}
static void
-uc_replace_str(uc_vm *vm, uc_value_t *str,
+uc_replace_str(uc_vm_t *vm, uc_value_t *str,
const char *subject, regmatch_t *pmatch, size_t plen,
uc_stringbuf_t *resbuf)
{
@@ -1936,7 +1936,7 @@ uc_replace_str(uc_vm *vm, uc_value_t *str,
}
static uc_value_t *
-uc_replace(uc_vm *vm, size_t nargs)
+uc_replace(uc_vm_t *vm, size_t nargs)
{
char *sb = NULL, *pt = NULL, *p, *l;
uc_value_t *subject = uc_get_arg(0);
@@ -2038,7 +2038,7 @@ uc_replace(uc_vm *vm, size_t nargs)
}
static uc_value_t *
-uc_json(uc_vm *vm, size_t nargs)
+uc_json(uc_vm_t *vm, size_t nargs)
{
uc_value_t *rv, *src = uc_get_arg(0);
struct json_tokener *tok = NULL;
@@ -2130,7 +2130,7 @@ include_path(const char *curpath, const char *incpath)
}
static uc_value_t *
-uc_include(uc_vm *vm, size_t nargs)
+uc_include(uc_vm_t *vm, size_t nargs)
{
uc_value_t *path = uc_get_arg(0);
uc_value_t *scope = uc_get_arg(1);
@@ -2198,7 +2198,7 @@ uc_include(uc_vm *vm, size_t nargs)
}
static uc_value_t *
-uc_render(uc_vm *vm, size_t nargs)
+uc_render(uc_vm_t *vm, size_t nargs)
{
uc_string_t *ustr = NULL;
FILE *mem, *prev;
@@ -2245,13 +2245,13 @@ out:
}
static uc_value_t *
-uc_warn(uc_vm *vm, size_t nargs)
+uc_warn(uc_vm_t *vm, size_t nargs)
{
return uc_print_common(vm, nargs, stderr);
}
static uc_value_t *
-uc_system(uc_vm *vm, size_t nargs)
+uc_system(uc_vm_t *vm, size_t nargs)
{
uc_value_t *cmdline = uc_get_arg(0);
uc_value_t *timeout = uc_get_arg(1);
@@ -2391,7 +2391,7 @@ fail:
}
static uc_value_t *
-uc_trace(uc_vm *vm, size_t nargs)
+uc_trace(uc_vm_t *vm, size_t nargs)
{
uc_value_t *level = uc_get_arg(0);
uint8_t prev_level;
@@ -2409,7 +2409,7 @@ uc_trace(uc_vm *vm, size_t nargs)
}
static uc_value_t *
-uc_proto(uc_vm *vm, size_t nargs)
+uc_proto(uc_vm_t *vm, size_t nargs)
{
uc_value_t *val = uc_get_arg(0);
uc_value_t *proto = NULL;
@@ -2428,7 +2428,7 @@ uc_proto(uc_vm *vm, size_t nargs)
}
static uc_value_t *
-uc_sleep(uc_vm *vm, size_t nargs)
+uc_sleep(uc_vm_t *vm, size_t nargs)
{
uc_value_t *duration = uc_get_arg(0);
struct timeval tv;
@@ -2448,7 +2448,7 @@ uc_sleep(uc_vm *vm, size_t nargs)
}
static uc_value_t *
-uc_assert(uc_vm *vm, size_t nargs)
+uc_assert(uc_vm_t *vm, size_t nargs)
{
uc_value_t *cond = uc_get_arg(0);
uc_value_t *msg = uc_get_arg(1);
@@ -2470,7 +2470,7 @@ uc_assert(uc_vm *vm, size_t nargs)
}
static uc_value_t *
-uc_regexp(uc_vm *vm, size_t nargs)
+uc_regexp(uc_vm_t *vm, size_t nargs)
{
bool icase = false, newline = false, global = false, freeable;
uc_value_t *source = uc_get_arg(0);
@@ -2525,7 +2525,7 @@ uc_regexp(uc_vm *vm, size_t nargs)
}
static uc_value_t *
-uc_wildcard(uc_vm *vm, size_t nargs)
+uc_wildcard(uc_vm_t *vm, size_t nargs)
{
uc_value_t *subject = uc_get_arg(0);
uc_value_t *pattern = uc_get_arg(1);
@@ -2550,12 +2550,12 @@ uc_wildcard(uc_vm *vm, size_t nargs)
}
static uc_value_t *
-uc_sourcepath(uc_vm *vm, size_t nargs)
+uc_sourcepath(uc_vm_t *vm, size_t nargs)
{
uc_value_t *calldepth = uc_get_arg(0);
uc_value_t *dironly = uc_get_arg(1);
uc_value_t *rv = NULL;
- uc_callframe *frame;
+ uc_callframe_t *frame;
char *path = NULL;
int64_t depth;
size_t i;
@@ -2593,7 +2593,7 @@ uc_sourcepath(uc_vm *vm, size_t nargs)
}
static uc_value_t *
-uc_min_max(uc_vm *vm, size_t nargs, int cmp)
+uc_min_max(uc_vm_t *vm, size_t nargs, int cmp)
{
uc_value_t *rv = NULL, *val;
bool set = false;
@@ -2612,13 +2612,13 @@ uc_min_max(uc_vm *vm, size_t nargs, int cmp)
}
static uc_value_t *
-uc_min(uc_vm *vm, size_t nargs)
+uc_min(uc_vm_t *vm, size_t nargs)
{
return uc_min_max(vm, nargs, I_LT);
}
static uc_value_t *
-uc_max(uc_vm *vm, size_t nargs)
+uc_max(uc_vm_t *vm, size_t nargs)
{
return uc_min_max(vm, nargs, I_GT);
}
@@ -2701,7 +2701,7 @@ uc_max(uc_vm *vm, size_t nargs)
*/
static uc_value_t *
-uc_b64dec(uc_vm *vm, size_t nargs)
+uc_b64dec(uc_vm_t *vm, size_t nargs)
{
enum { BYTE1, BYTE2, BYTE3, BYTE4 } state;
uc_value_t *str = uc_get_arg(0);
@@ -2834,7 +2834,7 @@ static const char Base64[] =
"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
static uc_value_t *
-uc_b64enc(uc_vm *vm, size_t nargs)
+uc_b64enc(uc_vm_t *vm, size_t nargs)
{
uc_value_t *str = uc_get_arg(0);
unsigned char input[3] = {0};
@@ -2887,7 +2887,7 @@ uc_b64enc(uc_vm *vm, size_t nargs)
*/
-const uc_cfunction_list uc_stdlib_functions[] = {
+const uc_cfunction_list_t uc_stdlib_functions[] = {
{ "chr", uc_chr },
{ "die", uc_die },
{ "exists", uc_exists },
diff --git a/lib.h b/lib.h
index aa805c5..7eeae9f 100644
--- a/lib.h
+++ b/lib.h
@@ -23,20 +23,20 @@
typedef struct {
const char *name;
uc_cfn_ptr_t func;
-} uc_cfunction_list;
+} uc_cfunction_list_t;
-extern const uc_cfunction_list uc_stdlib_functions[];
+extern const uc_cfunction_list_t uc_stdlib_functions[];
void uc_load_stdlib(uc_value_t *scope);
-bool format_source_context(uc_stringbuf_t *buf, uc_source *src, size_t off, bool compact);
-bool format_error_context(uc_stringbuf_t *buf, uc_source *src, uc_value_t *stacktrace, size_t off);
+bool format_source_context(uc_stringbuf_t *buf, uc_source_t *src, size_t off, bool compact);
+bool format_error_context(uc_stringbuf_t *buf, uc_source_t *src, uc_value_t *stacktrace, size_t off);
/* vm helper */
static inline void *
-_uc_get_self(uc_vm *vm, const char *expected_type)
+_uc_get_self(uc_vm_t *vm, const char *expected_type)
{
return ucv_ressource_dataptr(vm->callframes.entries[vm->callframes.count - 1].ctx, expected_type);
}
@@ -44,7 +44,7 @@ _uc_get_self(uc_vm *vm, const char *expected_type)
#define uc_get_self(...) _uc_get_self(vm, __VA_ARGS__)
static inline uc_value_t *
-_uc_get_arg(uc_vm *vm, size_t nargs, size_t n)
+_uc_get_arg(uc_vm_t *vm, size_t nargs, size_t n)
{
if (n >= nargs)
return NULL;
@@ -95,7 +95,7 @@ uc_to_int64(uc_value_t *v)
/* ressource type helper */
static inline uc_ressource_type_t *
-_uc_declare_type(uc_vm *vm, const char *name, const uc_cfunction_list *list, size_t len, void (*freefn)(void *))
+_uc_declare_type(uc_vm_t *vm, const char *name, const uc_cfunction_list_t *list, size_t len, void (*freefn)(void *))
{
uc_value_t *proto = ucv_object_new(NULL);
@@ -116,7 +116,7 @@ _uc_declare_type(uc_vm *vm, const char *name, const uc_cfunction_list *list, siz
ucv_object_add(object, name, ucv_cfunction_new(name, function))
static inline bool
-_uc_add_functions(uc_value_t *object, const uc_cfunction_list *list, size_t len)
+_uc_add_functions(uc_value_t *object, const uc_cfunction_list_t *list, size_t len)
{
bool rv = true;
diff --git a/lib/fs.c b/lib/fs.c
index 6f6c7cb..7d501a2 100644
--- a/lib/fs.c
+++ b/lib/fs.c
@@ -36,7 +36,7 @@ static uc_ressource_type_t *file_type, *proc_type, *dir_type;
static int last_error = 0;
static uc_value_t *
-uc_fs_error(uc_vm *vm, size_t nargs)
+uc_fs_error(uc_vm_t *vm, size_t nargs)
{
uc_value_t *errmsg;
@@ -50,7 +50,7 @@ uc_fs_error(uc_vm *vm, size_t nargs)
}
static uc_value_t *
-uc_fs_read_common(uc_vm *vm, size_t nargs, const char *type)
+uc_fs_read_common(uc_vm_t *vm, size_t nargs, const char *type)
{
uc_value_t *limit = uc_get_arg(0);
uc_value_t *rv = NULL;
@@ -142,7 +142,7 @@ uc_fs_read_common(uc_vm *vm, size_t nargs, const char *type)
}
static uc_value_t *
-uc_fs_write_common(uc_vm *vm, size_t nargs, const char *type)
+uc_fs_write_common(uc_vm_t *vm, size_t nargs, const char *type)
{
uc_value_t *data = uc_get_arg(0);
size_t len, wsize;
@@ -172,7 +172,7 @@ uc_fs_write_common(uc_vm *vm, size_t nargs, const char *type)
static uc_value_t *
-uc_fs_pclose(uc_vm *vm, size_t nargs)
+uc_fs_pclose(uc_vm_t *vm, size_t nargs)
{
FILE **fp = uc_get_self("fs.proc");
int rc;
@@ -196,19 +196,19 @@ uc_fs_pclose(uc_vm *vm, size_t nargs)
}
static uc_value_t *
-uc_fs_pread(uc_vm *vm, size_t nargs)
+uc_fs_pread(uc_vm_t *vm, size_t nargs)
{
return uc_fs_read_common(vm, nargs, "fs.proc");
}
static uc_value_t *
-uc_fs_pwrite(uc_vm *vm, size_t nargs)
+uc_fs_pwrite(uc_vm_t *vm, size_t nargs)
{
return uc_fs_write_common(vm, nargs, "fs.proc");
}
static uc_value_t *
-uc_fs_popen(uc_vm *vm, size_t nargs)
+uc_fs_popen(uc_vm_t *vm, size_t nargs)
{
uc_value_t *comm = uc_get_arg(0);
uc_value_t *mode = uc_get_arg(1);
@@ -228,7 +228,7 @@ uc_fs_popen(uc_vm *vm, size_t nargs)
static uc_value_t *
-uc_fs_close(uc_vm *vm, size_t nargs)
+uc_fs_close(uc_vm_t *vm, size_t nargs)
{
FILE **fp = uc_get_self("fs.file");
@@ -242,19 +242,19 @@ uc_fs_close(uc_vm *vm, size_t nargs)
}
static uc_value_t *
-uc_fs_read(uc_vm *vm, size_t nargs)
+uc_fs_read(uc_vm_t *vm, size_t nargs)
{
return uc_fs_read_common(vm, nargs, "fs.file");
}
static uc_value_t *
-uc_fs_write(uc_vm *vm, size_t nargs)
+uc_fs_write(uc_vm_t *vm, size_t nargs)
{
return uc_fs_write_common(vm, nargs, "fs.file");
}
static uc_value_t *
-uc_fs_seek(uc_vm *vm, size_t nargs)
+uc_fs_seek(uc_vm_t *vm, size_t nargs)
{
uc_value_t *ofs = uc_get_arg(0);
uc_value_t *how = uc_get_arg(1);
@@ -289,7 +289,7 @@ uc_fs_seek(uc_vm *vm, size_t nargs)
}
static uc_value_t *
-uc_fs_tell(uc_vm *vm, size_t nargs)
+uc_fs_tell(uc_vm_t *vm, size_t nargs)
{
long offset;
@@ -307,7 +307,7 @@ uc_fs_tell(uc_vm *vm, size_t nargs)
}
static uc_value_t *
-uc_fs_open(uc_vm *vm, size_t nargs)
+uc_fs_open(uc_vm_t *vm, size_t nargs)
{
uc_value_t *path = uc_get_arg(0);
uc_value_t *mode = uc_get_arg(1);
@@ -327,7 +327,7 @@ uc_fs_open(uc_vm *vm, size_t nargs)
static uc_value_t *
-uc_fs_readdir(uc_vm *vm, size_t nargs)
+uc_fs_readdir(uc_vm_t *vm, size_t nargs)
{
DIR **dp = uc_get_self("fs.dir");
struct dirent *e;
@@ -345,7 +345,7 @@ uc_fs_readdir(uc_vm *vm, size_t nargs)
}
static uc_value_t *
-uc_fs_telldir(uc_vm *vm, size_t nargs)
+uc_fs_telldir(uc_vm_t *vm, size_t nargs)
{
DIR **dp = uc_get_self("fs.dir");
long position;
@@ -362,7 +362,7 @@ uc_fs_telldir(uc_vm *vm, size_t nargs)
}
static uc_value_t *
-uc_fs_seekdir(uc_vm *vm, size_t nargs)
+uc_fs_seekdir(uc_vm_t *vm, size_t nargs)
{
uc_value_t *ofs = uc_get_arg(0);
DIR **dp = uc_get_self("fs.dir");
@@ -382,7 +382,7 @@ uc_fs_seekdir(uc_vm *vm, size_t nargs)
}
static uc_value_t *
-uc_fs_closedir(uc_vm *vm, size_t nargs)
+uc_fs_closedir(uc_vm_t *vm, size_t nargs)
{
DIR **dp = uc_get_self("fs.dir");
@@ -396,7 +396,7 @@ uc_fs_closedir(uc_vm *vm, size_t nargs)
}
static uc_value_t *
-uc_fs_opendir(uc_vm *vm, size_t nargs)
+uc_fs_opendir(uc_vm_t *vm, size_t nargs)
{
uc_value_t *path = uc_get_arg(0);
DIR *dp;
@@ -413,7 +413,7 @@ uc_fs_opendir(uc_vm *vm, size_t nargs)
}
static uc_value_t *
-uc_fs_readlink(uc_vm *vm, size_t nargs)
+uc_fs_readlink(uc_vm_t *vm, size_t nargs)
{
uc_value_t *path = uc_get_arg(0);
uc_value_t *res;
@@ -453,7 +453,7 @@ uc_fs_readlink(uc_vm *vm, size_t nargs)
}
static uc_value_t *
-uc_fs_stat_common(uc_vm *vm, size_t nargs, bool use_lstat)
+uc_fs_stat_common(uc_vm_t *vm, size_t nargs, bool use_lstat)
{
uc_value_t *path = uc_get_arg(0);
uc_value_t *res, *o;
@@ -537,19 +537,19 @@ uc_fs_stat_common(uc_vm *vm, size_t nargs, bool use_lstat)
}
static uc_value_t *
-uc_fs_stat(uc_vm *vm, size_t nargs)
+uc_fs_stat(uc_vm_t *vm, size_t nargs)
{
return uc_fs_stat_common(vm, nargs, false);
}
static uc_value_t *
-uc_fs_lstat(uc_vm *vm, size_t nargs)
+uc_fs_lstat(uc_vm_t *vm, size_t nargs)
{
return uc_fs_stat_common(vm, nargs, true);
}
static uc_value_t *
-uc_fs_mkdir(uc_vm *vm, size_t nargs)
+uc_fs_mkdir(uc_vm_t *vm, size_t nargs)
{
uc_value_t *path = uc_get_arg(0);
uc_value_t *mode = uc_get_arg(1);
@@ -565,7 +565,7 @@ uc_fs_mkdir(uc_vm *vm, size_t nargs)
}
static uc_value_t *
-uc_fs_rmdir(uc_vm *vm, size_t nargs)
+uc_fs_rmdir(uc_vm_t *vm, size_t nargs)
{
uc_value_t *path = uc_get_arg(0);
@@ -579,7 +579,7 @@ uc_fs_rmdir(uc_vm *vm, size_t nargs)
}
static uc_value_t *
-uc_fs_symlink(uc_vm *vm, size_t nargs)
+uc_fs_symlink(uc_vm_t *vm, size_t nargs)
{
uc_value_t *dest = uc_get_arg(0);
uc_value_t *path = uc_get_arg(1);
@@ -595,7 +595,7 @@ uc_fs_symlink(uc_vm *vm, size_t nargs)
}
static uc_value_t *
-uc_fs_unlink(uc_vm *vm, size_t nargs)
+uc_fs_unlink(uc_vm_t *vm, size_t nargs)
{
uc_value_t *path = uc_get_arg(0);
@@ -609,7 +609,7 @@ uc_fs_unlink(uc_vm *vm, size_t nargs)
}
static uc_value_t *
-uc_fs_getcwd(uc_vm *vm, size_t nargs)
+uc_fs_getcwd(uc_vm_t *vm, size_t nargs)
{
uc_value_t *res;
char *buf = NULL, *tmp;
@@ -645,7 +645,7 @@ uc_fs_getcwd(uc_vm *vm, size_t nargs)
}
static uc_value_t *
-uc_fs_chdir(uc_vm *vm, size_t nargs)
+uc_fs_chdir(uc_vm_t *vm, size_t nargs)
{
uc_value_t *path = uc_get_arg(0);
@@ -659,7 +659,7 @@ uc_fs_chdir(uc_vm *vm, size_t nargs)
}
static uc_value_t *
-uc_fs_chmod(uc_vm *vm, size_t nargs)
+uc_fs_chmod(uc_vm_t *vm, size_t nargs)
{
uc_value_t *path = uc_get_arg(0);
uc_value_t *mode = uc_get_arg(1);
@@ -769,7 +769,7 @@ uc_fs_resolve_group(uc_value_t *v, gid_t *gid)
}
static uc_value_t *
-uc_fs_chown(uc_vm *vm, size_t nargs)
+uc_fs_chown(uc_vm_t *vm, size_t nargs)
{
uc_value_t *path = uc_get_arg(0);
uc_value_t *user = uc_get_arg(1);
@@ -791,7 +791,7 @@ uc_fs_chown(uc_vm *vm, size_t nargs)
}
static uc_value_t *
-uc_fs_rename(uc_vm *vm, size_t nargs)
+uc_fs_rename(uc_vm_t *vm, size_t nargs)
{
uc_value_t *oldpath = uc_get_arg(0);
uc_value_t *newpath = uc_get_arg(1);
@@ -807,7 +807,7 @@ uc_fs_rename(uc_vm *vm, size_t nargs)
}
static uc_value_t *
-uc_fs_glob(uc_vm *vm, size_t nargs)
+uc_fs_glob(uc_vm_t *vm, size_t nargs)
{
uc_value_t *pat, *arr;
glob_t gl = { 0 };
@@ -835,14 +835,14 @@ uc_fs_glob(uc_vm *vm, size_t nargs)
}
-static const uc_cfunction_list proc_fns[] = {
+static const uc_cfunction_list_t proc_fns[] = {
{ "read", uc_fs_pread },
{ "write", uc_fs_pwrite },
{ "close", uc_fs_pclose },
{ "error", uc_fs_error },
};
-static const uc_cfunction_list file_fns[] = {
+static const uc_cfunction_list_t file_fns[] = {
{ "read", uc_fs_read },
{ "write", uc_fs_write },
{ "seek", uc_fs_seek },
@@ -851,7 +851,7 @@ static const uc_cfunction_list file_fns[] = {
{ "error", uc_fs_error },
};
-static const uc_cfunction_list dir_fns[] = {
+static const uc_cfunction_list_t dir_fns[] = {
{ "read", uc_fs_readdir },
{ "seek", uc_fs_seekdir },
{ "tell", uc_fs_telldir },
@@ -859,7 +859,7 @@ static const uc_cfunction_list dir_fns[] = {
{ "error", uc_fs_error },
};
-static const uc_cfunction_list global_fns[] = {
+static const uc_cfunction_list_t global_fns[] = {
{ "error", uc_fs_error },
{ "open", uc_fs_open },
{ "opendir", uc_fs_opendir },
@@ -904,7 +904,7 @@ static void close_dir(void *ud)
closedir(dp);
}
-void uc_module_init(uc_vm *vm, uc_value_t *scope)
+void uc_module_init(uc_vm_t *vm, uc_value_t *scope)
{
uc_add_functions(scope, global_fns);
diff --git a/lib/math.c b/lib/math.c
index bc8efb6..5ba8d76 100644
--- a/lib/math.c
+++ b/lib/math.c
@@ -22,7 +22,7 @@
static bool srand_called = false;
static uc_value_t *
-uc_abs(uc_vm *vm, size_t nargs)
+uc_abs(uc_vm_t *vm, size_t nargs)
{
uc_value_t *v = uc_get_arg(0);
uc_type_t t;
@@ -41,7 +41,7 @@ uc_abs(uc_vm *vm, size_t nargs)
}
static uc_value_t *
-uc_atan2(uc_vm *vm, size_t nargs)
+uc_atan2(uc_vm_t *vm, size_t nargs)
{
double d1 = uc_to_double(uc_get_arg(0));
double d2 = uc_to_double(uc_get_arg(1));
@@ -53,7 +53,7 @@ uc_atan2(uc_vm *vm, size_t nargs)
}
static uc_value_t *
-uc_cos(uc_vm *vm, size_t nargs)
+uc_cos(uc_vm_t *vm, size_t nargs)
{
double d = uc_to_double(uc_get_arg(0));
@@ -64,7 +64,7 @@ uc_cos(uc_vm *vm, size_t nargs)
}
static uc_value_t *
-uc_exp(uc_vm *vm, size_t nargs)
+uc_exp(uc_vm_t *vm, size_t nargs)
{
double d = uc_to_double(uc_get_arg(0));
@@ -75,7 +75,7 @@ uc_exp(uc_vm *vm, size_t nargs)
}
static uc_value_t *
-uc_log(uc_vm *vm, size_t nargs)
+uc_log(uc_vm_t *vm, size_t nargs)
{
double d = uc_to_double(uc_get_arg(0));
@@ -86,7 +86,7 @@ uc_log(uc_vm *vm, size_t nargs)
}
static uc_value_t *
-uc_sin(uc_vm *vm, size_t nargs)
+uc_sin(uc_vm_t *vm, size_t nargs)
{
double d = uc_to_double(uc_get_arg(0));
@@ -97,7 +97,7 @@ uc_sin(uc_vm *vm, size_t nargs)
}
static uc_value_t *
-uc_sqrt(uc_vm *vm, size_t nargs)
+uc_sqrt(uc_vm_t *vm, size_t nargs)
{
double d = uc_to_double(uc_get_arg(0));
@@ -108,7 +108,7 @@ uc_sqrt(uc_vm *vm, size_t nargs)
}
static uc_value_t *
-uc_pow(uc_vm *vm, size_t nargs)
+uc_pow(uc_vm_t *vm, size_t nargs)
{
double x = uc_to_double(uc_get_arg(0));
double y = uc_to_double(uc_get_arg(1));
@@ -120,7 +120,7 @@ uc_pow(uc_vm *vm, size_t nargs)
}
static uc_value_t *
-uc_rand(uc_vm *vm, size_t nargs)
+uc_rand(uc_vm_t *vm, size_t nargs)
{
struct timeval tv;
@@ -135,7 +135,7 @@ uc_rand(uc_vm *vm, size_t nargs)
}
static uc_value_t *
-uc_srand(uc_vm *vm, size_t nargs)
+uc_srand(uc_vm_t *vm, size_t nargs)
{
int64_t n = uc_to_int64(uc_get_arg(0));
@@ -145,7 +145,7 @@ uc_srand(uc_vm *vm, size_t nargs)
return NULL;
}
-static const uc_cfunction_list math_fns[] = {
+static const uc_cfunction_list_t math_fns[] = {
{ "abs", uc_abs },
{ "atan2", uc_atan2 },
{ "cos", uc_cos },
@@ -158,7 +158,7 @@ static const uc_cfunction_list math_fns[] = {
{ "srand", uc_srand },
};
-void uc_module_init(uc_vm *vm, uc_value_t *scope)
+void uc_module_init(uc_vm_t *vm, uc_value_t *scope)
{
uc_add_functions(scope, math_fns);
}
diff --git a/lib/ubus.c b/lib/ubus.c
index 933ef3a..d1b2c8c 100644
--- a/lib/ubus.c
+++ b/lib/ubus.c
@@ -33,7 +33,7 @@ typedef struct {
} ubus_connection;
static uc_value_t *
-uc_ubus_error(uc_vm *vm, size_t nargs)
+uc_ubus_error(uc_vm_t *vm, size_t nargs)
{
uc_value_t *errmsg;
@@ -47,10 +47,10 @@ uc_ubus_error(uc_vm *vm, size_t nargs)
}
static uc_value_t *
-uc_blob_to_json(uc_vm *vm, struct blob_attr *attr, bool table, const char **name);
+uc_blob_to_json(uc_vm_t *vm, struct blob_attr *attr, bool table, const char **name);
static uc_value_t *
-uc_blob_array_to_json(uc_vm *vm, struct blob_attr *attr, size_t len, bool table)
+uc_blob_array_to_json(uc_vm_t *vm, struct blob_attr *attr, size_t len, bool table)
{
uc_value_t *o = table ? ucv_object_new(vm) : ucv_array_new(vm);
uc_value_t *v;
@@ -77,7 +77,7 @@ uc_blob_array_to_json(uc_vm *vm, struct blob_attr *attr, size_t len, bool table)
}
static uc_value_t *
-uc_blob_to_json(uc_vm *vm, struct blob_attr *attr, bool table, const char **name)
+uc_blob_to_json(uc_vm_t *vm, struct blob_attr *attr, bool table, const char **name)
{
void *data;
int len;
@@ -131,7 +131,7 @@ uc_blob_to_json(uc_vm *vm, struct blob_attr *attr, bool table, const char **name
static uc_value_t *
-uc_ubus_connect(uc_vm *vm, size_t nargs)
+uc_ubus_connect(uc_vm_t *vm, size_t nargs)
{
uc_value_t *socket = uc_get_arg(0);
uc_value_t *timeout = uc_get_arg(1);
@@ -199,7 +199,7 @@ uc_ubus_objects_cb(struct ubus_context *c, struct ubus_object_data *o, void *p)
}
static uc_value_t *
-uc_ubus_list(uc_vm *vm, size_t nargs)
+uc_ubus_list(uc_vm_t *vm, size_t nargs)
{
ubus_connection **c = uc_get_self("ubus.connection");
uc_value_t *objname = uc_get_arg(0);
@@ -237,7 +237,7 @@ uc_ubus_call_cb(struct ubus_request *req, int type, struct blob_attr *msg)
}
static uc_value_t *
-uc_ubus_call(uc_vm *vm, size_t nargs)
+uc_ubus_call(uc_vm_t *vm, size_t nargs)
{
ubus_connection **c = uc_get_self("ubus.connection");
uc_value_t *objname = uc_get_arg(0);
@@ -282,7 +282,7 @@ uc_ubus_call(uc_vm *vm, size_t nargs)
}
static uc_value_t *
-uc_ubus_disconnect(uc_vm *vm, size_t nargs)
+uc_ubus_disconnect(uc_vm_t *vm, size_t nargs)
{
ubus_connection **c = uc_get_self("ubus.connection");
@@ -296,12 +296,12 @@ uc_ubus_disconnect(uc_vm *vm, size_t nargs)
}
-static const uc_cfunction_list global_fns[] = {
+static const uc_cfunction_list_t global_fns[] = {
{ "error", uc_ubus_error },
{ "connect", uc_ubus_connect },
};
-static const uc_cfunction_list conn_fns[] = {
+static const uc_cfunction_list_t conn_fns[] = {
{ "list", uc_ubus_list },
{ "call", uc_ubus_call },
{ "error", uc_ubus_error },
@@ -320,7 +320,7 @@ static void close_connection(void *ud) {
free(conn);
}
-void uc_module_init(uc_vm *vm, uc_value_t *scope)
+void uc_module_init(uc_vm_t *vm, uc_value_t *scope)
{
uc_add_functions(scope, global_fns);
diff --git a/lib/uci.c b/lib/uci.c
index 71a9c2d..89c5c92 100644
--- a/lib/uci.c
+++ b/lib/uci.c
@@ -31,7 +31,7 @@ enum pkg_cmd {
};
static uc_value_t *
-uc_uci_error(uc_vm *vm, size_t nargs)
+uc_uci_error(uc_vm_t *vm, size_t nargs)
{
char buf[sizeof("Unknown error: -9223372036854775808")];
uc_value_t *errmsg;
@@ -64,7 +64,7 @@ uc_uci_error(uc_vm *vm, size_t nargs)
static uc_value_t *
-uc_uci_cursor(uc_vm *vm, size_t nargs)
+uc_uci_cursor(uc_vm_t *vm, size_t nargs)
{
uc_value_t *cdir = uc_get_arg(0);
uc_value_t *sdir = uc_get_arg(1);
@@ -99,7 +99,7 @@ uc_uci_cursor(uc_vm *vm, size_t nargs)
static uc_value_t *
-uc_uci_load(uc_vm *vm, size_t nargs)
+uc_uci_load(uc_vm_t *vm, size_t nargs)
{
struct uci_context **c = uc_get_self("uci.cursor");
uc_value_t *conf = uc_get_arg(0);
@@ -128,7 +128,7 @@ uc_uci_load(uc_vm *vm, size_t nargs)
}
static uc_value_t *
-uc_uci_unload(uc_vm *vm, size_t nargs)
+uc_uci_unload(uc_vm_t *vm, size_t nargs)
{
struct uci_context **c = uc_get_self("uci.cursor");
uc_value_t *conf = uc_get_arg(0);
@@ -181,7 +181,7 @@ lookup_ptr(struct uci_context *ctx, struct uci_ptr *ptr, bool extended)
}
static uc_value_t *
-option_to_uval(uc_vm *vm, struct uci_option *o)
+option_to_uval(uc_vm_t *vm, struct uci_option *o)
{
struct uci_element *e;
uc_value_t *arr;
@@ -205,7 +205,7 @@ option_to_uval(uc_vm *vm, struct uci_option *o)
}
static uc_value_t *
-section_to_uval(uc_vm *vm, struct uci_section *s, int index)
+section_to_uval(uc_vm_t *vm, struct uci_section *s, int index)
{
uc_value_t *so = ucv_object_new(vm);
struct uci_element *e;
@@ -230,7 +230,7 @@ section_to_uval(uc_vm *vm, struct uci_section *s, int index)
}
static uc_value_t *
-package_to_uval(uc_vm *vm, struct uci_package *p)
+package_to_uval(uc_vm_t *vm, struct uci_package *p)
{
uc_value_t *po = ucv_object_new(vm);
uc_value_t *so;
@@ -249,7 +249,7 @@ package_to_uval(uc_vm *vm, struct uci_package *p)
}
static uc_value_t *
-uc_uci_get_any(uc_vm *vm, size_t nargs, bool all)
+uc_uci_get_any(uc_vm_t *vm, size_t nargs, bool all)
{
struct uci_context **c = uc_get_self("uci.cursor");
uc_value_t *conf = uc_get_arg(0);
@@ -309,19 +309,19 @@ uc_uci_get_any(uc_vm *vm, size_t nargs, bool all)
}
static uc_value_t *
-uc_uci_get(uc_vm *vm, size_t nargs)
+uc_uci_get(uc_vm_t *vm, size_t nargs)
{
return uc_uci_get_any(vm, nargs, false);
}
static uc_value_t *
-uc_uci_get_all(uc_vm *vm, size_t nargs)
+uc_uci_get_all(uc_vm_t *vm, size_t nargs)
{
return uc_uci_get_any(vm, nargs, true);
}
static uc_value_t *
-uc_uci_get_first(uc_vm *vm, size_t nargs)
+uc_uci_get_first(uc_vm_t *vm, size_t nargs)
{
struct uci_context **c = uc_get_self("uci.cursor");
uc_value_t *conf = uc_get_arg(0);
@@ -379,7 +379,7 @@ uc_uci_get_first(uc_vm *vm, size_t nargs)
}
static uc_value_t *
-uc_uci_add(uc_vm *vm, size_t nargs)
+uc_uci_add(uc_vm_t *vm, size_t nargs)
{
struct uci_context **c = uc_get_self("uci.cursor");
uc_value_t *conf = uc_get_arg(0);
@@ -414,7 +414,7 @@ uc_uci_add(uc_vm *vm, size_t nargs)
}
static bool
-uval_to_uci(uc_vm *vm, uc_value_t *val, const char **p, bool *is_list)
+uval_to_uci(uc_vm_t *vm, uc_value_t *val, const char **p, bool *is_list)
{
uc_value_t *item;
@@ -459,7 +459,7 @@ uval_to_uci(uc_vm *vm, uc_value_t *val, const char **p, bool *is_list)
}
static uc_value_t *
-uc_uci_set(uc_vm *vm, size_t nargs)
+uc_uci_set(uc_vm_t *vm, size_t nargs)
{
struct uci_context **c = uc_get_self("uci.cursor");
uc_value_t *conf = uc_get_arg(0);
@@ -564,7 +564,7 @@ uc_uci_set(uc_vm *vm, size_t nargs)
}
static uc_value_t *
-uc_uci_delete(uc_vm *vm, size_t nargs)
+uc_uci_delete(uc_vm_t *vm, size_t nargs)
{
struct uci_context **c = uc_get_self("uci.cursor");
uc_value_t *conf = uc_get_arg(0);
@@ -599,7 +599,7 @@ uc_uci_delete(uc_vm *vm, size_t nargs)
}
static uc_value_t *
-uc_uci_rename(uc_vm *vm, size_t nargs)
+uc_uci_rename(uc_vm_t *vm, size_t nargs)
{
struct uci_context **c = uc_get_self("uci.cursor");
uc_value_t *conf = uc_get_arg(0);
@@ -659,7 +659,7 @@ uc_uci_rename(uc_vm *vm, size_t nargs)
}
static uc_value_t *
-uc_uci_reorder(uc_vm *vm, size_t nargs)
+uc_uci_reorder(uc_vm_t *vm, size_t nargs)
{
struct uci_context **c = uc_get_self("uci.cursor");
uc_value_t *conf = uc_get_arg(0);
@@ -699,7 +699,7 @@ uc_uci_reorder(uc_vm *vm, size_t nargs)
}
static uc_value_t *
-uc_uci_pkg_command(uc_vm *vm, size_t nargs, enum pkg_cmd cmd)
+uc_uci_pkg_command(uc_vm_t *vm, size_t nargs, enum pkg_cmd cmd)
{
struct uci_context **c = uc_get_self("uci.cursor");
uc_value_t *conf = uc_get_arg(0);
@@ -749,25 +749,25 @@ uc_uci_pkg_command(uc_vm *vm, size_t nargs, enum pkg_cmd cmd)
}
static uc_value_t *
-uc_uci_save(uc_vm *vm, size_t nargs)
+uc_uci_save(uc_vm_t *vm, size_t nargs)
{
return uc_uci_pkg_command(vm, nargs, CMD_SAVE);
}
static uc_value_t *
-uc_uci_commit(uc_vm *vm, size_t nargs)
+uc_uci_commit(uc_vm_t *vm, size_t nargs)
{
return uc_uci_pkg_command(vm, nargs, CMD_COMMIT);
}
static uc_value_t *
-uc_uci_revert(uc_vm *vm, size_t nargs)
+uc_uci_revert(uc_vm_t *vm, size_t nargs)
{
return uc_uci_pkg_command(vm, nargs, CMD_REVERT);
}
static uc_value_t *
-change_to_uval(uc_vm *vm, struct uci_delta *d)
+change_to_uval(uc_vm_t *vm, struct uci_delta *d)
{
const char *types[] = {
[UCI_CMD_REORDER] = "order",
@@ -806,7 +806,7 @@ change_to_uval(uc_vm *vm, struct uci_delta *d)
}
static uc_value_t *
-changes_to_uval(uc_vm *vm, struct uci_context *ctx, const char *package)
+changes_to_uval(uc_vm_t *vm, struct uci_context *ctx, const char *package)
{
uc_value_t *a = NULL, *c;
struct uci_package *p = NULL;
@@ -856,7 +856,7 @@ changes_to_uval(uc_vm *vm, struct uci_context *ctx, const char *package)
}
static uc_value_t *
-uc_uci_changes(uc_vm *vm, size_t nargs)
+uc_uci_changes(uc_vm_t *vm, size_t nargs)
{
struct uci_context **c = uc_get_self("uci.cursor");
uc_value_t *conf = uc_get_arg(0);
@@ -890,7 +890,7 @@ uc_uci_changes(uc_vm *vm, size_t nargs)
}
static uc_value_t *
-uc_uci_foreach(uc_vm *vm, size_t nargs)
+uc_uci_foreach(uc_vm_t *vm, size_t nargs)
{
struct uci_context **c = uc_get_self("uci.cursor");
uc_value_t *conf = uc_get_arg(0);
@@ -952,7 +952,7 @@ uc_uci_foreach(uc_vm *vm, size_t nargs)
}
static uc_value_t *
-uc_uci_configs(uc_vm *vm, size_t nargs)
+uc_uci_configs(uc_vm_t *vm, size_t nargs)
{
struct uci_context **c = uc_get_self("uci.cursor");
uc_value_t *a;
@@ -975,7 +975,7 @@ uc_uci_configs(uc_vm *vm, size_t nargs)
}
-static const uc_cfunction_list cursor_fns[] = {
+static const uc_cfunction_list_t cursor_fns[] = {
{ "load", uc_uci_load },
{ "unload", uc_uci_unload },
{ "get", uc_uci_get },
@@ -995,7 +995,7 @@ static const uc_cfunction_list cursor_fns[] = {
{ "error", uc_uci_error },
};
-static const uc_cfunction_list global_fns[] = {
+static const uc_cfunction_list_t global_fns[] = {
{ "error", uc_uci_error },
{ "cursor", uc_uci_cursor },
};
@@ -1005,7 +1005,7 @@ static void close_uci(void *ud) {
uci_free_context((struct uci_context *)ud);
}
-void uc_module_init(uc_vm *vm, uc_value_t *scope)
+void uc_module_init(uc_vm_t *vm, uc_value_t *scope)
{
uc_add_functions(scope, global_fns);
diff --git a/main.c b/main.c
index a71e053..58ac2b3 100644
--- a/main.c
+++ b/main.c
@@ -74,13 +74,13 @@ register_variable(uc_value_t *scope, const char *key, uc_value_t *val)
static int
-parse(uc_parse_config *config, uc_source *src,
+parse(uc_parse_config_t *config, uc_source_t *src,
uc_value_t *env, uc_value_t *modules,
int argc, char **argv, int trace)
{
uc_value_t *globals = NULL, *res = NULL, *arr, *name, *mod;
uc_function_t *entry;
- uc_vm vm = { 0 };
+ uc_vm_t vm = { 0 };
int i, rc = 0;
size_t idx;
char *err;
@@ -154,7 +154,7 @@ out:
return rc;
}
-static uc_source *
+static uc_source_t *
read_stdin(char **ptr)
{
size_t rlen = 0, tlen = 0;
@@ -225,11 +225,11 @@ int
main(int argc, char **argv)
{
uc_value_t *env = NULL, *modules = NULL, *o, *p;
- uc_source *source = NULL, *envfile = NULL;
+ uc_source_t *source = NULL, *envfile = NULL;
int opt, rv = 0, trace = 0;
char *stdin = NULL, *c;
- uc_parse_config config = {
+ uc_parse_config_t config = {
.strict_declarations = false,
.lstrip_blocks = true,
.trim_blocks = true
diff --git a/module.h b/module.h
index b951e09..43d9d51 100644
--- a/module.h
+++ b/module.h
@@ -41,10 +41,10 @@
#define register_ressource(scope, key, res) \
json_object_object_add((scope)->header.jso, key, (res)->header.jso)
-void uc_module_init(uc_vm *vm, uc_value_t *scope) __attribute__((weak));
+void uc_module_init(uc_vm_t *vm, uc_value_t *scope) __attribute__((weak));
-void uc_module_entry(uc_vm *vm, uc_value_t *scope);
-void uc_module_entry(uc_vm *vm, uc_value_t *scope)
+void uc_module_entry(uc_vm_t *vm, uc_value_t *scope);
+void uc_module_entry(uc_vm_t *vm, uc_value_t *scope)
{
if (uc_module_init)
uc_module_init(vm, scope);
diff --git a/source.c b/source.c
index 21b9124..e5a924f 100644
--- a/source.c
+++ b/source.c
@@ -19,11 +19,11 @@
#include "source.h"
-uc_source *
+uc_source_t *
uc_source_new_file(const char *path)
{
FILE *fp = fopen(path, "rb");
- uc_source *src;
+ uc_source_t *src;
if (!fp)
return NULL;
@@ -41,11 +41,11 @@ uc_source_new_file(const char *path)
return src;
}
-uc_source *
+uc_source_t *
uc_source_new_buffer(const char *name, char *buf, size_t len)
{
FILE *fp = fmemopen(buf, len, "rb");
- uc_source *src;
+ uc_source_t *src;
if (!fp)
return NULL;
@@ -64,9 +64,9 @@ uc_source_new_buffer(const char *name, char *buf, size_t len)
}
size_t
-uc_source_get_line(uc_source *source, size_t *offset)
+uc_source_get_line(uc_source_t *source, size_t *offset)
{
- uc_lineinfo *lines = &source->lineinfo;
+ uc_lineinfo_t *lines = &source->lineinfo;
size_t i, pos = 0, line = 0, lastoff = 0;
for (i = 0; i < lines->count; i++) {
@@ -88,8 +88,8 @@ uc_source_get_line(uc_source *source, size_t *offset)
return 0;
}
-uc_source *
-uc_source_get(uc_source *source)
+uc_source_t *
+uc_source_get(uc_source_t *source)
{
if (!source)
return NULL;
@@ -100,7 +100,7 @@ uc_source_get(uc_source *source)
}
void
-uc_source_put(uc_source *source)
+uc_source_put(uc_source_t *source)
{
if (!source)
return;
diff --git a/source.h b/source.h
index 6557a48..3de7c93 100644
--- a/source.h
+++ b/source.h
@@ -25,12 +25,12 @@
#include "types.h"
-uc_source *uc_source_new_file(const char *path);
-uc_source *uc_source_new_buffer(const char *name, char *buf, size_t len);
+uc_source_t *uc_source_new_file(const char *path);
+uc_source_t *uc_source_new_buffer(const char *name, char *buf, size_t len);
-size_t uc_source_get_line(uc_source *source, size_t *offset);
+size_t uc_source_get_line(uc_source_t *source, size_t *offset);
-uc_source *uc_source_get(uc_source *source);
-void uc_source_put(uc_source *source);
+uc_source_t *uc_source_get(uc_source_t *source);
+void uc_source_put(uc_source_t *source);
#endif /* __SOURCE_H_ */
diff --git a/types.c b/types.c
index b72980b..98547e3 100644
--- a/types.c
+++ b/types.c
@@ -117,7 +117,7 @@ ucv_gc_mark(uc_value_t *uv)
{
uc_function_t *function;
uc_closure_t *closure;
- uc_upvalref_t *upval;
+ uc_upval_tref_t *upval;
uc_object_t *object;
uc_array_t *array;
struct lh_entry *entry;
@@ -169,7 +169,7 @@ ucv_gc_mark(uc_value_t *uv)
break;
case UC_UPVALUE:
- upval = (uc_upvalref_t *)uv;
+ upval = (uc_upval_tref_t *)uv;
ucv_gc_mark(upval->value);
break;
@@ -185,7 +185,7 @@ ucv_free(uc_value_t *uv, bool retain)
uc_ressource_t *ressource;
uc_function_t *function;
uc_closure_t *closure;
- uc_upvalref_t *upval;
+ uc_upval_tref_t *upval;
uc_regexp_t *regexp;
uc_object_t *object;
uc_array_t *array;
@@ -253,7 +253,7 @@ ucv_free(uc_value_t *uv, bool retain)
break;
case UC_UPVALUE:
- upval = (uc_upvalref_t *)uv;
+ upval = (uc_upval_tref_t *)uv;
ucv_put_value(upval->value, retain);
break;
}
@@ -560,13 +560,13 @@ ucv_double_get(uc_value_t *uv)
uc_value_t *
-ucv_array_new(uc_vm *vm)
+ucv_array_new(uc_vm_t *vm)
{
return ucv_array_new_length(vm, 0);
}
uc_value_t *
-ucv_array_new_length(uc_vm *vm, size_t length)
+ucv_array_new_length(uc_vm_t *vm, size_t length)
{
uc_array_t *array;
@@ -755,7 +755,7 @@ ucv_free_object_entry(struct lh_entry *entry)
}
uc_value_t *
-ucv_object_new(uc_vm *vm)
+ucv_object_new(uc_vm_t *vm)
{
struct lh_table *table;
uc_object_t *object;
@@ -860,7 +860,7 @@ ucv_object_length(uc_value_t *uv)
uc_value_t *
-ucv_function_new(const char *name, size_t srcpos, uc_source *source)
+ucv_function_new(const char *name, size_t srcpos, uc_source_t *source)
{
size_t namelen = 0;
uc_function_t *fn;
@@ -924,16 +924,16 @@ ucv_cfunction_new(const char *name, uc_cfn_ptr_t fptr)
uc_value_t *
-ucv_closure_new(uc_vm *vm, uc_function_t *function, bool arrow_fn)
+ucv_closure_new(uc_vm_t *vm, uc_function_t *function, bool arrow_fn)
{
uc_closure_t *closure;
- closure = xalloc(sizeof(*closure) + (sizeof(uc_upvalref_t *) * function->nupvals));
+ closure = xalloc(sizeof(*closure) + (sizeof(uc_upval_tref_t *) * function->nupvals));
closure->header.type = UC_CLOSURE;
closure->header.refcount = 1;
closure->function = function;
closure->is_arrow = arrow_fn;
- closure->upvals = function->nupvals ? (uc_upvalref_t **)((uintptr_t)closure + ALIGN(sizeof(*closure))) : NULL;
+ closure->upvals = function->nupvals ? (uc_upval_tref_t **)((uintptr_t)closure + ALIGN(sizeof(*closure))) : NULL;
if (vm)
ucv_ref(&vm->values, &closure->ref);
@@ -943,7 +943,7 @@ ucv_closure_new(uc_vm *vm, uc_function_t *function, bool arrow_fn)
uc_ressource_type_t *
-ucv_ressource_type_add(uc_vm *vm, const char *name, uc_value_t *proto, void (*freefn)(void *))
+ucv_ressource_type_add(uc_vm_t *vm, const char *name, uc_value_t *proto, void (*freefn)(void *))
{
uc_ressource_type_t *type;
@@ -967,7 +967,7 @@ ucv_ressource_type_add(uc_vm *vm, const char *name, uc_value_t *proto, void (*fr
}
uc_ressource_type_t *
-ucv_ressource_type_lookup(uc_vm *vm, const char *name)
+ucv_ressource_type_lookup(uc_vm_t *vm, const char *name)
{
size_t i;
@@ -1053,7 +1053,7 @@ ucv_regexp_new(const char *pattern, bool icase, bool newline, bool global, char
uc_value_t *
ucv_upvalref_new(size_t slot)
{
- uc_upvalref_t *up;
+ uc_upval_tref_t *up;
up = xalloc(sizeof(*up));
up->header.type = UC_UPVALUE;
@@ -1139,7 +1139,7 @@ ucv_property_get(uc_value_t *uv, const char *key)
uc_value_t *
-ucv_from_json(uc_vm *vm, json_object *jso)
+ucv_from_json(uc_vm_t *vm, json_object *jso)
{
//uc_array_t *arr;
uc_value_t *uv, *item;
@@ -1347,7 +1347,7 @@ ucv_to_string_json_encoded(uc_stringbuf_t *pb, const char *s, size_t len, bool r
}
static bool
-ucv_call_tostring(uc_vm *vm, uc_stringbuf_t *pb, uc_value_t *uv, bool json)
+ucv_call_tostring(uc_vm_t *vm, uc_stringbuf_t *pb, uc_value_t *uv, bool json)
{
uc_value_t *proto = ucv_prototype_get(uv);
uc_value_t *tostr = ucv_object_get(proto, "tostring", NULL);
@@ -1403,7 +1403,7 @@ ucv_to_stringbuf_add_padding(uc_stringbuf_t *pb, char pad_char, size_t pad_size)
}
void
-ucv_to_stringbuf_formatted(uc_vm *vm, uc_stringbuf_t *pb, uc_value_t *uv, size_t depth, char pad_char, size_t pad_size)
+ucv_to_stringbuf_formatted(uc_vm_t *vm, uc_stringbuf_t *pb, uc_value_t *uv, size_t depth, char pad_char, size_t pad_size)
{
bool json = (pad_char != '\0');
uc_ressource_type_t *restype;
@@ -1632,7 +1632,7 @@ ucv_to_stringbuf_formatted(uc_vm *vm, uc_stringbuf_t *pb, uc_value_t *uv, size_t
}
static char *
-ucv_to_string_any(uc_vm *vm, uc_value_t *uv, char pad_char, size_t pad_size)
+ucv_to_string_any(uc_vm_t *vm, uc_value_t *uv, char pad_char, size_t pad_size)
{
uc_stringbuf_t *pb = xprintbuf_new();
char *rv;
@@ -1647,13 +1647,13 @@ ucv_to_string_any(uc_vm *vm, uc_value_t *uv, char pad_char, size_t pad_size)
}
char *
-ucv_to_string(uc_vm *vm, uc_value_t *uv)
+ucv_to_string(uc_vm_t *vm, uc_value_t *uv)
{
return ucv_to_string_any(vm, uv, '\0', 0);
}
char *
-ucv_to_jsonstring_formatted(uc_vm *vm, uc_value_t *uv, char pad_char, size_t pad_size)
+ucv_to_jsonstring_formatted(uc_vm_t *vm, uc_value_t *uv, char pad_char, size_t pad_size)
{
return ucv_to_string_any(vm, uv, pad_char ? pad_char : '\1', pad_size);
}
@@ -1757,7 +1757,7 @@ ucv_equal(uc_value_t *uv1, uc_value_t *uv2)
}
void
-ucv_gc(uc_vm *vm, bool final)
+ucv_gc(uc_vm_t *vm, bool final)
{
uc_weakref_t *ref, *tmp;
uc_value_t *val;
diff --git a/types.h b/types.h
index 349ae7e..e2cb15d 100644
--- a/types.h
+++ b/types.h
@@ -27,7 +27,7 @@
/* Value types and generic value header */
-typedef enum uc_type_t {
+typedef enum uc_type {
UC_NULL,
UC_INTEGER,
UC_BOOLEAN,
@@ -43,7 +43,7 @@ typedef enum uc_type_t {
UC_RESSOURCE
} uc_type_t;
-typedef struct uc_value_t {
+typedef struct uc_value {
uint32_t type:4;
uint32_t mark:1;
uint32_t u64:1;
@@ -58,53 +58,53 @@ typedef struct {
size_t dsize;
uint64_t *index;
char *data;
-} uc_value_list;
+} uc_value_list_t;
/* Source buffer defintions */
-uc_declare_vector(uc_lineinfo, uint8_t);
+uc_declare_vector(uc_lineinfo_t, uint8_t);
typedef struct {
char *filename, *buffer;
FILE *fp;
size_t usecount, off;
- uc_lineinfo lineinfo;
-} uc_source;
+ uc_lineinfo_t lineinfo;
+} uc_source_t;
/* Bytecode chunk defintions */
typedef struct {
size_t from, to, target, slot;
-} uc_ehrange;
+} uc_ehrange_t;
typedef struct {
size_t from, to, slot, nameidx;
-} uc_varrange;
+} uc_varrange_t;
-uc_declare_vector(uc_ehranges, uc_ehrange);
-uc_declare_vector(uc_variables, uc_varrange);
-uc_declare_vector(uc_offsetinfo, uint8_t);
+uc_declare_vector(uc_ehranges_t, uc_ehrange_t);
+uc_declare_vector(uc_variables_t, uc_varrange_t);
+uc_declare_vector(uc_offsetinfo_t, uint8_t);
typedef struct {
size_t count;
uint8_t *entries;
- uc_value_list constants;
- uc_ehranges ehranges;
+ uc_value_list_t constants;
+ uc_ehranges_t ehranges;
struct {
- uc_variables variables;
- uc_value_list varnames;
- uc_offsetinfo offsets;
+ uc_variables_t variables;
+ uc_value_list_t varnames;
+ uc_offsetinfo_t offsets;
} debuginfo;
-} uc_chunk;
+} uc_chunk_t;
/* Value type structures */
-typedef struct uc_weakref_t {
- struct uc_weakref_t *prev;
- struct uc_weakref_t *next;
+typedef struct uc_weakref {
+ struct uc_weakref *prev;
+ struct uc_weakref *next;
} uc_weakref_t;
typedef struct {
@@ -154,29 +154,29 @@ typedef struct {
size_t nargs;
size_t nupvals;
size_t srcpos;
- uc_chunk chunk;
- uc_source *source;
+ uc_chunk_t chunk;
+ uc_source_t *source;
char name[];
} uc_function_t;
-typedef struct uc_upvalref_t {
+typedef struct uc_upval_tref {
uc_value_t header;
size_t slot;
bool closed;
uc_value_t *value;
- struct uc_upvalref_t *next;
-} uc_upvalref_t;
+ struct uc_upval_tref *next;
+} uc_upval_tref_t;
typedef struct {
uc_value_t header;
uc_weakref_t ref;
bool is_arrow;
uc_function_t *function;
- uc_upvalref_t **upvals;
+ uc_upval_tref_t **upvals;
} uc_closure_t;
-typedef struct uc_vm uc_vm;
-typedef uc_value_t *(*uc_cfn_ptr_t)(uc_vm *, size_t);
+typedef struct uc_vm uc_vm_t;
+typedef uc_value_t *(*uc_cfn_ptr_t)(uc_vm_t *, size_t);
typedef struct {
uc_value_t header;
@@ -206,7 +206,7 @@ typedef struct {
bool trim_blocks;
bool strict_declarations;
bool raw_mode;
-} uc_parse_config;
+} uc_parse_config_t;
/* VM definitions */
@@ -225,7 +225,7 @@ typedef struct {
uc_exception_type_t type;
uc_value_t *stacktrace;
char *message;
-} uc_exception;
+} uc_exception_t;
typedef struct {
uint8_t *ip;
@@ -234,23 +234,23 @@ typedef struct {
size_t stackframe;
uc_value_t *ctx;
bool mcall, strict;
-} uc_callframe;
+} uc_callframe_t;
-uc_declare_vector(uc_callframes, uc_callframe);
-uc_declare_vector(uc_stack, uc_value_t *);
+uc_declare_vector(uc_callframes_t, uc_callframe_t);
+uc_declare_vector(uc_stack_t, uc_value_t *);
typedef struct printbuf uc_stringbuf_t;
-typedef void (uc_exception_handler_t)(uc_vm *, uc_exception *);
+typedef void (uc_exception_handler_t)(uc_vm_t *, uc_exception_t *);
struct uc_vm {
- uc_stack stack;
- uc_exception exception;
- uc_callframes callframes;
- uc_upvalref_t *open_upvals;
- uc_parse_config *config;
+ uc_stack_t stack;
+ uc_exception_t exception;
+ uc_callframes_t callframes;
+ uc_upval_tref_t *open_upvals;
+ uc_parse_config_t *config;
uc_value_t *globals;
- uc_source *sources;
+ uc_source_t *sources;
uc_weakref_t values;
uc_ressource_types_t restypes;
union {
@@ -307,8 +307,8 @@ uint64_t ucv_uint64_get(uc_value_t *);
uc_value_t *ucv_double_new(double);
double ucv_double_get(uc_value_t *);
-uc_value_t *ucv_array_new(uc_vm *);
-uc_value_t *ucv_array_new_length(uc_vm *, size_t);
+uc_value_t *ucv_array_new(uc_vm_t *);
+uc_value_t *ucv_array_new_length(uc_vm_t *, size_t);
uc_value_t *ucv_array_get(uc_value_t *, size_t);
uc_value_t *ucv_array_pop(uc_value_t *);
uc_value_t *ucv_array_push(uc_value_t *, uc_value_t *);
@@ -319,7 +319,7 @@ bool ucv_array_delete(uc_value_t *, size_t, size_t);
bool ucv_array_set(uc_value_t *, size_t, uc_value_t *);
size_t ucv_array_length(uc_value_t *);
-uc_value_t *ucv_object_new(uc_vm *);
+uc_value_t *ucv_object_new(uc_vm_t *);
uc_value_t *ucv_object_get(uc_value_t *, const char *, bool *);
bool ucv_object_add(uc_value_t *, const char *, uc_value_t *);
bool ucv_object_delete(uc_value_t *, const char *);
@@ -337,15 +337,15 @@ size_t ucv_object_length(uc_value_t *);
: 0); \
entry##key = entry_next##key)
-uc_value_t *ucv_function_new(const char *, size_t, uc_source *);
+uc_value_t *ucv_function_new(const char *, size_t, uc_source_t *);
size_t ucv_function_srcpos(uc_value_t *, size_t);
uc_value_t *ucv_cfunction_new(const char *, uc_cfn_ptr_t);
-uc_value_t *ucv_closure_new(uc_vm *, uc_function_t *, bool);
+uc_value_t *ucv_closure_new(uc_vm_t *, uc_function_t *, bool);
-uc_ressource_type_t *ucv_ressource_type_add(uc_vm *, const char *, uc_value_t *, void (*)(void *));
-uc_ressource_type_t *ucv_ressource_type_lookup(uc_vm *, const char *);
+uc_ressource_type_t *ucv_ressource_type_add(uc_vm_t *, const char *, uc_value_t *, void (*)(void *));
+uc_ressource_type_t *ucv_ressource_type_lookup(uc_vm_t *, const char *);
uc_value_t *ucv_ressource_new(uc_ressource_type_t *, void *);
void **ucv_ressource_dataptr(uc_value_t *, const char *);
@@ -359,12 +359,12 @@ bool ucv_prototype_set(uc_value_t *, uc_value_t *);
uc_value_t *ucv_property_get(uc_value_t *, const char *);
-uc_value_t *ucv_from_json(uc_vm *, json_object *);
+uc_value_t *ucv_from_json(uc_vm_t *, json_object *);
json_object *ucv_to_json(uc_value_t *);
-char *ucv_to_string(uc_vm *, uc_value_t *);
-char *ucv_to_jsonstring_formatted(uc_vm *, uc_value_t *, char, size_t);
-void ucv_to_stringbuf_formatted(uc_vm *, uc_stringbuf_t *, uc_value_t *, size_t, char, size_t);
+char *ucv_to_string(uc_vm_t *, uc_value_t *);
+char *ucv_to_jsonstring_formatted(uc_vm_t *, uc_value_t *, char, size_t);
+void ucv_to_stringbuf_formatted(uc_vm_t *, uc_stringbuf_t *, uc_value_t *, size_t, char, size_t);
#define ucv_to_jsonstring(vm, val) ucv_to_jsonstring_formatted(vm, val, '\1', 0)
#define ucv_to_stringbuf(vm, buf, val, json) ucv_to_stringbuf_formatted(vm, buf, val, 0, json ? '\1' : '\0', 0)
@@ -434,6 +434,6 @@ ucv_clear_mark(uc_value_t *uv)
bool ucv_equal(uc_value_t *, uc_value_t *);
-void ucv_gc(uc_vm *, bool);
+void ucv_gc(uc_vm_t *, bool);
#endif /* __TYPES_H_ */
diff --git a/value.c b/value.c
index 125564b..b72ba8c 100644
--- a/value.c
+++ b/value.c
@@ -146,7 +146,7 @@ uc_cast_number(uc_value_t *v, int64_t *n, double *d)
}
static char *
-uc_tostring(uc_vm *vm, uc_value_t *val)
+uc_tostring(uc_vm_t *vm, uc_value_t *val)
{
if (ucv_type(val) != UC_STRING)
return ucv_to_string(vm, val);
@@ -189,7 +189,7 @@ uc_toidx(uc_value_t *val)
}
uc_value_t *
-uc_getval(uc_vm *vm, uc_value_t *scope, uc_value_t *key)
+uc_getval(uc_vm_t *vm, uc_value_t *scope, uc_value_t *key)
{
uc_value_t *o, *v = NULL;
int64_t idx;
@@ -221,7 +221,7 @@ uc_getval(uc_vm *vm, uc_value_t *scope, uc_value_t *key)
}
uc_value_t *
-uc_setval(uc_vm *vm, uc_value_t *scope, uc_value_t *key, uc_value_t *val)
+uc_setval(uc_vm_t *vm, uc_value_t *scope, uc_value_t *key, uc_value_t *val)
{
int64_t idx;
char *s;
@@ -247,7 +247,7 @@ uc_setval(uc_vm *vm, uc_value_t *scope, uc_value_t *key, uc_value_t *val)
}
bool
-uc_delval(uc_vm *vm, uc_value_t *scope, uc_value_t *key)
+uc_delval(uc_vm_t *vm, uc_value_t *scope, uc_value_t *key)
{
char *s;
bool rv;
@@ -327,7 +327,7 @@ uc_cmp(int how, uc_value_t *v1, uc_value_t *v2)
}
void
-uc_vallist_init(uc_value_list *list)
+uc_vallist_init(uc_value_list_t *list)
{
list->isize = 0;
list->dsize = 0;
@@ -336,7 +336,7 @@ uc_vallist_init(uc_value_list *list)
}
void
-uc_vallist_free(uc_value_list *list)
+uc_vallist_free(uc_value_list_t *list)
{
uc_value_t *o;
size_t i;
@@ -355,7 +355,7 @@ uc_vallist_free(uc_value_list *list)
}
static void
-add_num(uc_value_list *list, int64_t n)
+add_num(uc_value_list_t *list, int64_t n)
{
size_t sz = TAG_ALIGN(sizeof(n));
@@ -380,7 +380,7 @@ add_num(uc_value_list *list, int64_t n)
}
static ssize_t
-find_num(uc_value_list *list, int64_t n)
+find_num(uc_value_list_t *list, int64_t n)
{
TAG_TYPE search;
size_t i;
@@ -411,7 +411,7 @@ find_num(uc_value_list *list, int64_t n)
}
static void
-add_dbl(uc_value_list *list, double d)
+add_dbl(uc_value_list_t *list, double d)
{
size_t sz = TAG_ALIGN(sizeof(d));
@@ -430,7 +430,7 @@ add_dbl(uc_value_list *list, double d)
}
static ssize_t
-find_dbl(uc_value_list *list, double d)
+find_dbl(uc_value_list_t *list, double d)
{
size_t i;
@@ -451,7 +451,7 @@ find_dbl(uc_value_list *list, double d)
}
static void
-add_str(uc_value_list *list, const char *s, size_t slen)
+add_str(uc_value_list_t *list, const char *s, size_t slen)
{
uint32_t sl;
size_t sz;
@@ -497,7 +497,7 @@ add_str(uc_value_list *list, const char *s, size_t slen)
}
static ssize_t
-find_str(uc_value_list *list, const char *s, size_t slen)
+find_str(uc_value_list_t *list, const char *s, size_t slen)
{
TAG_TYPE search;
size_t i, len;
@@ -539,7 +539,7 @@ find_str(uc_value_list *list, const char *s, size_t slen)
}
static void
-add_ptr(uc_value_list *list, void *ptr)
+add_ptr(uc_value_list_t *list, void *ptr)
{
size_t sz = TAG_ALIGN(sizeof(ptr));
@@ -558,7 +558,7 @@ add_ptr(uc_value_list *list, void *ptr)
}
ssize_t
-uc_vallist_add(uc_value_list *list, uc_value_t *value)
+uc_vallist_add(uc_value_list_t *list, uc_value_t *value)
{
ssize_t existing;
@@ -615,7 +615,7 @@ uc_vallist_add(uc_value_list *list, uc_value_t *value)
}
uc_value_type_t
-uc_vallist_type(uc_value_list *list, size_t idx)
+uc_vallist_type(uc_value_list_t *list, size_t idx)
{
if (idx >= list->isize)
return TAG_INVAL;
@@ -624,7 +624,7 @@ uc_vallist_type(uc_value_list *list, size_t idx)
}
uc_value_t *
-uc_vallist_get(uc_value_list *list, size_t idx)
+uc_vallist_get(uc_value_list_t *list, size_t idx)
{
char str[sizeof(TAG_TYPE)];
size_t n, len;
diff --git a/value.h b/value.h
index 7d4e2b1..04d37a9 100644
--- a/value.h
+++ b/value.h
@@ -46,15 +46,15 @@ bool uc_val_is_truish(uc_value_t *val);
uc_type_t uc_cast_number(uc_value_t *v, int64_t *n, double *d);
-uc_value_t *uc_getval(uc_vm *, uc_value_t *scope, uc_value_t *key);
-uc_value_t *uc_setval(uc_vm *, uc_value_t *scope, uc_value_t *key, uc_value_t *val);
-bool uc_delval(uc_vm *, uc_value_t *scope, uc_value_t *key);
+uc_value_t *uc_getval(uc_vm_t *, uc_value_t *scope, uc_value_t *key);
+uc_value_t *uc_setval(uc_vm_t *, uc_value_t *scope, uc_value_t *key, uc_value_t *val);
+bool uc_delval(uc_vm_t *, uc_value_t *scope, uc_value_t *key);
-void uc_vallist_init(uc_value_list *list);
-void uc_vallist_free(uc_value_list *list);
+void uc_vallist_init(uc_value_list_t *list);
+void uc_vallist_free(uc_value_list_t *list);
-ssize_t uc_vallist_add(uc_value_list *list, uc_value_t *value);
-uc_value_type_t uc_vallist_type(uc_value_list *list, size_t idx);
-uc_value_t *uc_vallist_get(uc_value_list *list, size_t idx);
+ssize_t uc_vallist_add(uc_value_list_t *list, uc_value_t *value);
+uc_value_type_t uc_vallist_type(uc_value_list_t *list, size_t idx);
+uc_value_t *uc_vallist_get(uc_value_list_t *list, size_t idx);
#endif /* __VALUE_H_ */
diff --git a/vm.c b/vm.c
index 82d2f1c..443c64e 100644
--- a/vm.c
+++ b/vm.c
@@ -81,7 +81,7 @@ static const char *exception_type_strings[] = {
static void
-uc_vm_reset_stack(uc_vm *vm)
+uc_vm_reset_stack(uc_vm_t *vm)
{
while (vm->stack.count > 0) {
vm->stack.count--;
@@ -91,17 +91,17 @@ uc_vm_reset_stack(uc_vm *vm)
}
static uc_value_t *
-uc_vm_callframe_pop(uc_vm *vm);
+uc_vm_callframe_pop(uc_vm_t *vm);
static void
-uc_vm_reset_callframes(uc_vm *vm)
+uc_vm_reset_callframes(uc_vm_t *vm)
{
while (vm->callframes.count > 0)
ucv_put(uc_vm_callframe_pop(vm));
}
static uc_value_t *
-uc_vm_alloc_global_scope(uc_vm *vm)
+uc_vm_alloc_global_scope(uc_vm_t *vm)
{
const char *path[] = { LIB_SEARCH_PATH };
uc_value_t *scope, *arr;
@@ -132,9 +132,9 @@ uc_vm_alloc_global_scope(uc_vm *vm)
}
static void
-uc_vm_output_exception(uc_vm *vm, uc_exception *ex);
+uc_vm_output_exception(uc_vm_t *vm, uc_exception_t *ex);
-void uc_vm_init(uc_vm *vm, uc_parse_config *config)
+void uc_vm_init(uc_vm_t *vm, uc_parse_config_t *config)
{
vm->exception.type = EXCEPTION_NONE;
vm->exception.message = NULL;
@@ -159,9 +159,9 @@ void uc_vm_init(uc_vm *vm, uc_parse_config *config)
uc_vm_trace_set(vm, 0);
}
-void uc_vm_free(uc_vm *vm)
+void uc_vm_free(uc_vm_t *vm)
{
- uc_upvalref_t *ref;
+ uc_upval_tref_t *ref;
size_t i;
ucv_put(vm->exception.stacktrace);
@@ -191,34 +191,34 @@ void uc_vm_free(uc_vm *vm)
uc_vector_clear(&vm->restypes);
}
-static uc_chunk *
-uc_vm_frame_chunk(uc_callframe *frame)
+static uc_chunk_t *
+uc_vm_frame_chunk(uc_callframe_t *frame)
{
return frame->closure ? &frame->closure->function->chunk : NULL;
}
-static uc_callframe *
-uc_vm_current_frame(uc_vm *vm)
+static uc_callframe_t *
+uc_vm_current_frame(uc_vm_t *vm)
{
return uc_vector_last(&vm->callframes);
}
-static uc_chunk *
-uc_vm_current_chunk(uc_vm *vm)
+static uc_chunk_t *
+uc_vm_current_chunk(uc_vm_t *vm)
{
return uc_vm_frame_chunk(uc_vm_current_frame(vm));
}
static bool
-uc_vm_is_strict(uc_vm *vm)
+uc_vm_is_strict(uc_vm_t *vm)
{
return uc_vm_current_frame(vm)->strict;
}
-static enum insn_type
-uc_vm_decode_insn(uc_vm *vm, uc_callframe *frame, uc_chunk *chunk)
+static uc_vm_insn_t
+uc_vm_decode_insn(uc_vm_t *vm, uc_callframe_t *frame, uc_chunk_t *chunk)
{
- enum insn_type insn;
+ uc_vm_insn_t insn;
#ifndef NDEBUG
uint8_t *end = chunk->entries + chunk->count;
@@ -283,7 +283,7 @@ uc_vm_decode_insn(uc_vm *vm, uc_callframe *frame, uc_chunk *chunk)
static char *
-uc_vm_format_val(uc_vm *vm, uc_value_t *val)
+uc_vm_format_val(uc_vm_t *vm, uc_value_t *val)
{
if (!vm->strbuf)
vm->strbuf = xprintbuf_new();
@@ -301,12 +301,12 @@ uc_vm_format_val(uc_vm *vm, uc_value_t *val)
}
static void
-uc_vm_frame_dump(uc_vm *vm, uc_callframe *frame)
+uc_vm_frame_dump(uc_vm_t *vm, uc_callframe_t *frame)
{
- uc_chunk *chunk = uc_vm_frame_chunk(frame);
+ uc_chunk_t *chunk = uc_vm_frame_chunk(frame);
uc_function_t *function;
uc_closure_t *closure;
- uc_upvalref_t *ref;
+ uc_upval_tref_t *ref;
uc_value_t *v;
size_t i;
@@ -361,7 +361,7 @@ uc_vm_frame_dump(uc_vm *vm, uc_callframe *frame)
}
void
-uc_vm_stack_push(uc_vm *vm, uc_value_t *value)
+uc_vm_stack_push(uc_vm_t *vm, uc_value_t *value)
{
uc_vector_grow(&vm->stack);
@@ -378,7 +378,7 @@ uc_vm_stack_push(uc_vm *vm, uc_value_t *value)
}
uc_value_t *
-uc_vm_stack_pop(uc_vm *vm)
+uc_vm_stack_pop(uc_vm_t *vm)
{
uc_value_t *rv;
@@ -396,13 +396,13 @@ uc_vm_stack_pop(uc_vm *vm)
}
uc_value_t *
-uc_vm_stack_peek(uc_vm *vm, size_t offset)
+uc_vm_stack_peek(uc_vm_t *vm, size_t offset)
{
return vm->stack.entries[vm->stack.count + (-1 - offset)];
}
static void
-uc_vm_stack_set(uc_vm *vm, size_t offset, uc_value_t *value)
+uc_vm_stack_set(uc_vm_t *vm, size_t offset, uc_value_t *value)
{
if (vm->trace) {
fprintf(stderr, " [!%zu] %s\n",
@@ -415,10 +415,10 @@ uc_vm_stack_set(uc_vm *vm, size_t offset, uc_value_t *value)
}
static void
-uc_vm_call_native(uc_vm *vm, uc_value_t *ctx, uc_cfunction_t *fptr, bool mcall, size_t nargs)
+uc_vm_call_native(uc_vm_t *vm, uc_value_t *ctx, uc_cfunction_t *fptr, bool mcall, size_t nargs)
{
uc_value_t *res = NULL;
- uc_callframe *frame;
+ uc_callframe_t *frame;
/* add new callframe */
uc_vector_grow(&vm->callframes);
@@ -446,10 +446,10 @@ uc_vm_call_native(uc_vm *vm, uc_value_t *ctx, uc_cfunction_t *fptr, bool mcall,
}
static bool
-uc_vm_call_function(uc_vm *vm, uc_value_t *ctx, uc_value_t *fno, bool mcall, size_t argspec)
+uc_vm_call_function(uc_vm_t *vm, uc_value_t *ctx, uc_value_t *fno, bool mcall, size_t argspec)
{
size_t i, j, stackoff, nargs = argspec & 0xffff, nspreads = argspec >> 16;
- uc_callframe *frame = NULL;
+ uc_callframe_t *frame = NULL;
uc_value_t *ellip, *arg;
uc_function_t *function;
uc_closure_t *closure;
@@ -582,14 +582,14 @@ uc_vm_call_function(uc_vm *vm, uc_value_t *ctx, uc_value_t *fno, bool mcall, siz
return true;
}
-static uc_source *last_source = NULL;
+static uc_source_t *last_source = NULL;
static size_t last_srcpos = 0;
static void
-uc_dump_insn(uc_vm *vm, uint8_t *pos, enum insn_type insn)
+uc_dump_insn(uc_vm_t *vm, uint8_t *pos, uc_vm_insn_t insn)
{
- uc_callframe *frame = uc_vm_current_frame(vm);
- uc_chunk *chunk = uc_vm_frame_chunk(frame);
+ uc_callframe_t *frame = uc_vm_current_frame(vm);
+ uc_chunk_t *chunk = uc_vm_frame_chunk(frame);
uc_stringbuf_t *buf = NULL;
uc_value_t *cnst = NULL;
size_t srcpos;
@@ -698,9 +698,9 @@ uc_dump_insn(uc_vm *vm, uint8_t *pos, enum insn_type insn)
}
static uc_value_t *
-uc_vm_exception_tostring(uc_vm *vm, size_t nargs)
+uc_vm_exception_tostring(uc_vm_t *vm, size_t nargs)
{
- uc_callframe *frame = uc_vm_current_frame(vm);
+ uc_callframe_t *frame = uc_vm_current_frame(vm);
uc_value_t *message = ucv_object_get(frame->ctx, "message", NULL);
return message ? ucv_get(message) : ucv_string_new("Exception");
@@ -709,7 +709,7 @@ uc_vm_exception_tostring(uc_vm *vm, size_t nargs)
static uc_value_t *exception_prototype = NULL;
static uc_value_t *
-uc_vm_exception_new(uc_vm *vm, uc_exception_type_t type, const char *message, uc_value_t *stacktrace)
+uc_vm_exception_new(uc_vm_t *vm, uc_exception_type_t type, const char *message, uc_value_t *stacktrace)
{
uc_value_t *exo;
@@ -732,10 +732,10 @@ uc_vm_exception_new(uc_vm *vm, uc_exception_type_t type, const char *message, uc
}
static bool
-uc_vm_handle_exception(uc_vm *vm)
+uc_vm_handle_exception(uc_vm_t *vm)
{
- uc_callframe *frame = NULL;
- uc_chunk *chunk = NULL;
+ uc_callframe_t *frame = NULL;
+ uc_chunk_t *chunk = NULL;
uc_value_t *exo;
size_t i, pos;
@@ -794,11 +794,11 @@ uc_vm_handle_exception(uc_vm *vm)
}
static uc_value_t *
-uc_vm_capture_stacktrace(uc_vm *vm, size_t i)
+uc_vm_capture_stacktrace(uc_vm_t *vm, size_t i)
{
uc_value_t *stacktrace, *entry, *last = NULL;
uc_function_t *function;
- uc_callframe *frame;
+ uc_callframe_t *frame;
size_t off, srcpos;
char *name;
@@ -848,12 +848,12 @@ uc_vm_capture_stacktrace(uc_vm *vm, size_t i)
}
static uc_value_t *
-uc_vm_get_error_context(uc_vm *vm)
+uc_vm_get_error_context(uc_vm_t *vm)
{
uc_value_t *stacktrace;
- uc_callframe *frame;
+ uc_callframe_t *frame;
uc_stringbuf_t *buf;
- uc_chunk *chunk;
+ uc_chunk_t *chunk;
size_t offset, i;
/* skip to first non-native function call frame */
@@ -885,7 +885,7 @@ uc_vm_get_error_context(uc_vm *vm)
}
void __attribute__((format(printf, 3, 0)))
-uc_vm_raise_exception(uc_vm *vm, uc_exception_type_t type, const char *fmt, ...)
+uc_vm_raise_exception(uc_vm_t *vm, uc_exception_type_t type, const char *fmt, ...)
{
va_list ap;
@@ -903,7 +903,7 @@ uc_vm_raise_exception(uc_vm *vm, uc_exception_type_t type, const char *fmt, ...)
static void
-uc_vm_insn_load(uc_vm *vm, enum insn_type insn)
+uc_vm_insn_load(uc_vm_t *vm, uc_vm_insn_t insn)
{
switch (insn) {
case I_LOAD:
@@ -928,7 +928,7 @@ uc_vm_insn_load(uc_vm *vm, enum insn_type insn)
}
static void
-uc_vm_insn_load_regexp(uc_vm *vm, enum insn_type insn)
+uc_vm_insn_load_regexp(uc_vm_t *vm, uc_vm_insn_t insn)
{
uc_value_t *re, *jstr = uc_chunk_get_constant(uc_vm_current_chunk(vm), vm->arg.u32);
bool icase = false, newline = false, global = false;
@@ -960,19 +960,19 @@ uc_vm_insn_load_regexp(uc_vm *vm, enum insn_type insn)
}
static void
-uc_vm_insn_load_null(uc_vm *vm, enum insn_type insn)
+uc_vm_insn_load_null(uc_vm_t *vm, uc_vm_insn_t insn)
{
uc_vm_stack_push(vm, NULL);
}
static void
-uc_vm_insn_load_bool(uc_vm *vm, enum insn_type insn)
+uc_vm_insn_load_bool(uc_vm_t *vm, uc_vm_insn_t insn)
{
uc_vm_stack_push(vm, ucv_boolean_new(insn == I_LTRUE));
}
static void
-uc_vm_insn_load_var(uc_vm *vm, enum insn_type insn)
+uc_vm_insn_load_var(uc_vm_t *vm, uc_vm_insn_t insn)
{
uc_value_t *name, *val = NULL;
uc_value_t *scope, *next;
@@ -1008,7 +1008,7 @@ uc_vm_insn_load_var(uc_vm *vm, enum insn_type insn)
}
static void
-uc_vm_insn_load_val(uc_vm *vm, enum insn_type insn)
+uc_vm_insn_load_val(uc_vm_t *vm, uc_vm_insn_t insn)
{
uc_value_t *k = uc_vm_stack_pop(vm);
uc_value_t *v = uc_vm_stack_pop(vm);
@@ -1032,10 +1032,10 @@ uc_vm_insn_load_val(uc_vm *vm, enum insn_type insn)
}
static void
-uc_vm_insn_load_upval(uc_vm *vm, enum insn_type insn)
+uc_vm_insn_load_upval(uc_vm_t *vm, uc_vm_insn_t insn)
{
- uc_callframe *frame = uc_vm_current_frame(vm);
- uc_upvalref_t *ref = frame->closure->upvals[vm->arg.u32];
+ uc_callframe_t *frame = uc_vm_current_frame(vm);
+ uc_upval_tref_t *ref = frame->closure->upvals[vm->arg.u32];
if (ref->closed)
uc_vm_stack_push(vm, ucv_get(ref->value));
@@ -1044,19 +1044,19 @@ uc_vm_insn_load_upval(uc_vm *vm, enum insn_type insn)
}
static void
-uc_vm_insn_load_local(uc_vm *vm, enum insn_type insn)
+uc_vm_insn_load_local(uc_vm_t *vm, uc_vm_insn_t insn)
{
- uc_callframe *frame = uc_vm_current_frame(vm);
+ uc_callframe_t *frame = uc_vm_current_frame(vm);
uc_vm_stack_push(vm, ucv_get(vm->stack.entries[frame->stackframe + vm->arg.u32]));
}
-static uc_upvalref_t *
-uc_vm_capture_upval(uc_vm *vm, size_t slot)
+static uc_upval_tref_t *
+uc_vm_capture_upval(uc_vm_t *vm, size_t slot)
{
- uc_upvalref_t *curr = vm->open_upvals;
- uc_upvalref_t *prev = NULL;
- uc_upvalref_t *created;
+ uc_upval_tref_t *curr = vm->open_upvals;
+ uc_upval_tref_t *prev = NULL;
+ uc_upval_tref_t *created;
char *s;
while (curr && curr->slot > slot) {
@@ -1074,7 +1074,7 @@ uc_vm_capture_upval(uc_vm *vm, size_t slot)
return curr;
}
- created = (uc_upvalref_t *)ucv_upvalref_new(slot);
+ created = (uc_upval_tref_t *)ucv_upvalref_new(slot);
created->next = curr;
if (vm->trace) {
@@ -1092,9 +1092,9 @@ uc_vm_capture_upval(uc_vm *vm, size_t slot)
}
static void
-uc_vm_close_upvals(uc_vm *vm, size_t slot)
+uc_vm_close_upvals(uc_vm_t *vm, size_t slot)
{
- uc_upvalref_t *ref;
+ uc_upval_tref_t *ref;
while (vm->open_upvals && vm->open_upvals->slot >= slot) {
ref = vm->open_upvals;
@@ -1113,9 +1113,9 @@ uc_vm_close_upvals(uc_vm *vm, size_t slot)
}
static void
-uc_vm_insn_load_closure(uc_vm *vm, enum insn_type insn)
+uc_vm_insn_load_closure(uc_vm_t *vm, uc_vm_insn_t insn)
{
- uc_callframe *frame = uc_vm_current_frame(vm);
+ uc_callframe_t *frame = uc_vm_current_frame(vm);
uc_value_t *fno = uc_chunk_get_constant(uc_vm_current_chunk(vm), vm->arg.u32);
uc_function_t *function = (uc_function_t *)fno;
uc_closure_t *closure = (uc_closure_t *)ucv_closure_new(vm, function, insn == I_ARFN);
@@ -1144,7 +1144,7 @@ uc_vm_insn_load_closure(uc_vm *vm, enum insn_type insn)
}
static void
-uc_vm_insn_store_var(uc_vm *vm, enum insn_type insn)
+uc_vm_insn_store_var(uc_vm_t *vm, uc_vm_insn_t insn)
{
uc_value_t *name, *v = uc_vm_stack_pop(vm);
uc_value_t *scope, *next;
@@ -1182,7 +1182,7 @@ uc_vm_insn_store_var(uc_vm *vm, enum insn_type insn)
}
static void
-uc_vm_insn_store_val(uc_vm *vm, enum insn_type insn)
+uc_vm_insn_store_val(uc_vm_t *vm, uc_vm_insn_t insn)
{
uc_value_t *v = uc_vm_stack_pop(vm);
uc_value_t *k = uc_vm_stack_pop(vm);
@@ -1205,10 +1205,10 @@ uc_vm_insn_store_val(uc_vm *vm, enum insn_type insn)
}
static void
-uc_vm_insn_store_upval(uc_vm *vm, enum insn_type insn)
+uc_vm_insn_store_upval(uc_vm_t *vm, uc_vm_insn_t insn)
{
- uc_callframe *frame = uc_vm_current_frame(vm);
- uc_upvalref_t *ref = frame->closure->upvals[vm->arg.u32];
+ uc_callframe_t *frame = uc_vm_current_frame(vm);
+ uc_upval_tref_t *ref = frame->closure->upvals[vm->arg.u32];
uc_value_t *val = ucv_get(uc_vm_stack_peek(vm, 0));
if (ref->closed) {
@@ -1221,16 +1221,16 @@ uc_vm_insn_store_upval(uc_vm *vm, enum insn_type insn)
}
static void
-uc_vm_insn_store_local(uc_vm *vm, enum insn_type insn)
+uc_vm_insn_store_local(uc_vm_t *vm, uc_vm_insn_t insn)
{
- uc_callframe *frame = uc_vm_current_frame(vm);
+ uc_callframe_t *frame = uc_vm_current_frame(vm);
uc_value_t *val = ucv_get(uc_vm_stack_peek(vm, 0));
uc_vm_stack_set(vm, frame->stackframe + vm->arg.u32, val);
}
static uc_value_t *
-uc_vm_value_bitop(uc_vm *vm, enum insn_type operation, uc_value_t *value, uc_value_t *operand)
+uc_vm_value_bitop(uc_vm_t *vm, uc_vm_insn_t operation, uc_value_t *value, uc_value_t *operand)
{
uc_value_t *rv = NULL;
int64_t n1, n2;
@@ -1271,7 +1271,7 @@ uc_vm_value_bitop(uc_vm *vm, enum insn_type operation, uc_value_t *value, uc_val
}
static uc_value_t *
-uc_vm_value_arith(uc_vm *vm, enum insn_type operation, uc_value_t *value, uc_value_t *operand)
+uc_vm_value_arith(uc_vm_t *vm, uc_vm_insn_t operation, uc_value_t *value, uc_value_t *operand)
{
uc_value_t *rv = NULL;
uc_type_t t1, t2;
@@ -1386,7 +1386,7 @@ uc_vm_value_arith(uc_vm *vm, enum insn_type operation, uc_value_t *value, uc_val
}
static void
-uc_vm_insn_update_var(uc_vm *vm, enum insn_type insn)
+uc_vm_insn_update_var(uc_vm_t *vm, uc_vm_insn_t insn)
{
uc_value_t *name, *val, *inc = uc_vm_stack_pop(vm);
uc_value_t *scope, *next;
@@ -1428,7 +1428,7 @@ uc_vm_insn_update_var(uc_vm *vm, enum insn_type insn)
}
static void
-uc_vm_insn_update_val(uc_vm *vm, enum insn_type insn)
+uc_vm_insn_update_val(uc_vm_t *vm, uc_vm_insn_t insn)
{
uc_value_t *inc = uc_vm_stack_pop(vm);
uc_value_t *k = uc_vm_stack_pop(vm);
@@ -1457,11 +1457,11 @@ uc_vm_insn_update_val(uc_vm *vm, enum insn_type insn)
}
static void
-uc_vm_insn_update_upval(uc_vm *vm, enum insn_type insn)
+uc_vm_insn_update_upval(uc_vm_t *vm, uc_vm_insn_t insn)
{
- uc_callframe *frame = uc_vm_current_frame(vm);
+ uc_callframe_t *frame = uc_vm_current_frame(vm);
size_t slot = vm->arg.u32 & 0x00FFFFFF;
- uc_upvalref_t *ref = frame->closure->upvals[slot];
+ uc_upval_tref_t *ref = frame->closure->upvals[slot];
uc_value_t *inc = uc_vm_stack_pop(vm);
uc_value_t *val;
@@ -1486,9 +1486,9 @@ uc_vm_insn_update_upval(uc_vm *vm, enum insn_type insn)
}
static void
-uc_vm_insn_update_local(uc_vm *vm, enum insn_type insn)
+uc_vm_insn_update_local(uc_vm_t *vm, uc_vm_insn_t insn)
{
- uc_callframe *frame = uc_vm_current_frame(vm);
+ uc_callframe_t *frame = uc_vm_current_frame(vm);
size_t slot = vm->arg.u32 & 0x00FFFFFF;
uc_value_t *inc = uc_vm_stack_pop(vm);
uc_value_t *val;
@@ -1503,7 +1503,7 @@ uc_vm_insn_update_local(uc_vm *vm, enum insn_type insn)
}
static void
-uc_vm_insn_narr(uc_vm *vm, enum insn_type insn)
+uc_vm_insn_narr(uc_vm_t *vm, uc_vm_insn_t insn)
{
uc_value_t *arr = ucv_array_new_length(vm, vm->arg.u32);
@@ -1511,7 +1511,7 @@ uc_vm_insn_narr(uc_vm *vm, enum insn_type insn)
}
static void
-uc_vm_insn_parr(uc_vm *vm, enum insn_type insn)
+uc_vm_insn_parr(uc_vm_t *vm, uc_vm_insn_t insn)
{
uc_value_t *arr = uc_vm_stack_peek(vm, vm->arg.u32);
size_t idx;
@@ -1526,7 +1526,7 @@ uc_vm_insn_parr(uc_vm *vm, enum insn_type insn)
}
static void
-uc_vm_insn_marr(uc_vm *vm, enum insn_type insn)
+uc_vm_insn_marr(uc_vm_t *vm, uc_vm_insn_t insn)
{
uc_value_t *src = uc_vm_stack_pop(vm);
uc_value_t *dst = uc_vm_stack_peek(vm, 0);
@@ -1549,7 +1549,7 @@ uc_vm_insn_marr(uc_vm *vm, enum insn_type insn)
}
static void
-uc_vm_insn_nobj(uc_vm *vm, enum insn_type insn)
+uc_vm_insn_nobj(uc_vm_t *vm, uc_vm_insn_t insn)
{
uc_value_t *obj = ucv_object_new(vm);
@@ -1557,7 +1557,7 @@ uc_vm_insn_nobj(uc_vm *vm, enum insn_type insn)
}
static void
-uc_vm_insn_sobj(uc_vm *vm, enum insn_type insn)
+uc_vm_insn_sobj(uc_vm_t *vm, uc_vm_insn_t insn)
{
uc_value_t *obj = uc_vm_stack_peek(vm, vm->arg.u32);
uc_value_t *val;
@@ -1575,7 +1575,7 @@ uc_vm_insn_sobj(uc_vm *vm, enum insn_type insn)
}
static void
-uc_vm_insn_mobj(uc_vm *vm, enum insn_type insn)
+uc_vm_insn_mobj(uc_vm_t *vm, uc_vm_insn_t insn)
{
uc_value_t *src = uc_vm_stack_pop(vm);
uc_value_t *dst = uc_vm_stack_peek(vm, 0);
@@ -1611,7 +1611,7 @@ uc_vm_insn_mobj(uc_vm *vm, enum insn_type insn)
}
static void
-uc_vm_insn_arith(uc_vm *vm, enum insn_type insn)
+uc_vm_insn_arith(uc_vm_t *vm, uc_vm_insn_t insn)
{
uc_value_t *r2 = uc_vm_stack_pop(vm);
uc_value_t *r1 = uc_vm_stack_pop(vm);
@@ -1626,7 +1626,7 @@ uc_vm_insn_arith(uc_vm *vm, enum insn_type insn)
}
static void
-uc_vm_insn_plus_minus(uc_vm *vm, enum insn_type insn)
+uc_vm_insn_plus_minus(uc_vm_t *vm, uc_vm_insn_t insn)
{
uc_value_t *v = uc_vm_stack_pop(vm);
bool is_sub = (insn == I_MINUS);
@@ -1650,7 +1650,7 @@ uc_vm_insn_plus_minus(uc_vm *vm, enum insn_type insn)
}
static void
-uc_vm_insn_bitop(uc_vm *vm, enum insn_type insn)
+uc_vm_insn_bitop(uc_vm_t *vm, uc_vm_insn_t insn)
{
uc_value_t *r2 = uc_vm_stack_pop(vm);
uc_value_t *r1 = uc_vm_stack_pop(vm);
@@ -1665,7 +1665,7 @@ uc_vm_insn_bitop(uc_vm *vm, enum insn_type insn)
}
static void
-uc_vm_insn_complement(uc_vm *vm, enum insn_type insn)
+uc_vm_insn_complement(uc_vm_t *vm, uc_vm_insn_t insn)
{
uc_value_t *v = uc_vm_stack_pop(vm);
int64_t n;
@@ -1680,7 +1680,7 @@ uc_vm_insn_complement(uc_vm *vm, enum insn_type insn)
}
static void
-uc_vm_insn_rel(uc_vm *vm, enum insn_type insn)
+uc_vm_insn_rel(uc_vm_t *vm, uc_vm_insn_t insn)
{
uc_value_t *r2 = uc_vm_stack_pop(vm);
uc_value_t *r1 = uc_vm_stack_pop(vm);
@@ -1694,7 +1694,7 @@ uc_vm_insn_rel(uc_vm *vm, enum insn_type insn)
}
static void
-uc_vm_insn_in(uc_vm *vm, enum insn_type insn)
+uc_vm_insn_in(uc_vm_t *vm, uc_vm_insn_t insn)
{
uc_value_t *r2 = uc_vm_stack_pop(vm);
uc_value_t *r1 = uc_vm_stack_pop(vm);
@@ -1740,7 +1740,7 @@ uc_vm_insn_in(uc_vm *vm, enum insn_type insn)
}
static void
-uc_vm_insn_equality(uc_vm *vm, enum insn_type insn)
+uc_vm_insn_equality(uc_vm_t *vm, uc_vm_insn_t insn)
{
uc_value_t *r2 = uc_vm_stack_pop(vm);
uc_value_t *r1 = uc_vm_stack_pop(vm);
@@ -1758,7 +1758,7 @@ uc_vm_insn_equality(uc_vm *vm, enum insn_type insn)
}
static void
-uc_vm_insn_not(uc_vm *vm, enum insn_type insn)
+uc_vm_insn_not(uc_vm_t *vm, uc_vm_insn_t insn)
{
uc_value_t *r1 = uc_vm_stack_pop(vm);
@@ -1767,10 +1767,10 @@ uc_vm_insn_not(uc_vm *vm, enum insn_type insn)
}
static void
-uc_vm_insn_jmp(uc_vm *vm, enum insn_type insn)
+uc_vm_insn_jmp(uc_vm_t *vm, uc_vm_insn_t insn)
{
- uc_callframe *frame = uc_vm_current_frame(vm);
- uc_chunk *chunk = uc_vm_frame_chunk(frame);
+ uc_callframe_t *frame = uc_vm_current_frame(vm);
+ uc_chunk_t *chunk = uc_vm_frame_chunk(frame);
int32_t addr = vm->arg.s32;
/* ip already has been incremented */
@@ -1786,10 +1786,10 @@ uc_vm_insn_jmp(uc_vm *vm, enum insn_type insn)
}
static void
-uc_vm_insn_jmpz(uc_vm *vm, enum insn_type insn)
+uc_vm_insn_jmpz(uc_vm_t *vm, uc_vm_insn_t insn)
{
- uc_callframe *frame = uc_vm_current_frame(vm);
- uc_chunk *chunk = uc_vm_frame_chunk(frame);
+ uc_callframe_t *frame = uc_vm_current_frame(vm);
+ uc_chunk_t *chunk = uc_vm_frame_chunk(frame);
uc_value_t *v = uc_vm_stack_pop(vm);
int32_t addr = vm->arg.s32;
@@ -1809,7 +1809,7 @@ uc_vm_insn_jmpz(uc_vm *vm, enum insn_type insn)
}
static void
-uc_vm_insn_next(uc_vm *vm, enum insn_type insn)
+uc_vm_insn_next(uc_vm_t *vm, uc_vm_insn_t insn)
{
uc_value_t *k = uc_vm_stack_pop(vm);
uc_value_t *v = uc_vm_stack_pop(vm);
@@ -1882,14 +1882,14 @@ uc_vm_insn_next(uc_vm *vm, enum insn_type insn)
}
static void
-uc_vm_insn_close_upval(uc_vm *vm, enum insn_type insn)
+uc_vm_insn_close_upval(uc_vm_t *vm, uc_vm_insn_t insn)
{
uc_vm_close_upvals(vm, vm->stack.count - 1);
ucv_put(uc_vm_stack_pop(vm));
}
static void
-uc_vm_insn_call(uc_vm *vm, enum insn_type insn)
+uc_vm_insn_call(uc_vm_t *vm, uc_vm_insn_t insn)
{
uc_value_t *fno = ucv_get(uc_vm_stack_peek(vm, vm->arg.u32 & 0xffff));
uc_value_t *ctx = NULL;
@@ -1903,7 +1903,7 @@ uc_vm_insn_call(uc_vm *vm, enum insn_type insn)
}
static void
-uc_vm_insn_mcall(uc_vm *vm, enum insn_type insn)
+uc_vm_insn_mcall(uc_vm_t *vm, uc_vm_insn_t insn)
{
size_t key_slot = vm->stack.count - (vm->arg.u32 & 0xffff) - 1;
uc_value_t *ctx = vm->stack.entries[key_slot - 1];
@@ -1920,7 +1920,7 @@ uc_vm_insn_mcall(uc_vm *vm, enum insn_type insn)
}
static void
-uc_vm_insn_print(uc_vm *vm, enum insn_type insn)
+uc_vm_insn_print(uc_vm_t *vm, uc_vm_insn_t insn)
{
uc_value_t *v = uc_vm_stack_pop(vm);
char *p;
@@ -1950,7 +1950,7 @@ uc_vm_insn_print(uc_vm *vm, enum insn_type insn)
}
static void
-uc_vm_insn_delete(uc_vm *vm, enum insn_type insn)
+uc_vm_insn_delete(uc_vm_t *vm, uc_vm_insn_t insn)
{
uc_value_t *k = uc_vm_stack_pop(vm);
uc_value_t *v = uc_vm_stack_pop(vm);
@@ -1975,9 +1975,9 @@ uc_vm_insn_delete(uc_vm *vm, enum insn_type insn)
}
static uc_value_t *
-uc_vm_callframe_pop(uc_vm *vm)
+uc_vm_callframe_pop(uc_vm_t *vm)
{
- uc_callframe *frame = uc_vm_current_frame(vm);
+ uc_callframe_t *frame = uc_vm_current_frame(vm);
uc_value_t *retval;
/* close upvalues */
@@ -2012,7 +2012,7 @@ uc_vm_callframe_pop(uc_vm *vm)
}
static void
-uc_vm_output_exception(uc_vm *vm, uc_exception *ex)
+uc_vm_output_exception(uc_vm_t *vm, uc_exception_t *ex)
{
uc_value_t *ctx;
@@ -2032,12 +2032,12 @@ uc_vm_output_exception(uc_vm *vm, uc_exception *ex)
}
static uc_vm_status_t
-uc_vm_execute_chunk(uc_vm *vm, uc_value_t **retvalp)
+uc_vm_execute_chunk(uc_vm_t *vm, uc_value_t **retvalp)
{
- uc_callframe *frame = uc_vm_current_frame(vm);
- uc_chunk *chunk = uc_vm_frame_chunk(frame);
+ uc_callframe_t *frame = uc_vm_current_frame(vm);
+ uc_chunk_t *chunk = uc_vm_frame_chunk(frame);
uc_value_t *retval;
- enum insn_type insn;
+ uc_vm_insn_t insn;
while (chunk) {
if (vm->trace)
@@ -2302,10 +2302,10 @@ uc_vm_execute_chunk(uc_vm *vm, uc_value_t **retvalp)
}
uc_vm_status_t
-uc_vm_execute(uc_vm *vm, uc_function_t *fn, uc_value_t **retval)
+uc_vm_execute(uc_vm_t *vm, uc_function_t *fn, uc_value_t **retval)
{
uc_closure_t *closure = (uc_closure_t *)ucv_closure_new(vm, fn, false);
- uc_callframe *frame;
+ uc_callframe_t *frame;
uc_stringbuf_t *buf;
uc_vector_grow(&vm->callframes);
@@ -2337,7 +2337,7 @@ uc_vm_execute(uc_vm *vm, uc_function_t *fn, uc_value_t **retval)
}
uc_exception_type_t
-uc_vm_call(uc_vm *vm, bool mcall, size_t nargs)
+uc_vm_call(uc_vm_t *vm, bool mcall, size_t nargs)
{
uc_value_t *ctx = mcall ? ucv_get(uc_vm_stack_peek(vm, nargs + 1)) : NULL;
uc_value_t *fno = ucv_get(uc_vm_stack_peek(vm, nargs));
@@ -2351,20 +2351,20 @@ uc_vm_call(uc_vm *vm, bool mcall, size_t nargs)
}
uc_value_t *
-uc_vm_scope_get(uc_vm *vm)
+uc_vm_scope_get(uc_vm_t *vm)
{
return vm->globals;
}
void
-uc_vm_scope_set(uc_vm *vm, uc_value_t *ctx)
+uc_vm_scope_set(uc_vm_t *vm, uc_value_t *ctx)
{
ucv_put(vm->globals);
vm->globals = ctx;
}
uc_value_t *
-uc_vm_invoke(uc_vm *vm, const char *fname, size_t nargs, ...)
+uc_vm_invoke(uc_vm_t *vm, const char *fname, size_t nargs, ...)
{
uc_exception_type_t ex;
uc_value_t *fno, *arg;
@@ -2396,25 +2396,25 @@ uc_vm_invoke(uc_vm *vm, const char *fname, size_t nargs, ...)
}
uc_exception_handler_t *
-uc_vm_exception_handler_get(uc_vm *vm)
+uc_vm_exception_handler_get(uc_vm_t *vm)
{
return vm->exhandler;
}
void
-uc_vm_exception_handler_set(uc_vm *vm, uc_exception_handler_t *exhandler)
+uc_vm_exception_handler_set(uc_vm_t *vm, uc_exception_handler_t *exhandler)
{
vm->exhandler = exhandler;
}
uint32_t
-uc_vm_trace_get(uc_vm *vm)
+uc_vm_trace_get(uc_vm_t *vm)
{
return vm->trace;
}
void
-uc_vm_trace_set(uc_vm *vm, uint32_t level)
+uc_vm_trace_set(uc_vm_t *vm, uint32_t level)
{
vm->trace = level;
}
diff --git a/vm.h b/vm.h
index 3d22105..553cf61 100644
--- a/vm.h
+++ b/vm.h
@@ -96,10 +96,10 @@ __insn(DELETE)
#undef __insn
#define __insn(_name) I_##_name,
-enum insn_type {
+typedef enum {
__insns
__I_MAX
-};
+} uc_vm_insn_t;
typedef enum {
STATUS_OK,
@@ -110,28 +110,28 @@ typedef enum {
extern uint32_t insns[__I_MAX];
-void uc_vm_init(uc_vm *vm, uc_parse_config *config);
-void uc_vm_free(uc_vm *vm);
+void uc_vm_init(uc_vm_t *vm, uc_parse_config_t *config);
+void uc_vm_free(uc_vm_t *vm);
-uc_value_t *uc_vm_scope_get(uc_vm *vm);
-void uc_vm_scope_set(uc_vm *vm, uc_value_t *ctx);
+uc_value_t *uc_vm_scope_get(uc_vm_t *vm);
+void uc_vm_scope_set(uc_vm_t *vm, uc_value_t *ctx);
-void uc_vm_stack_push(uc_vm *vm, uc_value_t *value);
-uc_value_t *uc_vm_stack_pop(uc_vm *vm);
-uc_value_t *uc_vm_stack_peek(uc_vm *vm, size_t offset);
+void uc_vm_stack_push(uc_vm_t *vm, uc_value_t *value);
+uc_value_t *uc_vm_stack_pop(uc_vm_t *vm);
+uc_value_t *uc_vm_stack_peek(uc_vm_t *vm, size_t offset);
-uc_exception_handler_t *uc_vm_exception_handler_get(uc_vm *vm);
-void uc_vm_exception_handler_set(uc_vm *vm, uc_exception_handler_t *exhandler);
+uc_exception_handler_t *uc_vm_exception_handler_get(uc_vm_t *vm);
+void uc_vm_exception_handler_set(uc_vm_t *vm, uc_exception_handler_t *exhandler);
-uint32_t uc_vm_trace_get(uc_vm *vm);
-void uc_vm_trace_set(uc_vm *vm, uint32_t level);
+uint32_t uc_vm_trace_get(uc_vm_t *vm);
+void uc_vm_trace_set(uc_vm_t *vm, uint32_t level);
-uc_exception_type_t uc_vm_call(uc_vm *vm, bool mcall, size_t nargs);
+uc_exception_type_t uc_vm_call(uc_vm_t *vm, bool mcall, size_t nargs);
void __attribute__((format(printf, 3, 0)))
-uc_vm_raise_exception(uc_vm *vm, uc_exception_type_t type, const char *fmt, ...);
+uc_vm_raise_exception(uc_vm_t *vm, uc_exception_type_t type, const char *fmt, ...);
-uc_vm_status_t uc_vm_execute(uc_vm *vm, uc_function_t *fn, uc_value_t **retval);
-uc_value_t *uc_vm_invoke(uc_vm *vm, const char *fname, size_t nargs, ...);
+uc_vm_status_t uc_vm_execute(uc_vm_t *vm, uc_function_t *fn, uc_value_t **retval);
+uc_value_t *uc_vm_invoke(uc_vm_t *vm, const char *fname, size_t nargs, ...);
#endif /* __VM_H_ */