Move alang to c
This commit is contained in:
+50
-1
@@ -1,7 +1,56 @@
|
||||
|
||||
#include "iron_gc.h"
|
||||
|
||||
#ifdef NO_GC
|
||||
#ifdef NO_GC_USE_HEAP
|
||||
|
||||
#include <memory.h>
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
|
||||
#define HEAP_SIZE 512 * 1024 * 1024
|
||||
static uint8_t *heap = NULL;
|
||||
static size_t heap_top = 0;
|
||||
|
||||
void *gc_alloc(size_t size) {
|
||||
size_t old_top = heap_top;
|
||||
heap_top += size;
|
||||
if (heap_top >= HEAP_SIZE) {
|
||||
printf("gc_alloc: out of memory\n");
|
||||
}
|
||||
return &heap[old_top];
|
||||
}
|
||||
|
||||
void gc_array(void *ptr, uint32_t *length) {}
|
||||
void gc_leaf(void *ptr) {}
|
||||
void gc_root(void *ptr) {}
|
||||
void gc_unroot(void *ptr) {}
|
||||
|
||||
void *gc_cut(void *ptr, size_t pos, size_t size) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void *gc_realloc(void *ptr, size_t size) {
|
||||
void *new_ptr = gc_alloc(size);
|
||||
if (ptr != NULL) {
|
||||
memcpy(new_ptr, ptr, size);
|
||||
}
|
||||
return new_ptr;
|
||||
}
|
||||
|
||||
void gc_free(void *ptr) {}
|
||||
void gc_pause() {}
|
||||
void gc_resume() {}
|
||||
void gc_run() {}
|
||||
|
||||
void gc_start(void *bos) {
|
||||
heap = (uint8_t *)calloc(HEAP_SIZE, 1);
|
||||
}
|
||||
|
||||
void gc_stop() {}
|
||||
|
||||
#elif defined(NO_GC)
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
+1585
-3785
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@@ -3,11 +3,10 @@ let project = new Project("amake");
|
||||
|
||||
// alang
|
||||
project.add_define("NO_GC");
|
||||
project.add_define("NO_GC_USE_HEAP");
|
||||
project.add_define("NO_IRON_API");
|
||||
project.add_define("NO_IRON_START");
|
||||
project.add_tsfiles("./"); // alang.ts
|
||||
project.add_include_dir("./"); // iron.h
|
||||
project.add_cfiles("build/iron.c");
|
||||
project.add_cfiles("alang.c");
|
||||
project.add_include_dir("../../sources");
|
||||
project.add_cfiles("../../sources/iron_string.c");
|
||||
project.add_cfiles("../../sources/iron_array.c");
|
||||
|
||||
@@ -3,5 +3,5 @@
|
||||
Iron build tool.
|
||||
|
||||
```bash
|
||||
../../make --compile --alangjs
|
||||
../../make --compile
|
||||
```
|
||||
|
||||
@@ -2750,24 +2750,11 @@ function write_ts_project(projectdir, options) {
|
||||
source += file;
|
||||
}
|
||||
|
||||
if (goptions.alangjs) {
|
||||
globalThis.std = std;
|
||||
globalThis.fs_readfile = fs_readfile;
|
||||
globalThis.fs_writefile = fs_writefile;
|
||||
globalThis.flags.alang_source = source;
|
||||
globalThis.flags.alang_output = os_cwd() + path_sep + "build" + path_sep + "iron.c";
|
||||
let alang = irondir + '/tools/amake/alang.js';
|
||||
(1, eval)(fs_readfile(alang));
|
||||
}
|
||||
else {
|
||||
// let alang_input = os_cwd() + path_sep + "build" + path_sep + "iron.ts";
|
||||
// fs_writefile(alang_input, source);
|
||||
let alang_output = os_cwd() + path_sep + "build" + path_sep + "iron.c";
|
||||
let start = Date.now();
|
||||
amake.alang(source, alang_output);
|
||||
console.log("alang took " + (Date.now() - start) + "ms.");
|
||||
}
|
||||
}
|
||||
|
||||
function export_project_files(name, options, exporter, defines) {
|
||||
let ts_options = exporter.ts_options(defines);
|
||||
@@ -3316,7 +3303,6 @@ let goptions = {
|
||||
ccompiler : 'clang',
|
||||
cppcompiler : 'clang++',
|
||||
arch : 'default',
|
||||
alangjs : false,
|
||||
js : false,
|
||||
ashader : false,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user