Bug fixes
This commit is contained in:
@@ -379,6 +379,7 @@ struct Node {
|
|||||||
|
|
||||||
Node *params;
|
Node *params;
|
||||||
Node *child;
|
Node *child;
|
||||||
|
bool no_body;
|
||||||
|
|
||||||
Node *cond;
|
Node *cond;
|
||||||
|
|
||||||
@@ -1006,6 +1007,7 @@ Node *parse_html(Parser *p)
|
|||||||
parent->tagname = tagname;
|
parent->tagname = tagname;
|
||||||
parent->params = param_head;
|
parent->params = param_head;
|
||||||
parent->child = head;
|
parent->child = head;
|
||||||
|
parent->no_body = no_body;
|
||||||
|
|
||||||
return parent;
|
return parent;
|
||||||
}
|
}
|
||||||
@@ -2801,21 +2803,29 @@ void assemble_html_2(Assembler *a, HTMLAssembler *ha, Node *node)
|
|||||||
|
|
||||||
if (value) {
|
if (value) {
|
||||||
append_u8(&ha->tmp, '=');
|
append_u8(&ha->tmp, '=');
|
||||||
|
append_u8(&ha->tmp, '"');
|
||||||
|
|
||||||
if (value->type == NODE_VALUE_STR) {
|
if (value->type == NODE_VALUE_STR) {
|
||||||
append_u8(&ha->tmp, '"');
|
|
||||||
append_mem(&ha->tmp,
|
append_mem(&ha->tmp,
|
||||||
value->sval.ptr, // TODO: escape
|
value->sval.ptr, // TODO: escape
|
||||||
value->sval.len
|
value->sval.len
|
||||||
);
|
);
|
||||||
append_u8(&ha->tmp, '"');
|
|
||||||
} else {
|
} else {
|
||||||
write_buffered_html(a, ha);
|
write_buffered_html(a, ha);
|
||||||
assemble_statement(a, value, false);
|
assemble_statement(a, value, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
append_u8(&ha->tmp, '"');
|
||||||
}
|
}
|
||||||
attr = attr->next;
|
attr = attr->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (node->no_body) {
|
||||||
|
append_u8(&ha->tmp, ' ');
|
||||||
|
append_u8(&ha->tmp, '/');
|
||||||
|
append_u8(&ha->tmp, '>');
|
||||||
|
} else {
|
||||||
|
|
||||||
append_u8(&ha->tmp, '>');
|
append_u8(&ha->tmp, '>');
|
||||||
|
|
||||||
Node *child = node->child;
|
Node *child = node->child;
|
||||||
@@ -2835,6 +2845,7 @@ void assemble_html_2(Assembler *a, HTMLAssembler *ha, Node *node)
|
|||||||
append_u8(&ha->tmp, '/');
|
append_u8(&ha->tmp, '/');
|
||||||
append_mem(&ha->tmp, node->tagname.ptr, node->tagname.len);
|
append_mem(&ha->tmp, node->tagname.ptr, node->tagname.len);
|
||||||
append_u8(&ha->tmp, '>');
|
append_u8(&ha->tmp, '>');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void assemble_html(Assembler *a, Node *node)
|
void assemble_html(Assembler *a, Node *node)
|
||||||
@@ -3337,6 +3348,7 @@ void assemble_statement(Assembler *a, Node *node, bool pop_expr)
|
|||||||
|
|
||||||
assert(off == idx);
|
assert(off == idx);
|
||||||
|
|
||||||
|
idx++;
|
||||||
arg = arg->next;
|
arg = arg->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4218,7 +4230,7 @@ Value *array_select(Value array, int key)
|
|||||||
int cursor = 0;
|
int cursor = 0;
|
||||||
while (batch) {
|
while (batch) {
|
||||||
|
|
||||||
int num = ITEMS_PER_MAP_BATCH;
|
int num = ITEMS_PER_ARRAY_BATCH;
|
||||||
if (batch->next == NULL)
|
if (batch->next == NULL)
|
||||||
num = p->tail_count;
|
num = p->tail_count;
|
||||||
|
|
||||||
@@ -4235,7 +4247,7 @@ Value *array_select(Value array, int key)
|
|||||||
int array_append(WL_Arena *a, Value array, Value val)
|
int array_append(WL_Arena *a, Value array, Value val)
|
||||||
{
|
{
|
||||||
ArrayValue *p = get_array(array);
|
ArrayValue *p = get_array(array);
|
||||||
if (p->tail_count == ITEMS_PER_MAP_BATCH) {
|
if (p->tail_count == ITEMS_PER_ARRAY_BATCH) {
|
||||||
|
|
||||||
ArrayItems *batch = alloc(a, (int) sizeof(ArrayItems), _Alignof(ArrayItems));
|
ArrayItems *batch = alloc(a, (int) sizeof(ArrayItems), _Alignof(ArrayItems));
|
||||||
if (batch == NULL)
|
if (batch == NULL)
|
||||||
@@ -5210,7 +5222,12 @@ int step(WL_State *state)
|
|||||||
|
|
||||||
if (type_of(set) == TYPE_ARRAY) {
|
if (type_of(set) == TYPE_ARRAY) {
|
||||||
|
|
||||||
Value *dst = array_select(set, key);
|
if (type_of(key) != TYPE_INT) {
|
||||||
|
assert(0); // TODO
|
||||||
|
}
|
||||||
|
int64_t idx = get_int(key);
|
||||||
|
|
||||||
|
Value *dst = array_select(set, idx);
|
||||||
if (dst == NULL) {
|
if (dst == NULL) {
|
||||||
eval_report(state, "Index out of range");
|
eval_report(state, "Index out of range");
|
||||||
return -1;
|
return -1;
|
||||||
@@ -5241,7 +5258,12 @@ int step(WL_State *state)
|
|||||||
|
|
||||||
if (type_of(set) == TYPE_ARRAY) {
|
if (type_of(set) == TYPE_ARRAY) {
|
||||||
|
|
||||||
Value *dst = array_select(set, key);
|
if (type_of(key) != TYPE_INT) {
|
||||||
|
assert(0); // TODO
|
||||||
|
}
|
||||||
|
int64_t idx = get_int(key);
|
||||||
|
|
||||||
|
Value *dst = array_select(set, idx);
|
||||||
if (dst == NULL) {
|
if (dst == NULL) {
|
||||||
eval_report(state, "Index out of range");
|
eval_report(state, "Index out of range");
|
||||||
return -1;
|
return -1;
|
||||||
@@ -5272,7 +5294,12 @@ int step(WL_State *state)
|
|||||||
Value r;
|
Value r;
|
||||||
if (type_of(set) == TYPE_ARRAY) {
|
if (type_of(set) == TYPE_ARRAY) {
|
||||||
|
|
||||||
Value *src = array_select(set, key);
|
if (type_of(key) != TYPE_INT) {
|
||||||
|
assert(0); // TODO
|
||||||
|
}
|
||||||
|
int64_t idx = get_int(key);
|
||||||
|
|
||||||
|
Value *src = array_select(set, idx);
|
||||||
if (src == NULL) {
|
if (src == NULL) {
|
||||||
eval_report(state, "Index out of range");
|
eval_report(state, "Index out of range");
|
||||||
return -1;
|
return -1;
|
||||||
|
|||||||
+12
-2
@@ -441,21 +441,29 @@ void assemble_html_2(Assembler *a, HTMLAssembler *ha, Node *node)
|
|||||||
|
|
||||||
if (value) {
|
if (value) {
|
||||||
append_u8(&ha->tmp, '=');
|
append_u8(&ha->tmp, '=');
|
||||||
|
append_u8(&ha->tmp, '"');
|
||||||
|
|
||||||
if (value->type == NODE_VALUE_STR) {
|
if (value->type == NODE_VALUE_STR) {
|
||||||
append_u8(&ha->tmp, '"');
|
|
||||||
append_mem(&ha->tmp,
|
append_mem(&ha->tmp,
|
||||||
value->sval.ptr, // TODO: escape
|
value->sval.ptr, // TODO: escape
|
||||||
value->sval.len
|
value->sval.len
|
||||||
);
|
);
|
||||||
append_u8(&ha->tmp, '"');
|
|
||||||
} else {
|
} else {
|
||||||
write_buffered_html(a, ha);
|
write_buffered_html(a, ha);
|
||||||
assemble_statement(a, value, false);
|
assemble_statement(a, value, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
append_u8(&ha->tmp, '"');
|
||||||
}
|
}
|
||||||
attr = attr->next;
|
attr = attr->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (node->no_body) {
|
||||||
|
append_u8(&ha->tmp, ' ');
|
||||||
|
append_u8(&ha->tmp, '/');
|
||||||
|
append_u8(&ha->tmp, '>');
|
||||||
|
} else {
|
||||||
|
|
||||||
append_u8(&ha->tmp, '>');
|
append_u8(&ha->tmp, '>');
|
||||||
|
|
||||||
Node *child = node->child;
|
Node *child = node->child;
|
||||||
@@ -475,6 +483,7 @@ void assemble_html_2(Assembler *a, HTMLAssembler *ha, Node *node)
|
|||||||
append_u8(&ha->tmp, '/');
|
append_u8(&ha->tmp, '/');
|
||||||
append_mem(&ha->tmp, node->tagname.ptr, node->tagname.len);
|
append_mem(&ha->tmp, node->tagname.ptr, node->tagname.len);
|
||||||
append_u8(&ha->tmp, '>');
|
append_u8(&ha->tmp, '>');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void assemble_html(Assembler *a, Node *node)
|
void assemble_html(Assembler *a, Node *node)
|
||||||
@@ -977,6 +986,7 @@ void assemble_statement(Assembler *a, Node *node, bool pop_expr)
|
|||||||
|
|
||||||
assert(off == idx);
|
assert(off == idx);
|
||||||
|
|
||||||
|
idx++;
|
||||||
arg = arg->next;
|
arg = arg->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+18
-3
@@ -723,7 +723,12 @@ int step(WL_State *state)
|
|||||||
|
|
||||||
if (type_of(set) == TYPE_ARRAY) {
|
if (type_of(set) == TYPE_ARRAY) {
|
||||||
|
|
||||||
Value *dst = array_select(set, key);
|
if (type_of(key) != TYPE_INT) {
|
||||||
|
assert(0); // TODO
|
||||||
|
}
|
||||||
|
int64_t idx = get_int(key);
|
||||||
|
|
||||||
|
Value *dst = array_select(set, idx);
|
||||||
if (dst == NULL) {
|
if (dst == NULL) {
|
||||||
eval_report(state, "Index out of range");
|
eval_report(state, "Index out of range");
|
||||||
return -1;
|
return -1;
|
||||||
@@ -754,7 +759,12 @@ int step(WL_State *state)
|
|||||||
|
|
||||||
if (type_of(set) == TYPE_ARRAY) {
|
if (type_of(set) == TYPE_ARRAY) {
|
||||||
|
|
||||||
Value *dst = array_select(set, key);
|
if (type_of(key) != TYPE_INT) {
|
||||||
|
assert(0); // TODO
|
||||||
|
}
|
||||||
|
int64_t idx = get_int(key);
|
||||||
|
|
||||||
|
Value *dst = array_select(set, idx);
|
||||||
if (dst == NULL) {
|
if (dst == NULL) {
|
||||||
eval_report(state, "Index out of range");
|
eval_report(state, "Index out of range");
|
||||||
return -1;
|
return -1;
|
||||||
@@ -785,7 +795,12 @@ int step(WL_State *state)
|
|||||||
Value r;
|
Value r;
|
||||||
if (type_of(set) == TYPE_ARRAY) {
|
if (type_of(set) == TYPE_ARRAY) {
|
||||||
|
|
||||||
Value *src = array_select(set, key);
|
if (type_of(key) != TYPE_INT) {
|
||||||
|
assert(0); // TODO
|
||||||
|
}
|
||||||
|
int64_t idx = get_int(key);
|
||||||
|
|
||||||
|
Value *src = array_select(set, idx);
|
||||||
if (src == NULL) {
|
if (src == NULL) {
|
||||||
eval_report(state, "Index out of range");
|
eval_report(state, "Index out of range");
|
||||||
return -1;
|
return -1;
|
||||||
|
|||||||
@@ -592,6 +592,7 @@ Node *parse_html(Parser *p)
|
|||||||
parent->tagname = tagname;
|
parent->tagname = tagname;
|
||||||
parent->params = param_head;
|
parent->params = param_head;
|
||||||
parent->child = head;
|
parent->child = head;
|
||||||
|
parent->no_body = no_body;
|
||||||
|
|
||||||
return parent;
|
return parent;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -58,6 +58,7 @@ struct Node {
|
|||||||
|
|
||||||
Node *params;
|
Node *params;
|
||||||
Node *child;
|
Node *child;
|
||||||
|
bool no_body;
|
||||||
|
|
||||||
Node *cond;
|
Node *cond;
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -253,7 +253,7 @@ Value *array_select(Value array, int key)
|
|||||||
int cursor = 0;
|
int cursor = 0;
|
||||||
while (batch) {
|
while (batch) {
|
||||||
|
|
||||||
int num = ITEMS_PER_MAP_BATCH;
|
int num = ITEMS_PER_ARRAY_BATCH;
|
||||||
if (batch->next == NULL)
|
if (batch->next == NULL)
|
||||||
num = p->tail_count;
|
num = p->tail_count;
|
||||||
|
|
||||||
@@ -270,7 +270,7 @@ Value *array_select(Value array, int key)
|
|||||||
int array_append(WL_Arena *a, Value array, Value val)
|
int array_append(WL_Arena *a, Value array, Value val)
|
||||||
{
|
{
|
||||||
ArrayValue *p = get_array(array);
|
ArrayValue *p = get_array(array);
|
||||||
if (p->tail_count == ITEMS_PER_MAP_BATCH) {
|
if (p->tail_count == ITEMS_PER_ARRAY_BATCH) {
|
||||||
|
|
||||||
ArrayItems *batch = alloc(a, (int) sizeof(ArrayItems), _Alignof(ArrayItems));
|
ArrayItems *batch = alloc(a, (int) sizeof(ArrayItems), _Alignof(ArrayItems));
|
||||||
if (batch == NULL)
|
if (batch == NULL)
|
||||||
|
|||||||
Reference in New Issue
Block a user