Remove iptrdiff and uptrdiff. Bump version to 0.3.100

This commit is contained in:
Christoffer Lerno
2022-11-17 23:44:54 +01:00
parent bbef94b0fd
commit da1a45f718
61 changed files with 125 additions and 142 deletions

View File

@@ -61,7 +61,7 @@ fn void encode(char[] in, char *out)
}
// move back
usize last = in.len - 1;
usz last = in.len - 1;
// check the last and add padding
switch (last % 3)
{

View File

@@ -18,7 +18,7 @@ fn String bin(int x)
str.append_repeat('0', bits);
for (int i = 0; i < bits; i++)
{
str.set((usize)(bits - i - 1), x & 1 ? '1' : '0');
str.set((usz)(bits - i - 1), x & 1 ? '1' : '0');
x >>= 1;
}
return str;

View File

@@ -10,7 +10,7 @@ fault InterpretError
INTEPRET_FAILED
}
fn void! print_error(usize pos, char[] err)
fn void! print_error(usz pos, char[] err)
{
io::printfln("Error at %s: %s", pos, err);
return InterpretError.INTEPRET_FAILED!;
@@ -18,8 +18,8 @@ fn void! print_error(usize pos, char[] err)
fn void! brainf(char[] program)
{
usize sp = 0;
usize mem = 0;
usz sp = 0;
usz mem = 0;
while (sp < program.len)
{
char c = program[sp++];
@@ -41,9 +41,9 @@ fn void! brainf(char[] program)
case ',':
memory[mem] = io::stdin().getc()!!;
case '[':
usize indent = 1;
usz indent = 1;
if (memory[mem]) continue;
usize start = sp - 1;
usz start = sp - 1;
while (indent)
{
if (sp == program.len) return print_error(start, "No matching ']'");
@@ -56,8 +56,8 @@ fn void! brainf(char[] program)
}
case ']':
if (!memory[mem]) continue;
usize start = sp--;
usize indent = 1;
usz start = sp--;
usz indent = 1;
while (indent)
{
if (!sp) return print_error(start, "No matching '['");

View File

@@ -14,8 +14,8 @@ struct Summary
private struct StringData
{
Allocator allocator;
usize len;
usize capacity;
usz len;
usz capacity;
char[*] chars;
}
@@ -27,12 +27,12 @@ fn void Summary.print(Summary *s, File out)
fn bool contains(char[] haystack, char[] needle)
{
usize len = haystack.len;
usize needle_len = needle.len;
usz len = haystack.len;
usz needle_len = needle.len;
if (len < needle_len) return false;
if (!needle_len) return true;
len -= needle_len - 1;
for (usize i = 0; i < len; i++)
for (usz i = 0; i < len; i++)
{
if (mem::equals(haystack[i..], needle))
{

View File

@@ -2,7 +2,7 @@ module guess_number;
import std::io;
import libc;
extern fn isize getline(char** linep, usize* linecapp, CFile stream);
extern fn isz getline(char** linep, usz* linecapp, CFile stream);
struct Game
{
@@ -33,7 +33,7 @@ fn int! askGuess(int high)
fn char[]! readLine()
{
char* chars = tmalloc(1024)?;
isize loaded = getline(&chars, &&(usize)1023, libc::stdin());
isz loaded = getline(&chars, &&(usz)1023, libc::stdin());
if (loaded < 0) return InputResult.FAILED_TO_READ!;
chars[loaded] = 0;
return chars[0..(loaded - 1)];

View File

@@ -56,7 +56,7 @@ const LINELEN = 60;
// slowest character-at-a-time output
fn void repeat_fasta(char[] seq, int n)
{
usize len = seq.len;
usz len = seq.len;
int i = void;
for (i = 0; i < n; i++)
{

View File

@@ -10,14 +10,14 @@ struct Entry
{
Key key;
Type value;
usize hash;
usz hash;
Entry* next;
bool used;
}
struct Map
{
usize size;
usz size;
Entry* map;
uint mod;
}
@@ -37,7 +37,7 @@ fn Type! Map.valueForKey(Map *map, Key key)
{
if (!map.map) return MapResult.KEY_NOT_FOUND!;
uint hash = key.hash();
usize pos = hash & map.mod;
usz pos = hash & map.mod;
Entry* entry = &map.map[pos];
if (!entry) return MapResult.KEY_NOT_FOUND!;
while (entry)
@@ -91,7 +91,7 @@ fn Type! Map.set(Map *map, Key key, Type value) @maydiscard
}
}
fn usize Map.size(Map* map)
fn usz Map.size(Map* map)
{
return map.size;
}

View File

@@ -15,10 +15,10 @@ struct Planet
fn void advance(Planet[] bodies) @noinline
{
usize nbodies = bodies.len;
usz nbodies = bodies.len;
foreach (i, Planet* &b : bodies)
{
for (usize j = i + 1; j < nbodies; j++)
for (usz j = i + 1; j < nbodies; j++)
{
Planet* b2 = &bodies[j];
double dx = b.x - b2.x;
@@ -45,12 +45,12 @@ fn void advance(Planet[] bodies) @noinline
fn double energy(Planet[] bodies)
{
double e;
usize nbodies = bodies.len;
usz nbodies = bodies.len;
foreach (i, Planet* &b : bodies)
{
e += 0.5 * b.mass * (b.vx * b.vx + b.vy * b.vy + b.vz * b.vz);
for (usize j = i + 1; j < nbodies; j++)
for (usz j = i + 1; j < nbodies; j++)
{
Planet* b2 = &bodies[j];
double dx = b.x - b2.x;

View File

@@ -16,14 +16,14 @@ macro assert_exp($c, $e)
*/
/** A signed integer, whose size matches Value */
typedef isize Aint;
typedef isz Aint;
/** An unsigned integer, whose size matches Value */
typedef usize Auint;
typedef usz Auint;
/** A float, whose size matches Value (see avm_env.h) */
$assert(usize.size == 8 || usize.size == 4)
$if (usize.size == 8)
$assert(usz.size == 8 || usz.size == 4)
$if (usz.size == 8)
{
typedef double as Afloat;
}

View File

@@ -66,7 +66,7 @@ fn char[]! read_next(char[]* remaining)
// Store the beginning of the parse
char* ptr_start = remaining.ptr;
usize len = 0;
usz len = 0;
while (remaining.len > 0 && (*remaining)[0] != ' ')
{
// Increase length