-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Josep M. Bach
committed
Dec 20, 2012
1 parent
d5aada7
commit 15e9f25
Showing
12 changed files
with
94 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
#include <forkix/bootstrap.h> | ||
#include <forkix/darray.h> | ||
#include <forkix/bstrlib.h> | ||
#include <forkix/input_reader.h> | ||
#include <dirent.h> | ||
|
||
static inline DArray* | ||
kernel_files() | ||
{ | ||
DArray *entries = DArray_create(sizeof(bstring), 10); | ||
|
||
DIR *dirp = opendir("kernel"); // todo -- make it an absolute path | ||
struct dirent *dp; | ||
readdir(dirp); // . | ||
readdir(dirp); // .. | ||
|
||
while ((dp = readdir(dirp)) != NULL) { | ||
DArray_push(entries, bfromcstr(dp->d_name)); | ||
} | ||
(void)closedir(dirp); | ||
|
||
return entries; | ||
} | ||
|
||
void | ||
State_bootstrap(STATE state) | ||
{ | ||
DArray *filenames = kernel_files(); | ||
int count = DArray_count(filenames); | ||
|
||
Hashmap *fns = state->functions; | ||
|
||
for(int i=0; i < count; i++) { | ||
bstring filename = (bstring)DArray_at(filenames, i); | ||
debug("[BOOTSTRAP] Loading %s...", bdata(filename)); | ||
|
||
BytecodeFile *file = BytecodeFile_new(filename); | ||
int fn_count = DArray_count(file->function_names); | ||
for(int j=0; i < fn_count; i++) { | ||
bstring fn_name = (bstring)DArray_at(file->function_names, j); | ||
Function *fn = (Function*)Hashmap_get(file->functions, fn_name); | ||
Hashmap_set(fns, fn_name, fn); | ||
} | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#ifndef _fx_bootstrap_h_ | ||
#define _fx_bootstrap_h_ | ||
|
||
#include <forkix/state.h> | ||
|
||
void State_bootstrap(STATE state); | ||
|
||
#endif | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
#ifndef _fx_opcode_h_ | ||
#define _fx_opcode_h_ | ||
|
||
typedef enum { | ||
NOOP = 0, | ||
|
||
PUSHSELF = 0x10, // 16 | ||
PUSHINT, // 17 | ||
|
||
PUSHLOCAL = 0x20, // 32 | ||
|
||
ADD, // 33 | ||
|
||
POP, | ||
|
||
SEND = 0x80, // 128 | ||
RET = 0x90, // 144 | ||
|
||
DUMP, // 145 | ||
} OpCode; | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters