pebblisp/src/env.h

52 lines
1.1 KiB
C
Raw Normal View History

#ifndef ENVIRONMENT_H
#define ENVIRONMENT_H
#include "object.h"
struct Environment;
struct Environment {
char** strings;
Object* objects;
struct Environment* outer;
int size;
int structCount;
int structCapacity;
struct StructDef* structDefs;
2022-03-19 22:25:20 -04:00
2022-03-14 23:46:20 -04:00
int refs;
const char* name;
};
struct Environment* global();
2022-03-19 22:25:20 -04:00
void setGlobal(struct Environment* env);
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);
void printEnv(struct Environment* env);
void addFunc(const char* name,
Object (* func)(Object*, int, struct Environment*),
struct Environment* env);
void deleteEnv(struct Environment* e);
struct Environment defaultEnv();
2022-03-17 16:59:08 -04:00
struct StructDef getStructDef(struct Environment* env, const char* name);
int getStructIndex(struct Environment* env, const char* name);
/// Needs to be freed!
char* getHelp(const char* symbol);
int runTests();
#endif