-
Notifications
You must be signed in to change notification settings - Fork 23
/
Copy pathboot.as
94 lines (73 loc) · 2.71 KB
/
boot.as
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
/* -*- c-basic-offset: 4; indent-tabs-mode: nil; tab-width: 4 -*- */
/* vi: set ts=4 sw=4 expandtab: (add to ~/.vimrc: set modeline modelines=5) */
/* 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/. */
package shell
{
import C.errno.*;
import C.stdlib.*;
//import shell.async.CoreEventLoop;
/* IMPORTANT:
this is the redtamarin boot system,
it's where we configure the shell main entry point.
some of those access are protected under the AVM2 namespace
*/
use namespace AVM2;
/* 0. in the futur
we will make this boot system in such way
that users can override its logic from a text file
but before doing that we need a profile class
and a config class
*/
/* 1. we reset errno to zero
By default, something somewhere in tamarin define errno=2
eg. "No such file or directory"
for our API we want errno set as 0 (zero) from the start of the application
forcing errno=0 here allow to do this
*/
errno.value = 0;
/* 2. we setup the onExit() function
this function basically loop trough the _exitcall array
and call each one of the functions it may contain
then this function is defined as the "exit listener"
and when the redshell is about to terminate normally
it call this function (only if this function exists)
just before the actual exiting
if the program terminates abnormally
the "exit listener" is not called
Causes the specified function to be called when the program terminates normally.
At least 32 functions can be registered to be called when the program terminates.
They are called in a last-in, first-out basis (the last function registered is called first).
*/
Program.onExit = function()
{
var f:Function;
while( Program._exitcall.length > 0 )
{
f = Program._exitcall.pop();
f();
}
Program.setExitListener( null );
}
/* 2a. the onExit function is defined as the "exit listener"
*/
Program.setExitListener( Program.onExit );
/* 3. we setup the goAsync() function
this function only check if the loop is not null
and then start the loop
*/
Runtime.goAsync = function()
{
trace( "Runtime.goAsync()" );
if( Runtime.loop )
{
trace( "starts loop" );
Runtime.loop.start();
}
}
/* 4. we run the program selfCheck() function
no we don't
*/
//Program.selfCheck();
}