langatator/sandbox.c

93 lines
2.4 KiB
C
Raw Normal View History

#include <stdio.h>
#include "./src/types.h"
#include "./src/list.h"
#include "./src/number_parsing.h"
#include "./src/funcs.h"
#include "./src/utils.h"
#include "./src/var_store.h"
#include "./src/line_processing.h"
#include "./src/state.h"
#include <stdlib.h>
int main () {
// struct List l1;
// short val = 17;
// list_set(&l1, 0, TYPE_VAR_NAME, &val);
// list_print(&l1);
// return 0;
// int yes = 1234;
// int dst = 0;
// memcpy(&dst, &yes, 4);
// printf("yes: %d \n", dst);
struct VariableStore* store = var_store_init();
// int hashRes = var_store_hash_name(store, "HelloWorld++");
// printf("hashRes: %d \n", hashRes);
int val = 1234;
var_store_set(store, "foo", TYPE_INT, &val);
//printf("Pos of var: %d \n", var_store_get_pos(store, "foo"));
//byte type = var_store_get_type(store, "foo");
//printf("Type of var: %d \n", type);
//int key = var_store_get_pos(store, "foo");
//printf("size of type %d \n", get_size_of_type(store->container[key].type));
//printf("%d \n", *((int*) store->container[key].dataPtr));
int val2 = 0;
var_store_copy(store, "foo", &val2);
printf("Value of var: %d \n", val2);
printf("==== \n");
printf("==== \n");
struct StateContainer* state = state_init();
process_line(state, "# some random comment");
process_line(state, "set VAR_A to 8.5");
process_line(state, "set VAR_B to 1.5");
process_line(state, "set VAR_C to VAR_A+VAR_B");
process_line(state, "print_number(sqrt(VAR_C))");
// struct List l1;
// list_append_int(&l1, 4);
// list_append_char(&l1, '*');
// list_append_int(&l1, 5);
// list_print(&l1);
// list_delete(&l1, 0);
// list_print(&l1);
// list_delete(&l1, 0);
// list_print(&l1);
// float res = 0;
// void* ptr = &res;
// printf("%d\n", sizeof(ptr));
// int found = identify_func_name("ABS");
// printf("found: %d \n", found);
// unsigned char argsType[1] = { TYPE_FLOAT };
// int argsVals[1] = { get_int_rep_from_float(-3.145) };
// int resVal = 0;
// unsigned char resType = 0;
// execute_func(found, 1, argsType, argsVals, &resVal, &resType);
// printf("func res type: %d \n", resType);
// printf("func res: %f \n", get_float_from_int_rep(resVal));
// int stat = parse_float("1052.254", &res);
// printf("float parsing stat: %d \n", stat);
// printf("final float: %f \n", res);
}