minor cleanups

This commit is contained in:
cozis
2022-08-17 19:54:28 +02:00
parent 6ba7fd21ef
commit e4bc4fe253
3 changed files with 30 additions and 32 deletions
+4 -1
View File
@@ -1,6 +1,8 @@
fun isSpace(c: String) fun isSpace(c: String)
return c == " " or c == "\t" or c == "\n"; return c == " "
or c == "\t"
or c == "\n";
fun isDigit(c: String) { fun isDigit(c: String) {
u = unicode(c); u = unicode(c);
@@ -232,6 +234,7 @@ fun parseValue(context: Map) {
} }
fun parse(str: String) { fun parse(str: String) {
context = {str: str, cur: 0}; context = {str: str, cur: 0};
skipSpaces(context); skipSpaces(context);
val, err = parseValue(context); val, err = parseValue(context);
+3 -8
View File
@@ -149,7 +149,6 @@ static int bin_import(Runtime *runtime, Object **argv, unsigned int argc, Object
} }
Object *sub_rets[8]; Object *sub_rets[8];
{
int retc = run(runtime, &sub_error, exe, 0, NULL, NULL, 0, sub_rets); int retc = run(runtime, &sub_error, exe, 0, NULL, NULL, 0, sub_rets);
if(retc < 0) if(retc < 0)
{ {
@@ -158,12 +157,10 @@ static int bin_import(Runtime *runtime, Object **argv, unsigned int argc, Object
UNUSED(errname); UNUSED(errname);
Object *o_none = Object_NewNone(heap, error); Object *o_none = Object_NewNone(heap, error);
if(o_none == NULL) if(o_none == NULL) return -1;
return -1;
Object *o_err = Object_FromString(sub_error.message, -1, heap, error); Object *o_err = Object_FromString(sub_error.message, -1, heap, error);
if(o_err == NULL) if(o_err == NULL) return -1;
return -1;
Error_Free(&sub_error); Error_Free(&sub_error);
rets[0] = o_none; rets[0] = o_none;
@@ -171,7 +168,7 @@ static int bin_import(Runtime *runtime, Object **argv, unsigned int argc, Object
return 2; return 2;
} }
ASSERT(retc == 1); ASSERT(retc == 1);
}
Error_Free(&sub_error); Error_Free(&sub_error);
rets[0] = sub_rets[0]; rets[0] = sub_rets[0];
return 1; return 1;
@@ -505,7 +502,6 @@ void bins_basic_init(StaticMapSlot slots[])
} }
StaticMapSlot bins_basic[] = { StaticMapSlot bins_basic[] = {
{ "Type", SM_TYPE, .as_type = NULL /* Until bins_basic_init is called */ }, { "Type", SM_TYPE, .as_type = NULL /* Until bins_basic_init is called */ },
{ "None", SM_TYPE, .as_type = NULL /* Until bins_basic_init is called */ }, { "None", SM_TYPE, .as_type = NULL /* Until bins_basic_init is called */ },
{ "int", SM_TYPE, .as_type = NULL /* Until bins_basic_init is called */ }, { "int", SM_TYPE, .as_type = NULL /* Until bins_basic_init is called */ },
@@ -519,7 +515,6 @@ StaticMapSlot bins_basic[] = {
{ "math", SM_SMAP, .as_smap = bins_math, }, { "math", SM_SMAP, .as_smap = bins_math, },
{ "files", SM_SMAP, .as_smap = bins_files, }, { "files", SM_SMAP, .as_smap = bins_files, },
// { "net", SM_SMAP, .as_smap = bins_net, },
{ "import", SM_FUNCT, .as_funct = bin_import, .argc = 1, }, { "import", SM_FUNCT, .as_funct = bin_import, .argc = 1, },
{ "newBuffer", SM_FUNCT, .as_funct = bin_newBuffer, .argc = 1 }, { "newBuffer", SM_FUNCT, .as_funct = bin_newBuffer, .argc = 1 },