OpenGL and Vulkan examples; ptr(int)/int(ptr); trailing commas in calls; drop .fn hint

- examples/opengl.fch: OpenGL 3.3 core, shaders, VAO/VBO, a spinning triangle (checked offscreen)
- examples/vulkan.fch: instance, GPUs with properties/memory/queues, logical device and queue
- ptr(n) and int(p) conversions for C APIs that pass offsets as pointers
- .ptr works on string literals; a comma after the last call argument is allowed
- a missing header included by an imported header is now named in the error
- the old .fn extension hint is gone (Finch is new, there are no old files)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Nexoniarz 2026-10-08 19:37:34 +02:00
commit 8497251dc5
22 changed files with 357 additions and 26 deletions

View file

@ -758,7 +758,9 @@ LRef Codegen::member(const MemberExpr &m, bool forWrite) {
if (!obj.isPlace) release(obj.val);
return {false, {}, {len, FType::I64}};
}
if (!obj.isPlace && obj.val.fresh) failAt(p.file, p.line, p.col, ".ptr of a temporary value would point to freed memory");
// a literal lives as long as the program; other temporaries are freed right after this expression
if (!obj.isPlace && obj.val.fresh && !isa<Constant>(obj.val.v))
failAt(p.file, p.line, p.col, ".ptr of a temporary value would point to freed memory");
FType pt = t.kind == FType::Str ? FType::ptrTo(FType::Char) : FType::ptrTo(*t.elem);
return {false, {}, {t.kind == FType::Str ? cstr(v) : b.CreateExtractValue(v, 0), pt}};
}