-
Notifications
You must be signed in to change notification settings - Fork 10
/
Crack.h
executable file
·125 lines (96 loc) · 3.47 KB
/
Crack.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
// Copyright 2010-2011 Shannon Weyrick <weyrick@mozek.us>
// Copyright 2010-2012 Google Inc.
//
// This Source Code Form is subject to the terms of the Mozilla Public
// License, v. 2.0. If a copy of the MPL was not distributed with this
// file, You can obtain one at http://mozilla.org/MPL/2.0/.
//
#ifndef _Crack_h_
#define _Crack_h_
#include <vector>
#include <spug/RCPtr.h>
#include "builder/BuilderOptions.h"
#include "model/Options.h"
namespace model {
SPUG_RCPTR(Construct);
SPUG_RCPTR(Context);
SPUG_RCPTR(ModuleDef);
}
namespace builder {
SPUG_RCPTR(Builder);
}
/**
* High-level wrapper around the crack executor. Use this whenever possible
* for embedding.
*/
class Crack : public model::Options {
private:
// the primary construct.
model::ConstructPtr construct;
// keeps init() from doing its setup stuff twice.
bool initialized;
public:
// builder specific options
builder::BuilderOptionsPtr options;
// if true, don not load the bootstrapping modules before running a
// script. This changes some of the language semantics: constant
// strings become byteptr's and classes without explicit ancestors
// will not be derived from object.
bool noBootstrap;
// if true, add the global installed libary path to the library search
// path prior to running anything.
bool useGlobalLibs;
// if true, emit warnings when the code has elements with semantic
// differences from the last version of the language.
bool emitMigrationWarnings;
Crack(void);
// ~Crack();
public:
bool init();
/**
* Adds the given path to the source library path - 'path' is a
* colon separated list of directories.
*/
void addToSourceLibPath(const std::string &path);
/**
* Returns the source library path.
*/
const std::vector<std::string> &getSourceLibPath() const;
/**
* Set the program's arg list (this should be done prior to calling
* runScript()).
*/
void setArgv(int argc, char **argv);
/**
* set the main builder for compiling runtime code
*/
void setBuilder(builder::Builder *builder);
/**
* Set the builder to be used by the compiler for annotation modules.
*/
void setCompileTimeBuilder(builder::Builder *builder);
/**
* Run the specified script. Catches all parse exceptions, returns
* an exit code, which will be non-zero if a parse error occurred and
* should eventually be settable by the application.
*
* @param src the script's source stream.
* @param name the script's name (for use in error reporting and
* script module creation).
* @param notAFile Set to true if the input is not a file and
* therefore should not be cached (added for scripts read from
* standard input).
*/
int runScript(std::istream &src, const std::string &name, bool notAFile);
/**
* Call the module destructors for all loaded modules in the reverse
* order that they were loaded. This should be done before
* terminating.
*/
void callModuleDestructors();
/**
* print compile time stats to the given stream
*/
void printStats(std::ostream &out);
};
#endif