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;
|
2022-03-27 18:52:56 -04:00
|
|
|
int capacity;
|
2022-03-14 16:51:45 -04:00
|
|
|
|
2022-03-27 18:52:56 -04:00
|
|
|
int refs;
|
|
|
|
};
|
|
|
|
|
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);
|
|
|
|
|
2022-03-28 23:51:05 -04:00
|
|
|
struct Environment envForLambda(const Object* params, const Object* arg_forms, int paramCount,
|
2022-01-07 16:55:03 -05:00
|
|
|
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
|
|
|
|
2022-03-31 13:23:15 -04:00
|
|
|
void printEnv(struct Environment* env, int printPointers);
|
2022-01-07 16:55:03 -05:00
|
|
|
|
|
|
|
void addFunc(const char* name,
|
2022-03-24 16:56:52 -04:00
|
|
|
Object (* func)(Object*, int, struct Environment*),
|
2022-03-27 00:03:34 -04:00
|
|
|
struct Environment* env,
|
|
|
|
int i);
|
2022-01-07 16:55:03 -05:00
|
|
|
|
|
|
|
void deleteEnv(struct Environment* e);
|
|
|
|
|
2022-03-27 18:52:56 -04:00
|
|
|
void shredDictionary();
|
|
|
|
|
2020-05-10 13:51:33 -04:00
|
|
|
struct Environment defaultEnv();
|
|
|
|
|
2022-04-03 19:17:02 -04:00
|
|
|
struct Environment defaultEnvPreAllocated(char** strings, Object* objects);
|
|
|
|
|
2022-03-27 18:52:56 -04:00
|
|
|
int getStructIndex(const char* name);
|
|
|
|
|
|
|
|
struct StructDef* getStructAt(int i);
|
|
|
|
|
|
|
|
void addStructDef(struct StructDef def);
|
2022-03-18 11:23:19 -04:00
|
|
|
|
2022-03-25 13:33:26 -04:00
|
|
|
void printColored(const char* code);
|
|
|
|
|
2022-03-25 16:11:20 -04:00
|
|
|
int runTests(int detailed);
|
2022-03-21 12:33:35 -04:00
|
|
|
|
2020-05-10 13:51:33 -04:00
|
|
|
#endif
|