Handmade Network»Christoffer Lernö

Recent Activity

New blog post: Imports and modules
Christoffer Lernö

Converted the Raylib Arkanoid, which unearthed a bug in the ABI implementation! Excellent.

Playing Snake with Raylib + C3:

This is a first stab at a library description format for C3. This example defines only a single target (MacOS x64), but normally more are added. Using --lib raylib this definition would link libraylib.a + all of the MacOS frameworks. Note that rather than providing a statically allocated library, the same definition file could allow a directory of .c files or .c3 files to compile. Or link it dynamically.

C3 with raylib on mac

Output

ERROR: '@require "d > 0" violated.'
  at function test::test (debugstuff.c3:4)
  at function test::main (debugstuff.c3:10)
  at function test::_$mainstub (debugstuff.c3:8)

This prints:

Assertion failed: (@require "baz > 100" violated: 'whatever'.), function test, file debugstuff.c3, line 6.
Christoffer Lernö

Last piece of compile time constructs:

Just reducing the code output to LLVM on -O0 (an extreme case, reducing the number of instructions from 12 -> 3)

Christoffer Lernö

Some updates to the variant functionality - either get it as pointer or as the value copied to variable:

Not finished, but this prints

double 123.000000
int: 1
Unknown type.
New blog post: Some C3 Advent of Code
Christoffer Lernö

Ranged case Output:

Something else: 0
1-3
1-3
1-3
4-10
4-10
4-10
4-10
4-10
4-10
4-10
Something else: 11

I made this, which outputs:

3 12
1 7

Adding some volatile store/load:

New blog post: C3 Feature List
Christoffer Lernö
Christoffer Lernö
Christoffer Lernö
Christoffer Lernö
Christoffer Lernö
New blog post: How to break a + b + c
Christoffer Lernö
Christoffer Lernö

I've been implementing some of the programming language shootout tasks... here is mandelbrot:

C3 got string (actually slice) matching. This outputs

This works
This works too
Winning!

So this experimental stuff works now with this output:

Hex array: Open the pod bay doors
Base64 array: Open the pod bay doors
Multi line:
Say hello,
to my little friend...
Raw string: C:\foo\raw.dll

The whole new try stuff is added to C3 now, and I enhanced it a little:

A contributor made raylib bindings for C3: 🥳

First version of user defined foreach works, this prints

1
3
10

Thanks to the hard work by the contributor kvk1920 C3C is now up and running on Windows under Mingw and MSYS2 with CI! 🥳

I had to do ad hoc lexing for feature, but I'll end up reusing it for a lot of other compile time functions later on:

Doing test_param(11, 10); gives:

Assert violation 'Invalid input' on line 159, in file 'debugstuff.c3'.

This prints:

156: 
157: /**
158:  * @param x - one parameter
159:  * @param y - other parameter
               ^
(debugstuff.c3:159) Error: There is no parameter 'y', did you misspell it?

Getting more environment info available from inside of programs now.

Christoffer Lernö

So this now works, with an output of:

Repeat 1
Repeat 2
Repeat 3
Repeat 4
Repeat 5
Repeat 6
Repeat 7
Repeat 8
Repeat 9
Repeat 10
111 121 4 77 

I added this for enums, it's sometimes useful (printing Min -5 Max 14 Elements: 3)

C3 got a new style for casts:

Finally some generic module code up and running. Defining some parameterized functions and types.

Those cursed gradients are working again for text rendering:

Sum integers using recursion, slices and typed varargs... 😅 (call using sum_us(1, 3, 5, 11))

Ok so this works now, but it's using alloca to copy the slice. I don't know how I feel about that. In safe mode you'll get a panic if you exceed MAX_PARAMS, but currently not in non-safe. I might mask this though.

Typed varargs in C3:

A goddarn miracle, C3 is using built in linking on Linux

Christoffer Lernö
Christoffer Lernö
Christoffer Lernö
Christoffer Lernö
Christoffer Lernö
Christoffer Lernö
Christoffer Lernö
Forum reply: Welcome everyone
Christoffer Lernö
New blog post: Implementing "defer"
Christoffer Lernö
Christoffer Lernö

Piecemeal adding some welcome library functionality while checking how the macros/function namespacing looks in the wild (not perfect yet):

Took a little while but constant aggregates are now spliced in a fairly efficient format from what I can see. This one would take gigabytes of memory to describe for Clang:

More and more debug info getting done in the C3 backend:

New forum thread: Welcome everyone
Christoffer Lernö