mirror of
https://github.com/krgamestudios/Toy.git
synced 2026-04-15 14:54:07 +10:00
Implemented and tested Toy_String, read more
Strings are needed for the handling of identifiers in the key/value variable storage, so I've got them working first. I used the rope pattern, which seems to be quite an interesting approach. I'll add comparison checks later. Adjusted how buckets are handled in all tests, could've been an issue down the line. Added the build instructions to README.md.
This commit is contained in:
@@ -57,12 +57,12 @@ int test_sizeof_ast_32bit() {
|
||||
return -err;
|
||||
}
|
||||
|
||||
int test_type_emission(Toy_Bucket* bucket) {
|
||||
int test_type_emission(Toy_Bucket** bucket) {
|
||||
//emit value
|
||||
{
|
||||
//emit to an AST
|
||||
Toy_Ast* ast = NULL;
|
||||
Toy_private_emitAstValue(&bucket, &ast, TOY_VALUE_TO_INTEGER(42));
|
||||
Toy_private_emitAstValue(bucket, &ast, TOY_VALUE_TO_INTEGER(42));
|
||||
|
||||
//check if it worked
|
||||
if (
|
||||
@@ -79,8 +79,8 @@ int test_type_emission(Toy_Bucket* bucket) {
|
||||
{
|
||||
//build the AST
|
||||
Toy_Ast* ast = NULL;
|
||||
Toy_private_emitAstValue(&bucket, &ast, TOY_VALUE_TO_INTEGER(42));
|
||||
Toy_private_emitAstUnary(&bucket, &ast, TOY_AST_FLAG_NEGATE);
|
||||
Toy_private_emitAstValue(bucket, &ast, TOY_VALUE_TO_INTEGER(42));
|
||||
Toy_private_emitAstUnary(bucket, &ast, TOY_AST_FLAG_NEGATE);
|
||||
|
||||
//check if it worked
|
||||
if (
|
||||
@@ -100,9 +100,9 @@ int test_type_emission(Toy_Bucket* bucket) {
|
||||
//build the AST
|
||||
Toy_Ast* ast = NULL;
|
||||
Toy_Ast* right = NULL;
|
||||
Toy_private_emitAstValue(&bucket, &ast, TOY_VALUE_TO_INTEGER(42));
|
||||
Toy_private_emitAstValue(&bucket, &right, TOY_VALUE_TO_INTEGER(69));
|
||||
Toy_private_emitAstBinary(&bucket, &ast, TOY_AST_FLAG_ADD, right);
|
||||
Toy_private_emitAstValue(bucket, &ast, TOY_VALUE_TO_INTEGER(42));
|
||||
Toy_private_emitAstValue(bucket, &right, TOY_VALUE_TO_INTEGER(69));
|
||||
Toy_private_emitAstBinary(bucket, &ast, TOY_AST_FLAG_ADD, right);
|
||||
|
||||
//check if it worked
|
||||
if (
|
||||
@@ -124,10 +124,10 @@ int test_type_emission(Toy_Bucket* bucket) {
|
||||
//build the AST
|
||||
Toy_Ast* ast = NULL;
|
||||
Toy_Ast* right = NULL;
|
||||
Toy_private_emitAstValue(&bucket, &ast, TOY_VALUE_TO_INTEGER(42));
|
||||
Toy_private_emitAstValue(&bucket, &right, TOY_VALUE_TO_INTEGER(69));
|
||||
Toy_private_emitAstBinary(&bucket, &ast, TOY_AST_FLAG_ADD, right);
|
||||
Toy_private_emitAstGroup(&bucket, &ast);
|
||||
Toy_private_emitAstValue(bucket, &ast, TOY_VALUE_TO_INTEGER(42));
|
||||
Toy_private_emitAstValue(bucket, &right, TOY_VALUE_TO_INTEGER(69));
|
||||
Toy_private_emitAstBinary(bucket, &ast, TOY_AST_FLAG_ADD, right);
|
||||
Toy_private_emitAstGroup(bucket, &ast);
|
||||
|
||||
//check if it worked
|
||||
if (
|
||||
@@ -150,19 +150,19 @@ int test_type_emission(Toy_Bucket* bucket) {
|
||||
{
|
||||
//initialize the root block
|
||||
Toy_Ast* block = NULL;
|
||||
Toy_private_initAstBlock(&bucket, &block);
|
||||
Toy_private_initAstBlock(bucket, &block);
|
||||
|
||||
//loop over the ast emissions, appending each one as you go
|
||||
for (int i = 0; i < 5; i++) {
|
||||
//build the AST
|
||||
Toy_Ast* ast = NULL;
|
||||
Toy_Ast* right = NULL;
|
||||
Toy_private_emitAstValue(&bucket, &ast, TOY_VALUE_TO_INTEGER(42));
|
||||
Toy_private_emitAstValue(&bucket, &right, TOY_VALUE_TO_INTEGER(69));
|
||||
Toy_private_emitAstBinary(&bucket, &ast, TOY_AST_FLAG_ADD, right);
|
||||
Toy_private_emitAstGroup(&bucket, &ast);
|
||||
Toy_private_emitAstValue(bucket, &ast, TOY_VALUE_TO_INTEGER(42));
|
||||
Toy_private_emitAstValue(bucket, &right, TOY_VALUE_TO_INTEGER(69));
|
||||
Toy_private_emitAstBinary(bucket, &ast, TOY_AST_FLAG_ADD, right);
|
||||
Toy_private_emitAstGroup(bucket, &ast);
|
||||
|
||||
Toy_private_appendAstBlock(&bucket, &block, ast);
|
||||
Toy_private_appendAstBlock(bucket, &block, ast);
|
||||
}
|
||||
|
||||
//check if it worked
|
||||
@@ -218,7 +218,7 @@ int main() {
|
||||
{
|
||||
Toy_Bucket* bucket = NULL;
|
||||
TOY_BUCKET_INIT(Toy_Ast, bucket, 32);
|
||||
res = test_type_emission(bucket);
|
||||
res = test_type_emission(&bucket);
|
||||
TOY_BUCKET_FREE(bucket);
|
||||
if (res == 0) {
|
||||
printf(TOY_CC_NOTICE "All good\n" TOY_CC_RESET);
|
||||
|
||||
Reference in New Issue
Block a user