Browse Source

Review fixes, mostly assert order fixes

pull/222/head
Sami Vaarala 10 years ago
parent
commit
0a1f31d79f
  1. 14
      src/duk_debugger.c
  2. 13
      src/duk_js_compiler.c
  3. 2
      src/duk_js_var.c

14
src/duk_debugger.c

@ -68,6 +68,7 @@ DUK_INTERNAL duk_bool_t duk_debug_read_peek(duk_hthread *thr) {
DUK_ASSERT(thr != NULL);
heap = thr->heap;
DUK_ASSERT(heap != NULL);
if (heap->dbg_read_cb == NULL) {
DUK_D(DUK_DPRINT("attempt to peek in detached state, return zero (= no data)"));
@ -86,6 +87,7 @@ DUK_INTERNAL void duk_debug_read_flush(duk_hthread *thr) {
DUK_ASSERT(thr != NULL);
heap = thr->heap;
DUK_ASSERT(heap != NULL);
if (heap->dbg_read_cb == NULL) {
DUK_D(DUK_DPRINT("attempt to read flush in detached state, ignore"));
@ -104,6 +106,7 @@ DUK_INTERNAL void duk_debug_write_flush(duk_hthread *thr) {
DUK_ASSERT(thr != NULL);
heap = thr->heap;
DUK_ASSERT(heap != NULL);
if (heap->dbg_read_cb == NULL) {
DUK_D(DUK_DPRINT("attempt to write flush in detached state, ignore"));
@ -154,6 +157,7 @@ DUK_INTERNAL void duk_debug_read_bytes(duk_hthread *thr, duk_uint8_t *data, duk_
DUK_ASSERT(thr != NULL);
heap = thr->heap;
DUK_ASSERT(heap != NULL);
if (heap->dbg_read_cb == NULL) {
DUK_D(DUK_DPRINT("attempt to read %ld bytes in detached state, return zero data", (long) length));
@ -192,6 +196,7 @@ DUK_INTERNAL duk_uint8_t duk_debug_read_byte(duk_hthread *thr) {
DUK_ASSERT(thr != NULL);
heap = thr->heap;
DUK_ASSERT(heap != NULL);
if (heap->dbg_read_cb == NULL) {
DUK_D(DUK_DPRINT("attempt to read 1 bytes in detached state, return zero data"));
@ -459,6 +464,7 @@ DUK_INTERNAL void duk_debug_write_bytes(duk_hthread *thr, const duk_uint8_t *dat
DUK_ASSERT(thr != NULL);
DUK_ASSERT(length == 0 || data != NULL);
heap = thr->heap;
DUK_ASSERT(heap != NULL);
if (heap->dbg_write_cb == NULL) {
DUK_D(DUK_DPRINT("attempt to write %ld bytes in detached state, ignore", (long) length));
@ -499,6 +505,7 @@ DUK_INTERNAL void duk_debug_write_byte(duk_hthread *thr, duk_uint8_t x) {
DUK_ASSERT(thr != NULL);
heap = thr->heap;
DUK_ASSERT(heap != NULL);
if (heap->dbg_write_cb == NULL) {
DUK_D(DUK_DPRINT("attempt to write 1 bytes in detached state, ignore"));
@ -1693,8 +1700,9 @@ DUK_INTERNAL duk_small_int_t duk_debug_add_breakpoint(duk_hthread *thr, duk_hstr
DUK_ASSERT(thr != NULL);
DUK_ASSERT(filename != NULL);
heap = thr->heap;
DUK_ASSERT(heap != NULL);
if (heap->dbg_breakpoint_count >= DUK_HEAP_MAX_BREAKPOINTS) {
DUK_D(DUK_DPRINT("failed to add breakpoint for %O:%ld, all breakpoint slots used",
(duk_heaphdr *) filename, (long) line));
@ -1710,7 +1718,7 @@ DUK_INTERNAL duk_small_int_t duk_debug_add_breakpoint(duk_hthread *thr, duk_hstr
}
DUK_INTERNAL duk_bool_t duk_debug_remove_breakpoint(duk_hthread *thr, duk_small_uint_t breakpoint_index) {
duk_heap *heap = thr->heap;
duk_heap *heap;
duk_hstring *h;
duk_breakpoint *b;
duk_size_t move_size;
@ -1721,6 +1729,8 @@ DUK_INTERNAL duk_bool_t duk_debug_remove_breakpoint(duk_hthread *thr, duk_small_
*/
DUK_ASSERT(thr != NULL);
heap = thr->heap;
DUK_ASSERT(heap != NULL);
DUK_ASSERT_DISABLE(breakpoint_index >= 0); /* unsigned */
if (breakpoint_index >= heap->dbg_breakpoint_count) {

13
src/duk_js_compiler.c

@ -657,6 +657,7 @@ DUK_LOCAL void duk__convert_to_func_template(duk_compiler_ctx *comp_ctx, duk_boo
(void) duk_push_compiledfunction(ctx);
h_res = (duk_hcompiledfunction *) duk_get_hobject(ctx, -1); /* XXX: specific getter */
DUK_ASSERT(h_res != NULL);
if (func->is_function) {
DUK_DDD(DUK_DDDPRINT("function -> set NEWENV"));
@ -6921,15 +6922,21 @@ DUK_LOCAL void duk__init_varmap_and_prologue_for_pass2(duk_compiler_ctx *comp_ct
*/
DUK_LOCAL void duk__parse_func_body(duk_compiler_ctx *comp_ctx, duk_bool_t expect_eof, duk_bool_t implicit_return_value, duk_small_int_t expect_token) {
duk_compiler_func *func = &comp_ctx->curr_func;
duk_hthread *thr = comp_ctx->thr;
duk_context *ctx = (duk_context *) thr;
duk_compiler_func *func;
duk_hthread *thr;
duk_context *ctx;
duk_reg_t reg_stmt_value = -1;
duk_lexer_point lex_pt;
duk_reg_t temp_first;
duk_small_int_t compile_round = 1;
DUK_ASSERT(comp_ctx != NULL);
thr = comp_ctx->thr;
ctx = (duk_context *) thr;
DUK_ASSERT(thr != NULL);
func = &comp_ctx->curr_func;
DUK_ASSERT(func != NULL);
DUK__RECURSION_INCREASE(comp_ctx, thr);

2
src/duk_js_var.c

@ -130,8 +130,8 @@ void duk_js_push_closure(duk_hthread *thr,
duk_push_hobject(ctx, &fun_temp->obj); /* -> [ ... closure template ] */
fun_clos = (duk_hcompiledfunction *) duk_get_hcompiledfunction(ctx, -2);
DUK_ASSERT(DUK_HOBJECT_IS_COMPILEDFUNCTION((duk_hobject *) fun_clos));
DUK_ASSERT(fun_clos != NULL);
DUK_ASSERT(DUK_HOBJECT_IS_COMPILEDFUNCTION((duk_hobject *) fun_clos));
DUK_ASSERT(DUK_HCOMPILEDFUNCTION_GET_DATA(thr->heap, fun_clos) == NULL);
DUK_ASSERT(DUK_HCOMPILEDFUNCTION_GET_FUNCS(thr->heap, fun_clos) == NULL);
DUK_ASSERT(DUK_HCOMPILEDFUNCTION_GET_BYTECODE(thr->heap, fun_clos) == NULL);

Loading…
Cancel
Save