diff --git a/src/ast.h b/src/ast.h index d98c499..6d82ff8 100644 --- a/src/ast.h +++ b/src/ast.h @@ -85,12 +85,12 @@ class FunctionAST { std::string parentStruct; // Path of the module this function was declared in (e.g. "timer" - // for code in timer.jam). Empty for the entry module (matching - // Zig's behavior where the root file scope is the unqualified + // for code in timer.jam). Empty for the entry module (whose + // root file scope is the unqualified // namespace) and for generic clones that already carry qualified // names. ModuleResolver stamps this when a module is loaded. // - // Combined with parentStruct, the mangler can emit Zig-style + // Combined with parentStruct, the mangler can emit // dotted LLVM symbols (`timer.Timer.read32`) so same-named // methods or free fns in different modules don't collide. std::string modulePath; diff --git a/src/ast_flat.h b/src/ast_flat.h index 165dfd8..60fc1b0 100644 --- a/src/ast_flat.h +++ b/src/ast_flat.h @@ -372,8 +372,8 @@ enum class TypeKind : uint8_t { // are values of this type only at compile time; codegen rejects any // attempt to lower a Module-typed JIR ref to LLVM. // - // Mirrors Zig's "file = zero-field struct with namespace" pattern, - // but kept distinct from TypeKind::Struct so module values can't be + // Modeled as a zero-field struct that carries a namespace, but + // kept distinct from TypeKind::Struct so module values can't be // confused with user-defined aggregates. Module, // Function-typed value: a pointer to a function with a known diff --git a/src/astgen.cpp b/src/astgen.cpp index 18812fe..e70f7a8 100644 --- a/src/astgen.cpp +++ b/src/astgen.cpp @@ -639,9 +639,9 @@ static JirRef astgenNumberLit(AstGenCtx &gctx, const AstNode &n, // Pointer decay: a string literal is a NUL-terminated `u8` array constant, // so when the use site expects a many-/single-item pointer to u8 // (`*const[] u8`, `*mut[] u8`, `*const u8`) it lowers to the bare global -// pointer instead of a fat slice. This mirrors Zig, where a literal's type -// `*const [N:0]u8` coerces to `[*]const u8` / `[*c]const u8` (Sema.zig's -// `src_array_ptr` array-pointer decay). It is what lets a literal be passed +// pointer instead of a fat slice. A NUL-terminated array constant +// coerces to a many- or single-item pointer through array-pointer +// decay. It is what lets a literal be passed // straight to C FFI — `snprintf(.., "n=%d", ..)` — without an explicit // `.ptr`, while a runtime `[]u8` slice (which carries no static NUL // guarantee) still requires `.ptr`. The decay is keyed on the EXPECTED @@ -716,8 +716,8 @@ static TypeIdx resolveScalarExpected(AstGenCtx &gctx, TypeIdx t) { } // Does a comp integer value fit in `width`/`isSigned` without changing -// its numeric meaning? Mirrors Zig's "type 'u8' cannot represent -// integer value '256'" check. +// its numeric meaning? Rejects cases like a u8 that cannot represent +// the integer value 256. static bool compIntFits(const jam::ComptimeValue &v, uint16_t width, bool isSigned) { if (width >= 64) { @@ -2320,7 +2320,7 @@ static JirRef astgenArrayRepeat(AstGenCtx &gctx, const AstNode &n, "element explicitly"); } - // Zig-style fill: a constant byte fill (especially `[0; N]`) + // Constant-byte fill: a constant byte fill (especially `[0; N]`) // lowers to one memset instead of N unrolled IndexAddr+Store. // memset covers any zero fill (zeros every element type) and a // byte-element fill; other constant fills use the per-element path. @@ -5401,8 +5401,8 @@ static JirRef astgenAtCall(AstGenCtx &gctx, const AstNode &n) { // linker) on Linux. Sourced from the host target, which is the // only target today; switch to the selected target once // cross-compilation lands. - // `isDarwin` follows Zig (std.Target.Os.Tag.isDarwin = the Apple - // family). Jam's OS enum only has MacOS today, so it reduces to + // `isDarwin` covers the Apple OS family. Jam's OS enum only has + // MacOS today, so it reduces to // that and widens automatically if iOS/tvOS/etc. are ever added. // `isUnix` is "not Windows" for the current enum. jam::OS os = jam::Target::getHostTarget().os; @@ -5419,8 +5419,8 @@ static JirRef astgenAtCall(AstGenCtx &gctx, const AstNode &n) { return emit(gctx, inst); } if (name == "os") { - // `@os()` → the OS name as a `[]u8`, mirroring Zig's - // `@tagName(builtin.os.tag)` (e.g. "macos", "linux"). This is the + // `@os()` → the OS name as a `[]u8` (e.g. "macos", "linux"), + // the tag name of the current OS. This is the // display form: unlike the boolean predicates it does NOT fold a // branch (string `==` isn't comptime-evaluated), so keep using // `@isDarwin()` & co. for conditional compilation / dead-code @@ -5661,8 +5661,8 @@ static JirRef lowerArgInner(AstGenCtx &gctx, NodeIdx argIdx, const Param &p) { // A runtime slice does not implicitly decay to a pointer parameter; // passing a {ptr,len} aggregate where the callee expects a bare // pointer silently corrupts the ABI (e.g. desyncs C varargs). - // Require an explicit `.ptr`, matching Zig (a `[]T` slice has no - // static NUL guarantee, so it never coerces to `[*]T`). String + // Require an explicit `.ptr`: a `[]T` slice has no static NUL + // guarantee, so it never coerces to a many-item pointer. String // literals decay in astgenStringLit, so they arrive here already // typed as a pointer and skip this check. const TypeKey &vk = gctx.ctx.getTypePool().get(gctx.jfn.getInst(v).ty); @@ -6732,9 +6732,9 @@ static JirRef astgenCall(AstGenCtx &gctx, const AstNode &n, JirRef destPtr) { // not as a regular function call. if (callee == "assert") { return astgenAssertCall(gctx, n); } - // Multi-dot qualified call: `handle.Struct.method(args)`. Mirrors - // Zig's `container_ty.getNamespace().lookupInNamespace(name)` - // (Sema.zig:5295) — methods on imported structs live under the + // Multi-dot qualified call: `handle.Struct.method(args)`. Looks up + // the method in the container type's namespace — methods on + // imported structs live under the // importer's namespace handle, not in a flat global table. The // registration site in main.cpp puts these under the key // `handle.Struct.method`; we look them up directly here. diff --git a/src/codegen.cpp b/src/codegen.cpp index 129e359..b8296ce 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -1013,7 +1013,7 @@ TypeIdx JamCodegenContext::resolveGenericCall(TypeIdx callTy) const { // Look it up by whichever name the caller used. const FunctionAST *generic = getFunctionAST(calleeName); if (!generic && calleeDecl != jam::kNoDecl) { - // Demand-driven resolution (Zig-style): the eager import pass may + // Demand-driven resolution: the eager import pass may // not have reached this generic's defining module yet // (getLoadedModules() is an unordered_map), so resolve it on // reference straight from the decl index, which registerTopLevelDecls diff --git a/src/jir_codegen.cpp b/src/jir_codegen.cpp index 986f848..d84ced4 100644 --- a/src/jir_codegen.cpp +++ b/src/jir_codegen.cpp @@ -588,13 +588,13 @@ static JamValueRef emitInstImpl(JirCodegenCtx &lctx, JirRef r) { // JirRef VALUE is the storage pointer, never a materialized // aggregate in SSA. Skip the trailing `load %T, ptr %gep`; // downstream Store / Ret / arg-passing then sees a byref pointer - // and emits memcpy / pointer-forward. Mirrors the byref branch in - // Zig's airSliceElemVal / airPtrElemVal / airArrayElemVal - // (references/zig-0.10.1 src/codegen/llvm.zig ~5678/5716/5745): - // they do the same GEP + return-pointer-for-byref-elem. jam's - // universal "byref JirRef = pointer" invariant means we don't - // need Zig's `loadByRef` fallback — every downstream byref - // consumer (Store/Ret/Call) already memcpy's from the pointer. + // and emits memcpy / pointer-forward. This is the byref branch + // for slice / many-ptr / array element access: do the GEP and + // return the element pointer rather than loading the value. + // jam's universal "byref JirRef = pointer" invariant means we + // don't need a load-by-reference fallback — every downstream + // byref consumer (Store/Ret/Call) already memcpy's from the + // pointer. // Without this guard the aggregate was loaded into SSA, but the // byref consumer still treated the JirRef as a pointer — the // result was a malformed memcpy passing a struct value where a @@ -622,10 +622,9 @@ static JamValueRef emitInstImpl(JirCodegenCtx &lctx, JirRef r) { } // Array case. Arrays are byref (abi::isByRef is always true for // TypeKind::Array), so `emitInst` returns a *pointer* to the - // backing storage — GEP straight into it, mirroring Zig's - // airArrayElemVal byref branch (references/zig-0.10.1 - // src/codegen/llvm.zig:5724: resolveInst gives a pointer, then - // inBoundsGEP {0, idx}). The previous code unconditionally + // backing storage — GEP straight into it: resolving the base + // gives a pointer, then an in-bounds GEP of {0, idx} indexes the + // element. The previous code unconditionally // spilled `base` into a fresh alloca; for a byref base that // stores the *pointer bits* into a [N]T slot and then indexes // garbage — the bug behind module-const array reads (`TABLE[i]`) diff --git a/src/lexer.cpp b/src/lexer.cpp index f908da4..2485201 100644 --- a/src/lexer.cpp +++ b/src/lexer.cpp @@ -53,7 +53,7 @@ void Lexer::skipWhitespace() { break; } // `/*` is NOT a comment — jam has only `//` line comments - // (same deliberate choice as Zig: greppable, no nesting + // (a deliberate choice: greppable, no nesting // rules). Without this check the `/` lexes as divide and the // parser reports a baffling "Expected primary expression". if (peekNext() == '*') { diff --git a/src/main.cpp b/src/main.cpp index fe25dbd..90a27d7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1229,9 +1229,9 @@ static int compileAndRun(const std::string &filename, // `--emit-ir` is a "print IR and exit" mode — skipping the object // emit + link step matches clang's `-emit-llvm -S` / rustc's - // `--emit=llvm-ir` / zig's `-femit-llvm-ir` behavior. Critically - // it also dodges the default output name (`./output`) colliding - // with the build tree's `output/` directory in this repo. + // `--emit=llvm-ir` behavior. Critically it also dodges the default + // output name (`./output`) colliding with the build tree's + // `output/` directory in this repo. if (emitIR) { char *irStr = JamLLVMPrintModuleToString(codegenCtx.getModule()); std::cout << irStr; diff --git a/src/mangling.h b/src/mangling.h index 2b833b0..1fc3e36 100644 --- a/src/mangling.h +++ b/src/mangling.h @@ -14,9 +14,9 @@ #include // Translate a FunctionAST into the LLVM-level symbol the linker sees. -// Modeled on Zig's `Decl.getFullyQualifiedName` (Module.zig:713) — -// dot-separated, walking up the namespace chain. LLVM accepts `.` in -// symbol names, so no further escaping is needed. +// Builds a dot-separated fully-qualified name, walking up the +// namespace chain. LLVM accepts `.` in symbol names, so no further +// escaping is needed. // // The rules: // - `tfn t()` -> `__test_t` (the harness in main.cpp calls these by