GithubHelp home page GithubHelp logo

mrsmith33 / vox Goto Github PK

View Code? Open in Web Editor NEW
325.0 325.0 18.0 2.91 MB

Vox language compiler. AOT / JIT / Linker. Zero dependencies

License: Boost Software License 1.0

D 100.00%
amd64 aot codegen compiler d dlang jit language linker pe-format programming-language ssa-form vox voxlang x86-64

vox's People

Contributors

drkameleon avatar jedekar avatar m4gnv5 avatar mrsmith33 avatar nordlow avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

vox's Issues

ICE: getAst(AliasArrayDeclNode) got type_slice

Expected behavior
Was this supposed to work or is it not implemented yet?

Describe the bug
The following error appears:

vox.context:574: ICE: getAst(AliasArrayDeclNode) got type_slice
Stack:
> test.vox:12:6: node.879 name_register_nested type_func_sig void function(data)
  test.vox:12:6: node.850 name_register_nested decl_function printa
  test.vox:1:1: node.485 name_register_nested decl_module test
[email protected](574)
----------------
??:? [0x55bc79b2149c]
??:? [0x55bc79b02f6d]
??:? [0x55bc799511bd]
??:? [0x55bc79950d69]
??:? [0x55bc79a10c3b]
??:? [0x55bc79a0f289]
??:? [0x55bc79a0f59a]
??:? [0x55bc79a2b406]
??:? [0x55bc79ad528f]
??:? [0x55bc79adc508]
??:? [0x55bc79b02bfe]
??:? [0x55bc79b02a80]
??:? [0x55bc79b028dd]
??:? [0x7f4e473d230f]
??:? __libc_start_main [0x7f4e473d23c0]
??:? [0x55bc79a4ee2d]

To Reproduce
Trying to compile the following function (the body doesn't matter):

void printa(u8[]... data) {
  sys_write(1, data[1].ptr, data[1].length);
  sys_write(1, data[2].ptr, data[2].length);
  sys_write(1, data[3].ptr, data[3].length);
}

Additional context

Importing file with extern attributes causes "External function cannot have a body" error

I may be misunderstanding how @extern can be used, but the following program results in an error.

// main.vox
#version(windows) {
    import win;
}

void main() {
    #version(windows) ExitProcess(0);
}
// win.vox
@extern(module, "kernel32")
void ExitProcess(u32 uExitCode);

@extern(module, "kernel32")
void* GetStdHandle(u32 nStdHandle);

// ...

Command: vox main.vox win.vox [location of kernel32.dll]

Output:

win.vox:1:1: Error: External function cannot have a body

Copying and pasting the contents of win.vox into main.vox fixes this.

I'm getting the "illegal hardware instruction" error when I execute the "vox" executable

Expected behavior
To not get this error.

Describe the bug
When I run Vox, I'm getting the error in the title.

To Reproduce
Just trying to execute the "vox" executable results in an "illegal hardware instruction" error to be printed. I also tried to use the debug version of the built-in CI builds but it didn't showed anything more. It seems that the only thing that seems to output something more is when I run it with an unrecognized option. In that case, I also get the message that the option is unrecognized and then again, I get the "illegal hardware instruction" error.

Additional context

Wrong results in a function when using a template

I have the following code which converts and integral type to a string (u8*):

u8* itostr(i64 num) {
  if (num == 0) return "0";

  i32 digit_count = 0;

  if (num < 0) {
    num = -num;
    digit_count++;
  }

  if (num < 10) digit_count += 1;
  else if (num < 100) digit_count += 2;
  else if (num < 1000) digit_count += 3;
  else if (num < 10000) digit_count += 4;
  else if (num < 100000) digit_count += 5;
  else if (num < 1000000) digit_count += 6;
  else if (num < 10000000) digit_count += 7;
  else if (num < 100000000) digit_count += 8;
  else if (num < 1000000000) digit_count += 9;
  else digit_count += 10;

  u8* str = cast(u8*)sys_mmap(null, cast(u64)digit_count, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
  if (str == null) return "E";

  while (num > 0) {
    --digit_count;
    str[digit_count] = cast(u8)(num % 10 + '0');
    num /= 10;
  }

  if (digit_count == 1) str[0] = '-';
  return str;
}

The result is the expected result but when I use a template the result is not what I was expecting. It actually has a weird behavior where some numbers will get converted normally but some others will return "00" as the result. The full code for the template and the main function is the following: NOTE: Keep in mind that I suppose that you have "write, sys_write, exit, and mmap" from a previous issue, if not, tell me to give them to you.

// SUPOSE THE "itostr" function exists here

u8* to_str[T](T num) {
  #if (T == u8 || T == i8 || T == u16 || T == i16 || T == u32 || T == i32 || T == u64 || T == i64) {
    if (num == 0) return "0";

    i32 digit_count = 0;

  #if (T == i8 || T == i16 || T == i32 || T == i64) { // Unsigned numbers cannot be negative
    if (num < 0) {
      num = -num;
      digit_count++;
    }
  }
    if (num < 10) digit_count += 1;
    else if (num < 100) digit_count += 2;
    else if (num < 1000) digit_count += 3;
    else if (num < 10000) digit_count += 4;
    else if (num < 100000) digit_count += 5;
    else if (num < 1000000) digit_count += 6;
    else if (num < 10000000) digit_count += 7;
    else if (num < 100000000) digit_count += 8;
    else if (num < 1000000000) digit_count += 9;
    else digit_count += 10;

    u8* str = cast(u8*)sys_mmap(null, cast(u64)digit_count, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, 0, 0);
    if (str == null) return "E";

    while (num > 0) {
      --digit_count;
      str[digit_count] = cast(u8)(num % 10 + '0');
      num /= 10;
    }

    if (digit_count == 1) str[0] = '-';
    return str;
  }

  // TODO: Implement that
  #if (T == f32 || T == f64) {}
}

void main() {
  u8* num;
  num = itostr(32); // Return "32" as expected
  sys_write(1, num, strlen(num));
  write("\n\n"); // Ask this function if you don't have it

  num = to_str(32); // Returns "00"
  sys_write(1, num, strlen(num));
  write("\n\n"); // Ask this function if you don't have it

  num = itostr(-10); // Return "-10" as expected
  sys_write(1, num, strlen(num));
  write("\n\n"); // Ask this function if you don't have it

  num = to_str(-10); // This is right for some reason tho
  sys_write(1, num, strlen(num));
  write("\n"); // Ask this function if you don't have it

  exit(0);
}

A couple of questions and suggestions

First of all I would like to say that so far, Vox look so promising!!!! Your design choices are on point. A d-like language without a GC, a bloated runtime with even faster compilation times? I must be dreaming! First of all I would like to ask some questions and then proceed on giving some suggestions. Of course you should read this with caution cause maybe some of them may not be good ideas. So first of all I would like to give a little bit of background about me. You can of course skip it but you may be interested and it will help you understand with I'm so Hyped with Vox. Also keep in mind that I disited to write that here rather than getting in contact in private because there will be suggestions here (I hope you would consider some of them, lol) so it will be fine to stay here and also have other people saying their opinion.

My background
I started coding in about early 2020 (I kinda had some experience with Python but I don't count that). I feel really bad for saying that, but I don't think that I have made anything significant thorough this time. Which is really disappointing if you think that we are talking about a span of 1.5 years. Well I learnt TONS of stuff but didn't do a lot in practice. Were I wasted my time? Easy! 85-90% I was searching for my ideal programming language. I've come across tons of different languages but explain each one and saying why I didn't finally used them, would literally take paragraphs and paragraphs... From what you understand, I don't like the "Choose the right language for the right job" phrase. I want to learn only 1 language that will be able to do anything (even if it's not better in everything) and be a professional about it. Anyway let's see my ideal language.

My ideal language
I will go straight to the point. My ideal language compiles fast! Really fast!!! It should be able to have compilation times close to C (or even better). The performance should also be important. It should be at worse 2-3 times slower than C (again at worse). The syntax should not be bloated (not unnecessary and hard to read code) but still clear and not Python-like. And finally It should not limit me in anything or in general make my life harder (Yes Rust I'm talking about you).

Vox has the potential to be this language
Vox is not there yet (not in everything at leas) but it has an amazing potential. If we see that we have common goals, I would like to help and make the new TRUE replacement of C (C++ and D failed to do that)

Questions

  1. How does Vox compiles so fast (faster than GCC, Clang) and still produces code that is 80-100% slower than optimized (-Os) gcc? Well tbh I don't know if that's the case, I just tried one example with fib numbers. Also only 35k loc? Man wtf!!!
  2. Does Vox has an optimization flag or it does it out of the box (like Go)? You say that one of the goals is: "Maximize application performance" so I suppose you care about optimization right?
  3. What's the current state o Vox? What has been implemented so far?
  4. Is the memory only manual managed?
  5. How the structs are implemented? Are they similar to C? Are they lighter and faster than C++/D classes/structs or?
  6. Are there any feature that Vox has (or is planned to have) that C++/D doesn't?

Suggestions
Before I type the suggestions out, I just want to be very clear that I don't think like a spoiled user who demands what he has or else "I won't use your language". You have the final word and you will decide. Also like I said before, If we have the same views on some topics, I would also learn and join the development. Let's see:

  1. DOCUMENTATION!!! Pretty much the most important thing imo. I'm talking about both user documentation and about developer documentation. The first one will come in time but I think that in this point the second one is more important as people should learn and how Vox is structured and how it works so we can contribute and improve the language. This will be really useful for people like me that want to help
  2. Please allow people to make suggestion/feature requests just like I do now and not make it necessary to write a whole HUGE proposal like D does. This is really annoying and it takes a lot of time to write, review and finally get approved. YOU should be the only one to decide the direction of Vox and choose who will get implemented and what not. D is where it is now pretty much because of this (well not only because of that but the language doesn't have a direction).
  3. Create a standard library that will be linked automatically (while having a flag to not link it). Let's make the library something between C++ and D in size with performance in mind so build directly on system calls rather than build on other functions like C++ (and D if I'm not wrong) does. I know this will take a lot of years to reach to this point but we gotta start right?
  4. Package/Project manager. I mean we all know the C/C++ dependency hell...
  5. Make a automatic memory management system (optional) based on some rules for when the memory is freed just like how Rust does it (but not having Ownership). If you are interested on this one, I could tell you my ideas.
  6. Optional semicolon maybe? I think we can have the end of a statement to be the end of the line just like a lot of other languages. The semicolon can be used when someone want to have a lot of statements in the same line.
  7. This a little bit of a detail thing but I think that you should also add words for types rather than just have things like "i32" because I think having numbers is a little bit distrusting. If not then maybe implement D-like alias where people can alias the type with the name they want (which would also be a great feature in general to beginning with). Also I think the the brackets look better after the name of the variable and it will also allow us to create multiple arrays of the same type with different sizes.
  8. For the end, I would say that I would like to see a strong template system like Rust's macro rules which is SUPER flexible and powerful. However you have pointed out in the "README" that you care about strong meta-programming and the you plan to implement macros (WIP) so you probably already thinking about that.

Anyway that was all. I know it was huge and I hope you don't mind but I'm so so so excited! The fast compilation times where really what I was looking for. Any language with fast compilation time would either by 4-6 times slower than C or it would be C (which is fine but really annoying when you hit the limitations). So if everything goes as planned, I'll look up the code and I hope I can help as soon as possible! Thanks for your work and I hope Vox gets big (fingers crossed!)!

Incorrect codegen for syscall instruction

Discussed in #29

Originally posted by rempas December 3, 2021
I'm trying to implement the "mmap" system call on Linux 64bit. I have the following code:

/* mmap system call */
/* Protections */
enum PROT_READ  = 0x1; /* Page can be read.  */
enum PROT_WRITE = 0x2; /* Page can be written.  */
enum PROT_EXEC  = 0x4; /* Page can be executed.  */
enum PROT_NONE  = 0x0; /* Page can not be accessed.  */

/* Flags */
enum MAP_SHARED    = 0x01; /* Share changes.  */
enum MAP_PRIVATE   = 0x02; /* Changes are private.  */
enum MAP_FIXED     = 0x10; /* Interpret addr exactly.  */
enum MAP_ANONYMOUS = 0x20; /* Don't use a file.  */

@extern(syscall, 9)
void* sys_mmap(void* addr, u64 len, i32 prot, i32 flags, i32 fd, i64 off);

void* malloc(u64 len) {
  return sys_mmap(null, len, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
}

void main() {
  u8* val = cast(u8*)malloc(4096); // PAGESIZE
  *val = 10;

  exit(0);
}

I got the signature for "mmap" from the man pages. This code will work under C but it will throw a "segmentation fault" on Vox when I try to de-reference the pointer. Any ideas?

ICE(be.reg_alloc.move_solver:64): Internal error: getInfo(g1)

I'm having a function that takes an i32 and return an u8. I will list the code that produces the error. Keep attention to the comment:

u8* i32_to_str(i32 num) {
  // These two lines both produce the error message
  if (num == 0) return "0";
  if (num == 0) return cast(u8*)'0'; // This worked in a previous commit

  u64 digit_count = 0;

  if (num < 0) {
    num = -num;
    digit_count++;
  }

  i32 tmp_num = num;
  while (tmp_num > 0) {
    digit_count++;
    tmp_num /= 10;
  }

  u8 *str = cast(u8*)malloc(digit_count + 1);
  // Same piece of code so it's commented out
  /* if (str == null) */
    /* return cast(u8*)'E'; */

  while (num > 0) {
    --digit_count;
    str[digit_count] = cast(u8)(num % 10 + '0');
    num /= 10;
  }

  if (digit_count == 1) str[0] = '-';
  /* return str; */ // Don't worry about this one, I was just testing the function
  return "174"; // Hmmmmm. This is like the first line but it works down here...
}

Also it is worth noted that this function compiled normally in a previous commit but it doesn't in the latest CI build.

Wrong stack alignment on Linux for entry point

Discussed in #29

Originally posted by rempas December 3, 2021
I'm trying to implement the "mmap" system call on Linux 64bit. I have the following code:

/* mmap system call */
/* Protections */
enum PROT_READ  = 0x1; /* Page can be read.  */
enum PROT_WRITE = 0x2; /* Page can be written.  */
enum PROT_EXEC  = 0x4; /* Page can be executed.  */
enum PROT_NONE  = 0x0; /* Page can not be accessed.  */

/* Flags */
enum MAP_SHARED    = 0x01; /* Share changes.  */
enum MAP_PRIVATE   = 0x02; /* Changes are private.  */
enum MAP_FIXED     = 0x10; /* Interpret addr exactly.  */
enum MAP_ANONYMOUS = 0x20; /* Don't use a file.  */

@extern(syscall, 9)
void* sys_mmap(void* addr, u64 len, i32 prot, i32 flags, i32 fd, i64 off);

void* malloc(u64 len) {
  return sys_mmap(null, len, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
}

void main() {
  u8* val = cast(u8*)malloc(4096); // PAGESIZE
  *val = 10;

  exit(0);
}

I got the signature for "mmap" from the man pages. This code will work under C but it will throw a "segmentation fault" on Vox when I try to de-reference the pointer. Any ideas?

Strange bug

struct Color {
    u8 r;
    u8 g;
    u8 b;
    u8 a;
}

void draw(){
    for(u64 i = 0; i < COUNT; i++){
        u8 a = cast(u8) i;
        Color c = Color(255, 0, 0, a);
    }
}
Compile error:
be.emit_mc_amd64:733: ICE: Index is not register, but constantZero 0
- module `test`
- function `draw`
  - defined at test.vx:16:1

Windows

fe.ast.expr.type_conv:226: ICE: TODO fi_i

I'm having an error that from what I understand has to do with casting. The code is the following:

alias time_t = i64;

struct timespec {
  time_t  tv_sec;     /* seconds */
  i64     tv_nsec;    /* nanoseconds */
}

i64 time_diff(timespec* start, timespec* end) {
  return (end.tv_sec - start.tv_sec) * cast(i64)1e9 + (end.tv_nsec - start.tv_nsec);
}

Of course this is always a part of the code. Line 9 causes the error

Build fails on Ubuntu 21.04

Building master on Ubuntu 21.04 fails as

~/.local/ldc2-1.26.0-beta1-linux-x86_64/bin/../import/std/bitmanip.d(313): Error: static assert:  "Wrong size of bitfield: 12"
be/debug_info/pdb/symbol.d(407):        instantiated from here: `bitfields!(CV_SourceLanguage, "sourceLanguage", 8, bool, "pcode", 1, ubyte, "floatprec", 2, ubyte, "floatpkg", 2, ubyte, "ambdata", 3, ubyte, "ambcode", 3, bool, "mode32", 1, ubyte, "pad", 12)`

ICE: getAst(VariableDeclNode) got cast(AstType)255

Expected behavior
Similar to #43 but now the a templated parameter is used instead.

Describe the bug
The error message is now:

vox.context:574: ICE: getAst(VariableDeclNode) got cast(AstType)255
Stack:
> test.vox:14:9: node.1164 type_check expr_call printa
  test.vox:13:13: node.1204 type_check stmt_block stmt_block
  test.vox:13:6: node.1073 type_check decl_function main
  test.vox:1:1: node.485 type_check decl_module test
[email protected](574)
----------------
??:? [0x55835b29249c]
??:? [0x55835b273f6d]
??:? [0x55835b0c21bd]
??:? [0x55835b0c1d69]
??:? [0x55835b17da25]
??:? [0x55835b178736]
??:? [0x55835b17865a]
??:? [0x55835b178b7f]
??:? [0x55835b19c5df]
??:? [0x55835b24628f]
??:? [0x55835b24d508]
??:? [0x55835b273bfe]
??:? [0x55835b273a80]
??:? [0x55835b2738dd]
??:? [0x7fe1a7f9c30f]
??:? __libc_start_main [0x7fe1a7f9c3c0]
??:? [0x55835b1bfe2d]

To Reproduce
The function signature is now:

void printa[Args](Args... data) {
  sys_write(1, data[1].ptr, data[1].length);
  sys_write(1, data[2].ptr, data[2].length);
  sys_write(1, data[3].ptr, data[3].length);
}

Additional context

vox.context:574: ICE: getAst(FunctionDeclNode) got decl_struct

Expected behavior
I was expecting to not get the exception

Describe the bug
I'm trying to create a templated struct and it doesn't work. It gives me the following error message:

vox.context:574: ICE: getAst(FunctionDeclNode) got decl_struct
Stack:
> test.vox:27:36: node.1297 type_check expr_call Vector[i32]
  test.vox:27:15: node.1311 type_check decl_var numbers
  test.vox:26:13: node.1353 type_check stmt_block stmt_block
  test.vox:26:6: node.1194 type_check decl_function main
  test.vox:1:1: node.485 type_check decl_module test
[email protected](574)
----------------
??:? [0x5640eeec169c]
??:? [0x5640eeea316d]
??:? [0x5640eecf11ad]
??:? [0x5640eecf0d59]
??:? [0x5640eedac4e9]
??:? [0x5640eeda7d9a]
??:? [0x5640eeda774a]
??:? [0x5640eeda766e]
??:? [0x5640eeda7bac]
??:? [0x5640eedcb2df]
??:? [0x5640eee7548f]
??:? [0x5640eee7c708]
??:? [0x5640eeea2dfe]
??:? [0x5640eeea2c80]
??:? [0x5640eeea2add]
??:? __libc_start_main [0x7fc47c3f40b2]
??:? [0x5640eedeecbd]

To Reproduce
Trying to compile the following source code:

@extern(syscall, 60)
void exit(i32 error_code);

@extern(syscall, 1)
void sys_write(u32 fd, u8* buf, u64 count);

void print(u8[] data) {
  sys_write(1, data.ptr, data.length);
}

struct Vector[T] {
  T* ptr;
  u64 capacity;
  u64 length;

  void add(T element) {
    if (capacity <= length) {
      /* ptr = malloc(); */
      print("Allocating more memory!");
    }

    ptr[length++] = element;
  }
}

void main() {
  Vector[i32] numbers = Vector[i32](null, 10, 0);
  exit(0);
}

.har file

Additional context

The example of "libvox" doesn't work for me.

Expected behavior
I was expecting the program to work (at least for the D version).

Describe the bug
The example doesn't work.

To Reproduce
I'm trying to compile the libvox example but I have no luck. I'm trying to do it both using D (and specifically LDC) and by using C. In the C version, I also had to copy the decorations from the "libvox" module and change some stuff to make it work with a C compiler. For that reason, there may be mistakes that I made here. Having "libvox" work with a C program is very important as pretty much everyone that's gonna make a language frontend will want to bootstrap at some point so it makes sense for me to test it and report back.

In the C version, the program compiles normally but when I try to run it, I get a segmentation fault. In the D version, I'm getting linker errors. More specifically:

/usr/bin/ld: test_libvox_d.o: in function `main':
test_libvox.d:(.text.main+0x4c): undefined reference to `_D6libvox__T5SliceTxaZQk6__ctorMFNaNbNcNiAxaZSQBs__TQBoTxaZQBv'
/usr/bin/ld: test_libvox.d:(.text.main+0x98): undefined reference to `_D6libvox__T5SliceTxaZQk6__ctorMFNaNbNcNiAxaZSQBs__TQBoTxaZQBv'
/usr/bin/ld: test_libvox.d:(.text.main+0xcf): undefined reference to `_D6libvox__T5SliceTxaZQk6__ctorMFNaNbNcNiAxaZSQBs__TQBoTxaZQBv'
collect2: error: ld returned 1 exit status
Error: /usr/bin/cc failed with status: 1

I have uploaded the files in a repo so you can easily test it out yourself and examine the code and see if I made any mistakes (if you prefer to do so). You can see more info in the 'README.md' in the repo. However, of course ask me if you need anything. I'll try to see and answer as fast as I can :)

Additional context

weird bug that causes newlines not get printed

This is a little bit weird and doesn't make any sense to begin with. So I will declare some variables and that will cause newlines (the "\n" character) to not get printed. I don't know if it is only newlines that will not get printed but newlines will not get printed for sure. So here is the code:

u8[10000] stdout_buffer;
u8[10000] stderr_buffer;
u16 stdout_index = 0;
u16 stderr_index = 0;

#version(linux) {
  /* read system call */
  enum u32 stdin = 0;
  @extern(syscall, 0)
  void sys_read(u32 fd, u8* buf, u64 count);

  /* write system call */
  enum u32 stdout = 1;
  enum u32 stderr = 2;
  @extern(syscall, 1)
  void sys_write(u32 fd, u8* buf, u64 count);
  void write(u8[] data) {
    sys_write(1, data.ptr, data.length);
  }
}

void main() {
  u8* num;
  num = to_str(32);
  sys_write(1, num, strlen(num));
  write("\n\n");

  num = to_str(-10);
  sys_write(1, num, strlen(num));
  write("\n\n"); // Ask this function if you don't have it

  exit(0);
}

This is some code I got from a previous error and I tested out. Now "to_str" just converts an integer to a u8* and then we got printing. If we uncomment the first 4 lines, the output will be as expected but when the lines get compiled, for some reason the newlines will not get printed.

$alias of global var

u32 hey;

$alias getHey(){
	return $alias(hey);
}

void main(){
	ExitProcess(getHey());
}

noreturn ExitProcess(u32 uExitCode);

Compiler crashes

`be.reg_alloc.move_solver(82): ICE: Assertion failure: Second write to eax detected` error

I'm trying to create a function to covert a string to a float I'm keep getting the error in the title. I have found out where the error occurs and I will post a snippet of the code.

Code:

f64 to_f64(u8* s) {
  f64 a = 0.0;
  i32 c;
  i32 e = 0;
  
  // HERE: "c = *s++" causes the error
  while ((c = *s++) != '\0' && is_digit(c)) {
    a = a * 10.0 + (c - '0');
  }

  if (c == '.') {
    // However, here it works perfectly fine
    while ((c = *s++) != '\0' && is_digit(c)) {
      a = a * 10.0 + (c - '0');
      e = e - 1;
    }

So yeah, any ideas why is this happening?

EDIT: This error happens on other places too but I haven't find the exact place yet so let's first fix that one and then I will update for the other places as well.

EDIT: Actually it's only one other place, I fixed the others

Add support for OSDev

If you are able to, try making this programming language be able to be used in OSDev.

ELF-64

Thanks for the Linux support! I've updated the Vox run-times. Default build is by far the fastest and generated executable is among the fastest! Great work!

Vox programs on linux will not get the signals with Ctrl+c, Ctrl+z etc.

Normally when I run a program, I expect Ctrl+c to stop its execution and Ctrl+z to suspend it (put it in the background). There are probably other signals that you can send but these two are the ones I mostly care about and from what I noticed (don't ask me why I found out about this now, lol) they don't work with Vox

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.