Skip to content

Latest commit

 

History

History
181 lines (167 loc) · 4.4 KB

File metadata and controls

181 lines (167 loc) · 4.4 KB

Todo

  • Arrays/Pointers
    • Array indexing
    • Array init
    • Array decay
    • Pointer indexing
    • Array Deref
    • Pointer deref
  • Array Return value -> Probably skip for now, since it's not in C
  • Structs
    • Initialization
    • field lookup
    • Pass by Reference
    • Pass by value
    • Return
    • Structs of Structs
    • Arrays of Structs
    • Structs of Arrays
    • Typecheck invalid/missing fields
    • Vec2 { x, y } syntax
  • Globals
    • Global Declaration
    • Global Lookup
    • Full Const Eval
      • Literal
      • Binary
      • Unary
      • Struct
      • Array
      • Globals
    • Extern Globals (STDIN, STDOUT, STDERR)
  • For-loop
  • Break/Continue
  • Nullptr
  • Modules
    • Find modules
    • Import aliasing ( const math = import "math" )
    • Import module
    • pub keyword
    • Resolve prototypes
    • Resolve Globals
    • Resolve Externs?
    • Path operator ( math::Vec2 stdio::print() )
    • Reexports with alias ( pub const math = import "math" )
    • Reexport symbols ( pub const foo = inner_foo; )
    • Convert Identifiers to symbols
      • Struct init
      • Calls
      • Globals
  • Unions
    • Initialization
    • field lookup
    • Pass by Reference
    • Pass by value
    • Return
    • Union of Structs
    • Struct of Unions
    • Arrays of Unions
    • Unions of Arrays
  • Enums -> Typechecked numbers with certain amount of bits?
    • switch/match
      • Basic implementation
      • Check for duplicate cases
      • Allow skipping default case when cond is enum and all enum variants are covered
    • Define value enum { ROCK = 10, }
  • Fn Variadic args
  • Fix char[]
    • How to store 2 chars in a single W
    • How to index even/uneven chars (str[1] = 'c' / str[2] = 'a')
    • It just works
  • [?] stdlib
    • IO: Read, Write, printf, putchar, getchar, puts,
    • File: Open, Read, Seek, Close, ect.
    • Memory: malloc, free, calloc, memcpy, memset, memcmp
    • String: strcpy, strcmp, strncmp, push, slice, concat, ect.
    • Exit, Assert
    • sizeof
  • AssignEq operators
    • i += 1; i -= 1;
  • Fn Pointers
    • TypeIdent: fn(int, int, int): int
    • Calling Pointers
  • Explicit pointer casting -> replace most of implicit (disallow *vec -> *player, but allow *vec -> *void -> *player)
    • Add *void/*any/ptr/ptr/ type
    • Update try_cast to rely on this
  • Compiler Arg forwarding + executable forwarding
    • ./ib -cc=gcc -cc_flags="-lraylib -lpthread" -e -- {...exec_args}
    • ./ib run
    • ibconfig.conf -> define builds/args
  • Optional:
    • stdlib::math: sin, cos, sqrt, floor, ceil, pow
    • offsetof
    • Unit test runner
    • stdlib::cmd: Parse
    • Bitwise operators/any other operators
  • Update treesitter grammar
    • support ' ' " " (strings/chars ending with space)
    • break, continue, for, null, pub
    • const/imports/alias
    • union, Enums, Fn Typeident
    • switch/case/match
    • rest of the operators
  • (*any) Can it gent deferred?

Optional, but really sweet sounding syntactic sugars

Tagged Enum (Variants)

variant Foo {
  Bar(Bar),
  Baz(Baz),
}

fn assert_foo(foo: Foo, tag: Foo::Tag) {
  if foo != tag {
    panic(...)
  }
}

let foo = Foo::Bar(Bar { ... });
assert_foo(foo, Foo::Bar);

CompTime Generics

Ideally, it's just gathered into a Set, compiled and typechecked as if they are normal types

variant Result<T, V> {
  Ok(T)
  Err(V)
}
let res = fallible();
match res {
  Ok(res) => {},
  Err(err) => {},
}
// This is kinda cool, we technically 
// shouldn't need to know T or V here
if res == Result::Ok {}

Flags

flag EntityFlag {
  Player // 1 << 0
  Dead, // 1 << 1
  Ally, // 1 << 2
  Enemy, // 1 << 3
}
let entity_flag: EntityFlag = EntityFlag::Player | EntityFlag::Dead | EntityFlag::Ally

Anonymous Types

union Vec2 {
  v: int[2],
  struct { x: int, y: int },
}

union Vec2 {
  v: int[2],
  u: struct { x: int, y: int },
}

struct Entity {
  id: EntityId,
  struct {
    is_alive: bool,
    is_player: bool,
    is_enemy: bool,
    on_fire: bool,
    on_poison: bool,
  }
}

Sort of a syntactic sugar, could either be under a field or unwrapped