Giter Club home page Giter Club logo

basque's People

Contributors

nikolashn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

basque's Issues

Add the bool type

The bool type should work as a Boolean value which can take values of 0 or 1, with a size of 1 byte. All non-zero integers when converted to bool are 1, all zeros remain as 0.

Bug in assigning dereferencing list to bool

For example both of the following programs will output 1 when they should output 0.

i64 x = 0;
i64* ptr = &x;
bool a = 1;
a = [ptr];
write a; "\n";
u8 x = 0;
u8* ptr = &x;
bool a = 1;
a = [ptr];
write a; "\n";

Getting the size of a dereferencing list erroneously generates actual dereferencing code

In the following example, when the source code is compiled and run, it will give a segmentation fault. This is because when parsing the second line, the compiler will try to generate code to actually dereference ptr (which is set to 0), rather than just getting the size of the type of [ptr] (a constant known at compile time).

Source code:

i64* ptr = 0;
write $[ptr]; "\n";

Expected output:

8

Actual output: (segmentation fault)

Variables on the stack are sometimes not correctly located

Example of code compiled erroneously:

{
    i64 x = 5;
    i64 y = 3;
    i64 a = x * y;
    # Writes "5" instead of "15"
    write a; "\n";
}

Disassembly of the code generated by this example gives the following (comments added by me):

[...]
0000010F  B805000000        mov eax,0x5
00000114  50                push rax
00000115  B803000000        mov eax,0x3
0000011A  50                push rax
0000011B  488B442410        mov rax,[rsp+0x10] ; (incorrect location) x
00000120  488B4C2408        mov rcx,[rsp+0x8] ; (incorrect location) y
00000125  480FAFC1          imul rax,rcx
00000129  50                push rax
0000012A  488B0424          mov rax,[rsp] ; (correct location) a
0000012E  E8CDFEFFFF        call 0x0 ; (internal function) U64ToStr
[...]

Make sure that already included files are not reincluded multiple times

For example, compiling main.ba should not give an error about redefining RotL as it currently does, since rotl.ba would not be included the second time compilation reached an include statement. "Included RotL func.\n" should be written out only once.

main.ba

include "rotl.ba";
write RotL(1, 100); "\n";

include "rotatedvars.ba";
write r0; "\n";
write r1; "\n";
write r2; "\n";
write r3; "\n";

rotl.ba

"Included RotL func.\n";
u64 RotL(u64 n, u64 r) {
  return (n << r) | (n >> -r);
}

rotatedvars.ba

include "rotl.ba";
u64 r0 = 0xEEEE_EEEE_EEEE_EEEE;
u64 r1 = RotL(r0, 1);
u64 r2 = RotL(r0, 2);
u64 r3 = RotL(r0, 3);

Recursion does not work

Minimal example:

u64 One(u64 n) {
	if n <= 1u, return 1;
	return One(n-1);
}

One(0); # Compiles with no errors, executes correctly
One(1); # Compiles with no errors, executes correctly
One(2); # Compiles with no errors, execution crashes with segmentation fault

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.