asm...
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
#import "modules/std.sx";
|
||||
#import "modules/math/math.sx";
|
||||
#import "modules/compiler.sx";
|
||||
pkg :: #import "modules/testpkg";
|
||||
|
||||
// ============================================================
|
||||
@@ -3064,5 +3065,60 @@ END;
|
||||
print("opt-if5: {}\n", val2 ?? 0.0);
|
||||
}
|
||||
|
||||
// --- usize / isize ---
|
||||
{
|
||||
a : usize = 42;
|
||||
b : isize = 0 - 7;
|
||||
print("usize: {}\n", a);
|
||||
print("isize: {}\n", b);
|
||||
|
||||
// arithmetic
|
||||
c : usize = a + 8;
|
||||
print("usize+8: {}\n", c);
|
||||
|
||||
// coercion from s32
|
||||
x : s32 = 10;
|
||||
y : usize = xx x;
|
||||
print("s32->usize: {}\n", y);
|
||||
|
||||
// coercion to s64
|
||||
z : s64 = xx a;
|
||||
print("usize->s64: {}\n", z);
|
||||
}
|
||||
|
||||
// --- inline if (compile-time conditionals) ---
|
||||
print("=== inline if ===\n");
|
||||
{
|
||||
// POINTER_SIZE is 8 on desktop (64-bit)
|
||||
inline if POINTER_SIZE == 8 {
|
||||
print("64-bit\n");
|
||||
} else {
|
||||
print("32-bit\n");
|
||||
}
|
||||
|
||||
// OS enum comparison
|
||||
inline if OS == .wasm {
|
||||
print("wasm\n");
|
||||
} else {
|
||||
print("not wasm\n");
|
||||
}
|
||||
|
||||
// != comparison
|
||||
inline if OS != .unknown {
|
||||
print("known os\n");
|
||||
} else {
|
||||
print("unknown os\n");
|
||||
}
|
||||
|
||||
// nested inline if
|
||||
inline if POINTER_SIZE != 4 {
|
||||
inline if OS != .wasm {
|
||||
print("desktop 64-bit\n");
|
||||
} else {
|
||||
print("wasm 64-bit??\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
print("=== DONE ===\n");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user