forked from RustPython/RustPython
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.c
More file actions
79 lines (67 loc) · 1.5 KB
/
main.c
File metadata and controls
79 lines (67 loc) · 1.5 KB
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
#if defined(__MWERKS__) && defined(macintosh)
#include <MacMemory.h>
#define __bool_true_false_are_defined
typedef char bool;
#endif
#include <stdio.h>
#include "w2c2/w2c2_base.h"
#include "wasi/wasi.h"
#include "rustpython.h"
#ifdef __MSL__
#include <SIOUX.h>
#endif
void
trap(
Trap trap
) {
fprintf(stderr, "TRAP: %s\n", trapDescription(trap));
abort();
}
wasmMemory*
wasiMemory(
void* instance
) {
return rustpython_memory((rustpythonInstance*)instance);
}
#if defined(__MSL__) && defined(macintosh)
char** environ = NULL;
#else
extern char** environ;
#endif
/* Main */
int main(int argc, char* argv[]) {
#if defined(__MWERKS__) && defined(macintosh)
MaxApplZone();
MoreMasters();
MoreMasters();
#endif
/* Initialize WASI */
if (!wasiInit(argc, argv, environ)) {
fprintf(stderr, "failed to init WASI\n");
return 1;
}
#ifdef __MSDOS__
if (!wasiFileDescriptorAdd(-1, "C:\\", NULL)) {
fprintf(stderr, "failed to add preopen\n");
return 1;
}
#endif
if (!wasiFileDescriptorAdd(-2, ".", NULL)) {
fprintf(stderr, "failed to add preopen\n");
return 1;
}
if (!wasiFileDescriptorAdd(-3, "/", NULL)) {
fprintf(stderr, "failed to add preopen\n");
return 1;
}
#ifdef __MSL__
SIOUXSetTitle("\pRust");
#endif
{
rustpythonInstance instance;
rustpythonInstantiate(&instance, NULL);
rustpython__start(&instance);
rustpythonFreeInstance(&instance);
}
return 0;
}