Compare commits
8 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b602e2ff87 | |||
| 0b99eb7b0c | |||
| 2505cedc79 | |||
| d7035a59c8 | |||
| ea584d8950 | |||
| 2ce9a0cf42 | |||
| b77f0fb50d | |||
| edb5a52562 |
@@ -1,17 +1,26 @@
|
|||||||
name: Comprehensive Tests
|
name: Continuous Integration v1.x
|
||||||
|
|
||||||
|
#trigger when these occur
|
||||||
on:
|
on:
|
||||||
push:
|
push:
|
||||||
branches: [ "main", "dev" ]
|
branches:
|
||||||
|
- v1
|
||||||
pull_request:
|
pull_request:
|
||||||
branches: [ "main" ]
|
types:
|
||||||
|
- opened
|
||||||
|
- edited
|
||||||
|
- reopened
|
||||||
|
branches:
|
||||||
|
- v1
|
||||||
|
workflow_dispatch:
|
||||||
|
|
||||||
|
#testing the CI workflows under multiple supported conditions
|
||||||
jobs:
|
jobs:
|
||||||
test-valgrind:
|
test-valgrind:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
- name: install valgrind
|
- name: install valgrind
|
||||||
run: sudo apt install valgrind
|
run: sudo apt install valgrind
|
||||||
- name: make test (valgrind)
|
- name: make test (valgrind)
|
||||||
@@ -21,7 +30,7 @@ jobs:
|
|||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
- name: make test (sanitized)
|
- name: make test (sanitized)
|
||||||
run: make test-sanitized
|
run: make test-sanitized
|
||||||
|
|
||||||
@@ -29,6 +38,6 @@ jobs:
|
|||||||
runs-on: windows-latest
|
runs-on: windows-latest
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v3
|
- uses: actions/checkout@v4
|
||||||
- name: make test (mingw32)
|
- name: make test (mingw32)
|
||||||
run: make test
|
run: make test
|
||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
# License
|
# License
|
||||||
|
|
||||||
Copyright (c) 2020-2023 Kayne Ruse, KR Game Studios
|
Copyright (c) 2020-2024 Kayne Ruse, KR Game Studios
|
||||||
|
|
||||||
This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.
|
This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software.
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
<image src="toylogo.png" />
|
<image src="toylogo.png" />
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
# Toy
|
# Toy v1
|
||||||
|
|
||||||
The Toy programming language is an imperative bytecode-intermediate embedded scripting language. It isn't intended to operate on its own, but rather as part of another program, the "host". This process is intended to allow a decent amount of easy customisation by the host's end user, by exposing logic in script files. Alternatively, binary files in a custom format can be used as well.
|
The Toy programming language is an imperative bytecode-intermediate embedded scripting language. It isn't intended to operate on its own, but rather as part of another program, the "host". This process is intended to allow a decent amount of easy customisation by the host's end user, by exposing logic in script files. Alternatively, binary files in a custom format can be used as well.
|
||||||
|
|
||||||
@@ -83,4 +83,4 @@ Unnamed Individuals - Feedback
|
|||||||
|
|
||||||
* Seth A. Robinson
|
* Seth A. Robinson
|
||||||
|
|
||||||
Special thanks to http://craftinginterpreters.com/ for their fantastic book that set me on this path.
|
Special thanks to http://craftinginterpreters.com/ for their fantastic book that set me on this path.
|
||||||
|
|||||||
+3
-3
@@ -661,7 +661,7 @@ static int nativeConcat(Toy_Interpreter* interpreter, Toy_LiteralArray* argument
|
|||||||
}
|
}
|
||||||
|
|
||||||
//get the combined length for the new string
|
//get the combined length for the new string
|
||||||
size_t length = TOY_AS_STRING(selfLiteral)->length + TOY_AS_STRING(otherLiteral)->length + 1;
|
size_t length = TOY_AS_STRING(selfLiteral)->length + TOY_AS_STRING(otherLiteral)->length;
|
||||||
|
|
||||||
if (length > TOY_MAX_STRING_LENGTH) {
|
if (length > TOY_MAX_STRING_LENGTH) {
|
||||||
interpreter->errorOutput("Can't concatenate these strings, result is too long (error found in concat)\n");
|
interpreter->errorOutput("Can't concatenate these strings, result is too long (error found in concat)\n");
|
||||||
@@ -671,8 +671,8 @@ static int nativeConcat(Toy_Interpreter* interpreter, Toy_LiteralArray* argument
|
|||||||
}
|
}
|
||||||
|
|
||||||
//allocate the space and generate
|
//allocate the space and generate
|
||||||
char* buffer = TOY_ALLOCATE(char, length);
|
char* buffer = TOY_ALLOCATE(char, length + 1);
|
||||||
snprintf(buffer, length, "%s%s", Toy_toCString(TOY_AS_STRING(selfLiteral)), Toy_toCString(TOY_AS_STRING(otherLiteral)));
|
snprintf(buffer, length + 1, "%s%s", Toy_toCString(TOY_AS_STRING(selfLiteral)), Toy_toCString(TOY_AS_STRING(otherLiteral)));
|
||||||
|
|
||||||
Toy_Literal result = TOY_TO_STRING_LITERAL(Toy_createRefString(buffer));
|
Toy_Literal result = TOY_TO_STRING_LITERAL(Toy_createRefString(buffer));
|
||||||
|
|
||||||
|
|||||||
@@ -362,8 +362,8 @@ void Toy_emitASTNodeAnd(Toy_ASTNode** nodeHandle, Toy_ASTNode* rhs) {
|
|||||||
Toy_ASTNode* tmp = TOY_ALLOCATE(Toy_ASTNode, 1);
|
Toy_ASTNode* tmp = TOY_ALLOCATE(Toy_ASTNode, 1);
|
||||||
|
|
||||||
tmp->type = TOY_AST_NODE_AND;
|
tmp->type = TOY_AST_NODE_AND;
|
||||||
tmp->binary.left = *nodeHandle;
|
tmp->pathAnd.left = *nodeHandle;
|
||||||
tmp->binary.right = rhs;
|
tmp->pathAnd.right = rhs;
|
||||||
|
|
||||||
*nodeHandle = tmp;
|
*nodeHandle = tmp;
|
||||||
}
|
}
|
||||||
@@ -372,8 +372,8 @@ void Toy_emitASTNodeOr(Toy_ASTNode** nodeHandle, Toy_ASTNode* rhs) {
|
|||||||
Toy_ASTNode* tmp = TOY_ALLOCATE(Toy_ASTNode, 1);
|
Toy_ASTNode* tmp = TOY_ALLOCATE(Toy_ASTNode, 1);
|
||||||
|
|
||||||
tmp->type = TOY_AST_NODE_OR;
|
tmp->type = TOY_AST_NODE_OR;
|
||||||
tmp->binary.left = *nodeHandle;
|
tmp->pathOr.left = *nodeHandle;
|
||||||
tmp->binary.right = rhs;
|
tmp->pathOr.right = rhs;
|
||||||
|
|
||||||
*nodeHandle = tmp;
|
*nodeHandle = tmp;
|
||||||
}
|
}
|
||||||
|
|||||||
+1
-1
@@ -64,7 +64,7 @@ The current patch version of Toy. This value is embedded into the bytecode.
|
|||||||
This value MUST fit into an unsigned char.
|
This value MUST fit into an unsigned char.
|
||||||
!*/
|
!*/
|
||||||
|
|
||||||
#define TOY_VERSION_PATCH 1
|
#define TOY_VERSION_PATCH 2
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
### TOY_VERSION_BUILD
|
### TOY_VERSION_BUILD
|
||||||
|
|||||||
@@ -455,8 +455,8 @@ static void printToBuffer(const char* str) {
|
|||||||
globalPrintBuffer = TOY_GROW_ARRAY(char, globalPrintBuffer, oldCapacity, globalPrintCapacity);
|
globalPrintBuffer = TOY_GROW_ARRAY(char, globalPrintBuffer, oldCapacity, globalPrintCapacity);
|
||||||
}
|
}
|
||||||
|
|
||||||
snprintf(globalPrintBuffer + globalPrintCount, strlen(str) + 1, "%s", str ? str : "\0");
|
size_t total = snprintf(globalPrintBuffer + globalPrintCount, strlen(str) + 1, "%s", str ? str : "\0");
|
||||||
globalPrintCount += strlen(str);
|
globalPrintCount += total;
|
||||||
}
|
}
|
||||||
|
|
||||||
//exposed functions
|
//exposed functions
|
||||||
|
|||||||
+1
-1
@@ -22,7 +22,7 @@ void* Toy_private_defaultMemoryAllocator(void* pointer, size_t oldSize, size_t n
|
|||||||
void* mem = realloc(pointer, newSize);
|
void* mem = realloc(pointer, newSize);
|
||||||
|
|
||||||
if (mem == NULL) {
|
if (mem == NULL) {
|
||||||
fprintf(stderr, TOY_CC_ERROR "[internal] Memory allocation error (requested %zu, replacing %zu)\n" TOY_CC_RESET, newSize, oldSize);
|
fprintf(stderr, TOY_CC_ERROR "[internal] Memory allocation error (requested %d, replacing %d)\n" TOY_CC_RESET, (int)newSize, (int)oldSize);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -906,7 +906,8 @@ void disassemble(const char *filename, options_t config) {
|
|||||||
|
|
||||||
if (!strcmp(litf->fun, "MAIN")) {
|
if (!strcmp(litf->fun, "MAIN")) {
|
||||||
printf("MAIN:\n");
|
printf("MAIN:\n");
|
||||||
printf("%s", litf->str);
|
printf("%s", str_replace_substr_all(litf->str, ".lit FUNCTION ", ".lit FUNCTION (code=FUN_) "));
|
||||||
|
|
||||||
dis_disassemble_section(&prg, prg->pc, prg->len, 0, false, config);
|
dis_disassemble_section(&prg, prg->pc, prg->len, 0, false, config);
|
||||||
free(litf->fun);
|
free(litf->fun);
|
||||||
free(litf->str);
|
free(litf->str);
|
||||||
@@ -915,8 +916,10 @@ void disassemble(const char *filename, options_t config) {
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("FUNCTION_%s:\n", litf->fun);
|
printf("FUN_%s:\n", litf->fun);
|
||||||
printf("%s", litf->str);
|
char sbtr[strlen(litf->fun) + 19];
|
||||||
|
sprintf(sbtr, ".lit FUNCTION (code=FUN_%s_) ", litf->fun);
|
||||||
|
printf("%s", str_replace_substr_all(litf->str, ".lit FUNCTION ", sbtr));
|
||||||
|
|
||||||
queue_node_t *fqf = function_queue_front;
|
queue_node_t *fqf = function_queue_front;
|
||||||
while (fqf != NULL) {
|
while (fqf != NULL) {
|
||||||
|
|||||||
@@ -58,3 +58,35 @@ void str_append(char **str, const char *app) {
|
|||||||
*str = realloc(*str, (strlen(*str) + strlen(app) + 1) * sizeof(char));
|
*str = realloc(*str, (strlen(*str) + strlen(app) + 1) * sizeof(char));
|
||||||
memcpy((*str) + strlen(*str), app, strlen(app) + 1);
|
memcpy((*str) + strlen(*str), app, strlen(app) + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
char* str_replace_substr_all(char *mainstr, char *substr, char *newstr) {
|
||||||
|
int lenmain, lensub, i, j, lennew, startindex = -1, c;
|
||||||
|
lenmain = strlen(mainstr);
|
||||||
|
lensub = strlen(substr);
|
||||||
|
lennew = strlen(newstr);
|
||||||
|
char *result = (char*) malloc(sizeof(char) * (lenmain + 200));
|
||||||
|
for (c = 0, i = 0; i < lenmain; i++) {
|
||||||
|
if (lenmain - i >= lensub && *(mainstr + i) == *(substr)) {
|
||||||
|
startindex = i;
|
||||||
|
for (j = 1; j < lensub; j++)
|
||||||
|
if (*(mainstr + i + j) != *(substr + j)) {
|
||||||
|
startindex = -1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
if (startindex != -1) {
|
||||||
|
for (j = 0; j < lennew; j++, c++) {
|
||||||
|
*(result + c) = *(newstr + j);
|
||||||
|
}
|
||||||
|
i = i + lensub - 1;
|
||||||
|
} else {
|
||||||
|
*(result + c) = *(mainstr + i);
|
||||||
|
c++;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
*(result + c) = *(mainstr + i);
|
||||||
|
c++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
*(result + c) = '\0';
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|||||||
@@ -21,5 +21,6 @@ void dis_enqueue(void *x, queue_node_t **queue_front, queue_node_t **queue_rear,
|
|||||||
void dis_dequeue(queue_node_t **queue_front, queue_node_t **queue_rear, uint32_t *len);
|
void dis_dequeue(queue_node_t **queue_front, queue_node_t **queue_rear, uint32_t *len);
|
||||||
|
|
||||||
void str_append(char **str, const char *app);
|
void str_append(char **str, const char *app);
|
||||||
|
char* str_replace_substr_all(char *mainstr, char *substr, char *newstr);
|
||||||
|
|
||||||
#endif /* UTILS_H_ */
|
#endif /* UTILS_H_ */
|
||||||
|
|||||||
Reference in New Issue
Block a user