cgen: add `builtin.init` call inside of `_vinit`
parent
50b9faf347
commit
6c4de001b8
|
@ -6,15 +6,6 @@ module builtin
|
||||||
__global g_m2_buf byteptr
|
__global g_m2_buf byteptr
|
||||||
__global g_m2_ptr byteptr
|
__global g_m2_ptr byteptr
|
||||||
|
|
||||||
fn init() {
|
|
||||||
$if windows {
|
|
||||||
if is_atty(1) > 0 {
|
|
||||||
C.SetConsoleMode(C.GetStdHandle(C.STD_OUTPUT_HANDLE), C.ENABLE_PROCESSED_OUTPUT | 0x0004) // ENABLE_VIRTUAL_TERMINAL_PROCESSING
|
|
||||||
C.setbuf(C.stdout, 0)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn exit(code int) {
|
pub fn exit(code int) {
|
||||||
C.exit(code)
|
C.exit(code)
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,6 +21,10 @@ const (
|
||||||
fn C.puts(charptr)
|
fn C.puts(charptr)
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
fn init() {
|
||||||
|
// Do nothing
|
||||||
|
}
|
||||||
|
|
||||||
pub fn println(s string) {
|
pub fn println(s string) {
|
||||||
// TODO: a syscall sys_write on linux works, except for the v repl.
|
// TODO: a syscall sys_write on linux works, except for the v repl.
|
||||||
// Probably it is a stdio buffering issue. Needs more testing...
|
// Probably it is a stdio buffering issue. Needs more testing...
|
||||||
|
|
|
@ -58,6 +58,13 @@ const (
|
||||||
SYMOPT_DEBUG = 0x80000000
|
SYMOPT_DEBUG = 0x80000000
|
||||||
)
|
)
|
||||||
|
|
||||||
|
fn init() {
|
||||||
|
if is_atty(1) > 0 {
|
||||||
|
C.SetConsoleMode(C.GetStdHandle(C.STD_OUTPUT_HANDLE), C.ENABLE_PROCESSED_OUTPUT | 0x0004) // ENABLE_VIRTUAL_TERMINAL_PROCESSING
|
||||||
|
C.setbuf(C.stdout, 0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
fn print_backtrace_skipping_top_frames_msvc(skipframes int) bool {
|
fn print_backtrace_skipping_top_frames_msvc(skipframes int) bool {
|
||||||
|
|
||||||
$if msvc {
|
$if msvc {
|
||||||
|
|
|
@ -2024,6 +2024,7 @@ fn verror(s string) {
|
||||||
|
|
||||||
fn (g mut Gen) write_init_function() {
|
fn (g mut Gen) write_init_function() {
|
||||||
g.writeln('void _vinit() {')
|
g.writeln('void _vinit() {')
|
||||||
|
g.writeln('init(); // builtin.init')
|
||||||
g.writeln(g.inits.str())
|
g.writeln(g.inits.str())
|
||||||
g.writeln('}')
|
g.writeln('}')
|
||||||
if g.autofree {
|
if g.autofree {
|
||||||
|
|
Loading…
Reference in New Issue