2020-05-10 13:51:33 -04:00
|
|
|
#ifndef ENVIRONMENT_H
|
|
|
|
#define ENVIRONMENT_H
|
|
|
|
|
|
|
|
#include "object.h"
|
|
|
|
|
|
|
|
struct Environment;
|
|
|
|
struct Environment {
|
2022-01-07 16:55:03 -05:00
|
|
|
char** strings;
|
|
|
|
Object* objects;
|
|
|
|
struct Environment* outer;
|
|
|
|
int size;
|
2022-03-14 16:51:45 -04:00
|
|
|
|
|
|
|
int structCount;
|
2022-03-15 15:26:01 -04:00
|
|
|
int structCapacity;
|
2022-03-14 16:51:45 -04:00
|
|
|
struct StructDef* structDefs;
|
2022-03-19 22:25:20 -04:00
|
|
|
|
2022-03-14 23:46:20 -04:00
|
|
|
int refs;
|
2022-03-21 12:33:35 -04:00
|
|
|
const char* name;
|
2020-05-10 13:51:33 -04:00
|
|
|
};
|
2022-03-15 21:43:53 -04:00
|
|
|
|
|
|
|
struct Environment* global();
|
2022-03-19 22:25:20 -04:00
|
|
|
|
|
|
|
void setGlobal(struct Environment* env);
|
2020-05-10 13:51:33 -04:00
|
|
|
|
2022-01-07 16:55:03 -05:00
|
|
|
Object fetchFromEnvironment(const char* name, struct Environment* env);
|
|
|
|
|
|
|
|
struct Environment envForLambda(const Object* params, const Object* arg_forms,
|
|
|
|
struct Environment* outer);
|
|
|
|
|
2022-03-19 22:25:20 -04:00
|
|
|
void addToEnv(struct Environment* env, const char* name, Object obj);
|
2022-01-07 16:55:03 -05:00
|
|
|
|
|
|
|
void printEnv(struct Environment* env);
|
|
|
|
|
|
|
|
void addFunc(const char* name,
|
2022-03-24 16:56:52 -04:00
|
|
|
Object (* func)(Object*, int, struct Environment*),
|
2022-01-07 16:55:03 -05:00
|
|
|
struct Environment* env);
|
|
|
|
|
|
|
|
void deleteEnv(struct Environment* e);
|
|
|
|
|
2020-05-10 13:51:33 -04:00
|
|
|
struct Environment defaultEnv();
|
|
|
|
|
2022-03-17 16:59:08 -04:00
|
|
|
struct StructDef getStructDef(struct Environment* env, const char* name);
|
|
|
|
|
2022-03-18 11:23:19 -04:00
|
|
|
int getStructIndex(struct Environment* env, const char* name);
|
|
|
|
|
2022-03-22 11:44:22 -04:00
|
|
|
/// Needs to be freed!
|
|
|
|
char* getHelp(const char* symbol);
|
2022-03-20 03:50:43 -04:00
|
|
|
|
2022-03-25 13:33:26 -04:00
|
|
|
void printColored(const char* code);
|
|
|
|
|
2022-03-21 12:33:35 -04:00
|
|
|
int runTests();
|
|
|
|
|
2020-05-10 13:51:33 -04:00
|
|
|
#endif
|