-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathloader.h
42 lines (35 loc) · 1.16 KB
/
loader.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
#pragma once
#include "codegen.h"
#include "gc.h"
#include "parser.h"
struct Loader {
GcObject obj;
// All error handling is done internally.
// The function just returns a NULL to
// denote a (un)successful load.
CodeGenerator generator;
Parser parser;
// in case we're compiling for the repl, we need
// to keep track of its variables too
Value replModule;
bool isCompiling;
static Loader *create();
GcObject *compile_and_load(const String2 &fileName, bool execute = false);
GcObject *compile_and_load(const void *fileName, bool execute = false);
GcObject *compile_and_load_with_name(const void *fileName,
String * moduleName,
bool execute = false);
// Compile and load in an already loaded module
// takes the module, and modifies it
Value compile_and_load_from_source(const void * source,
ClassCompilationContext *m, Value mod,
bool execute = false);
void mark() {
if(isCompiling) {
generator.mark();
parser.mark();
}
if(!replModule.isNil())
Gc::mark(replModule);
}
};