feat: add stdlib module support with auto-import resolution
- Parse module paths in stdlib (module Std::Array { ... })
- Collect stdlib declarations and inject into user modules before sema
- Add dkExternFunc support throughout pipeline (parser, sema, hir, c backend)
- Auto-dereference pointer types for field access (arr->field)
- Add hArrowField HIR node for cleaner C emission
- Fix resolveTypeExpr for pointer and cast types
- Fix struct field lowering to use resolveTypeExpr
- Allow int <-> uint implicit conversion for bootstrap convenience
- Add stdlib/Std/Array.bux with dynamic array primitives
- Add stdlib_test demonstrating Array usage via import Std::Array::{Array};
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
import Std::Array::{Array, Array_New, Array_Push, Array_Get, Array_Len, Array_Free};
|
||||
import Std::Io::{PrintLine, PrintInt};
|
||||
|
||||
func Main() -> int {
|
||||
var arr: Array = Array_New(4);
|
||||
|
||||
Array_Push(&arr, 10);
|
||||
Array_Push(&arr, 20);
|
||||
Array_Push(&arr, 30);
|
||||
|
||||
PrintLine("Array contents:");
|
||||
var i: uint = 0;
|
||||
while i < Array_Len(&arr) {
|
||||
PrintInt(Array_Get(&arr, i));
|
||||
PrintLine("");
|
||||
i = i + 1;
|
||||
}
|
||||
|
||||
Array_Free(&arr);
|
||||
return 0;
|
||||
}
|
||||
Reference in New Issue
Block a user