Skip to content

feat: Array #22

@Zffu

Description

@Zffu

Add support for arrays in Quickfall.

There are two types of arrays in Quickfall:

  1. Static arrays: arrays of fixed size, will represent an vector IR type. Can be defined as follows <type>[<size as u64>]
  2. Pointer-based arrays: arrays originating from a pointer. These are unsafe and will return unsafe marked values. Pointer arrays can also be passed as pointers. Written as *<type>[]

Syntax examples

var si32[6] testArray // 0 initialized

var si32 myInt = testArray[4]; // Gets 0, bounds checked at compile time

var si64 ind = ......
var si32 myInt = testArray[ind]; // Will check bounds at runtime if runtime safety isnt disabled. Will trigger a warning if not.
var ptr myPointer = ..... // Get from the allocator

var *si32[] myArray = cast_ptr si32<myPointer> // Converts myPointer into an array pointer

var si32# myUnsafeInt = myArray[7];

var si32? mySafeInt = myUnsafeInt.as_true(); // Runtime checks
var si32 myForcedInt = myUnsafeInt.as_true_forced(); // No runtime checks

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions