Commit Graph

13 Commits

Author SHA1 Message Date
daf429d463 Core: Add the signedness machinery (no behaviour change)
LLVM integer types are sign-agnostic; the sign lives in the operations. The
frontend therefore has to carry it, and until now it did not: c_uint32 became
a bare i32 at declaration and every later choice (sext, sdiv, icmp_signed)
assumed signed.

This commit adds the pieces without changing any emitted IR:

- type_deducer.IntTy, an ir.IntType subclass carrying 'signed'. It renders,
  compares and hashes as the plain type, so the 40 isinstance checks and every
  == ir.IntType(64) comparison keep working; signedness() reads it and treats a
  plain IntType as signed (today's behaviour). Constructed outside IntType's
  per-width instance cache, which is shared with subclasses and would have
  merged the two signs of a width into one object.
- ctypes_to_ir now returns IntTy, which types five declaration kinds at once:
  locals from ctypes constructors, struct fields, globals, context
  annotations, and map key/value types. is_signed_ctype replaces the private
  copy in globals_pass.
- operators.usual_arithmetic_conversions: C's rule for the type a binary
  operation is performed in.
- type_normalization.convert (source-driven zext/sext when widening, trunc
  when narrowing) and canonicalise (bring a value to the working width holding
  exactly a given type's value).

Nothing consults the sign yet. The corpus of 67 compilable test programs
produces byte-identical .ll before and after.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BSDVsZH5NtoASyxB8FCtGU
2026-09-17 20:34:21 +05:30
1593b7bcfe feat:user defined struct casting 2025-11-27 12:41:57 +05:30
4905649700 feat:non struct field values can be cast 2025-11-26 14:18:40 +05:30
204ec26154 add i32 support and make it extensible 2025-11-01 14:44:39 +05:30
85a62d6cd8 add example and support unsigned i64 2025-11-01 08:13:22 +05:30
93285dbdd8 geenrate gep IR 2025-10-26 02:12:33 +05:30
f53ca3bd5b Add ctypes in eval_expr 2025-10-06 04:43:04 +05:30
8d5067996f format chore and pre commit hook addition 2025-10-01 00:41:00 +05:30
5adc6d75e9 janitorial 2025-09-09 00:26:06 +05:30
03404bb164 make license handling easier 2025-09-09 00:19:53 +05:30
7e47f8dcef Multi string and multi program support 2025-09-07 20:41:41 +05:30
1118e4fcd6 add naive unpythonic return type inference to function parsing 2025-09-07 20:12:39 +05:30
a8e7a42b72 WIP functions processing 2025-08-31 05:12:47 +05:30