mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 03:51:18 +00:00
Complete transition to fn. Introduce global/threadlocal
This commit is contained in:
committed by
Christoffer Lerno
parent
e2621617f1
commit
b52b42d4da
@@ -13,7 +13,7 @@ public struct BigInt @opaque
|
||||
char sign;
|
||||
}
|
||||
|
||||
public func void BigInt.init(BigInt* bigInt)
|
||||
public fn void BigInt.init(BigInt* bigInt)
|
||||
{
|
||||
bigInt.number = malloc(1);
|
||||
bigInt.number[0] = 0;
|
||||
@@ -21,7 +21,7 @@ public func void BigInt.init(BigInt* bigInt)
|
||||
bigInt.sign = 1;
|
||||
}
|
||||
|
||||
public func void BigInt.initFromString(BigInt* bigInt, char* str)
|
||||
public fn void BigInt.initFromString(BigInt* bigInt, char* str)
|
||||
{
|
||||
uint size = strlen(str);
|
||||
bigInt.sign = 1;
|
||||
@@ -46,7 +46,7 @@ public func void BigInt.initFromString(BigInt* bigInt, char* str)
|
||||
bigInt.length = size;
|
||||
}
|
||||
|
||||
public func void BigInt.copyTo(BigInt* source, BigInt* target)
|
||||
public fn void BigInt.copyTo(BigInt* source, BigInt* target)
|
||||
{
|
||||
target.number = realloc(target.number, source.length);
|
||||
target.sign = source.sign;
|
||||
@@ -54,12 +54,12 @@ public func void BigInt.copyTo(BigInt* source, BigInt* target)
|
||||
for (uint i = 0; i < target.length; i++) target.number[i] = source.number[i];
|
||||
}
|
||||
|
||||
public func void BigInt.destroy(BigInt* bigInt)
|
||||
public fn void BigInt.destroy(BigInt* bigInt)
|
||||
{
|
||||
free(bigInt.number);
|
||||
}
|
||||
|
||||
func void BigInt.addIgnoreSign(BigInt* a, BigInt* b, BigInt* result)
|
||||
fn void BigInt.addIgnoreSign(BigInt* a, BigInt* b, BigInt* result)
|
||||
{
|
||||
uint length = @max(a.length, b.length) + 1;
|
||||
byte* res = malloc(length);
|
||||
@@ -98,7 +98,7 @@ func void BigInt.addIgnoreSign(BigInt* a, BigInt* b, BigInt* result)
|
||||
result.length = length;
|
||||
}
|
||||
|
||||
public func void BigInt.getMaxVal(BigInt* bigInt, uint* pos, int* val)
|
||||
public fn void BigInt.getMaxVal(BigInt* bigInt, uint* pos, int* val)
|
||||
{
|
||||
for (uint i = bigInt.length; i > 0; i++)
|
||||
{
|
||||
@@ -113,7 +113,7 @@ public func void BigInt.getMaxVal(BigInt* bigInt, uint* pos, int* val)
|
||||
*val = 0;
|
||||
}
|
||||
|
||||
public func char BigInt.compare(BigInt* a, BigInt* b)
|
||||
public fn char BigInt.compare(BigInt* a, BigInt* b)
|
||||
{
|
||||
if (a.sign != b.sign) return a.sign;
|
||||
byte aMax;
|
||||
@@ -130,7 +130,7 @@ public func char BigInt.compare(BigInt* a, BigInt* b)
|
||||
return 0;
|
||||
}
|
||||
|
||||
public func char BigInt.compareNoSign(BigInt* a, BigInt* b)
|
||||
public fn char BigInt.compareNoSign(BigInt* a, BigInt* b)
|
||||
{
|
||||
byte aMax;
|
||||
uint aMaxPos;
|
||||
@@ -146,7 +146,7 @@ public func char BigInt.compareNoSign(BigInt* a, BigInt* b)
|
||||
return 0;
|
||||
}
|
||||
|
||||
func void BigInt.subIgnoreSign(BigInt* a, BigInt* b, BigInt* result)
|
||||
fn void BigInt.subIgnoreSign(BigInt* a, BigInt* b, BigInt* result)
|
||||
{
|
||||
uint length = @max(a.length, b.length);
|
||||
byte* res = malloc(length);
|
||||
@@ -187,7 +187,7 @@ func void BigInt.subIgnoreSign(BigInt* a, BigInt* b, BigInt* result)
|
||||
result.length = length;
|
||||
}
|
||||
|
||||
public func void BigInt.add(BigInt* a, BigInt* b, BigInt* result)
|
||||
public fn void BigInt.add(BigInt* a, BigInt* b, BigInt* result)
|
||||
{
|
||||
if (a.sign == b.sign)
|
||||
{
|
||||
@@ -205,7 +205,7 @@ public func void BigInt.add(BigInt* a, BigInt* b, BigInt* result)
|
||||
}
|
||||
}
|
||||
|
||||
public func char* BigInt.toCharArray(BigInt* bigInt)
|
||||
public fn char* BigInt.toCharArray(BigInt* bigInt)
|
||||
{
|
||||
uint charLen = bigInt.length + 1 + (bigInt.sign < 0 ? 1 : 0);
|
||||
byte* out = malloc(charLen);
|
||||
@@ -227,7 +227,7 @@ public func char* BigInt.toCharArray(BigInt* bigInt)
|
||||
return out;
|
||||
}
|
||||
|
||||
public func void BigInt.print(BigInt* bigInt)
|
||||
public fn void BigInt.print(BigInt* bigInt)
|
||||
{
|
||||
char* chars = bigInt.toCharArray();
|
||||
puts(chars);
|
||||
@@ -244,7 +244,7 @@ public func void BigInt.fprint(BigInt* bigInt, FILE* file)
|
||||
}*/
|
||||
|
||||
|
||||
public func int main(int size, char** args)
|
||||
public fn int main(int size, char** args)
|
||||
{
|
||||
BigInt minus2;
|
||||
BigInt minus1;
|
||||
|
||||
@@ -6,7 +6,7 @@ struct Pixmap
|
||||
int bpp;
|
||||
}
|
||||
|
||||
func void readpgm(char* name, Pixmap* p)
|
||||
fn void readpgm(char* name, Pixmap* p)
|
||||
{
|
||||
/* ... */
|
||||
pnm_readpaminit(fp, &inpam);
|
||||
@@ -28,7 +28,7 @@ func void readpgm(char* name, Pixmap* p)
|
||||
}
|
||||
}
|
||||
|
||||
func void getComm(uint len, char* src)
|
||||
fn void getComm(uint len, char* src)
|
||||
{
|
||||
uint size;
|
||||
size = len - 2;
|
||||
@@ -36,7 +36,7 @@ func void getComm(uint len, char* src)
|
||||
memcpy(comm, src, size);
|
||||
}
|
||||
|
||||
func uint* decode_fh(uint* p, SvcFh* fhp)
|
||||
fn uint* decode_fh(uint* p, SvcFh* fhp)
|
||||
{
|
||||
int size;
|
||||
fh_init(fhp, NFS3_FHSIZE);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
module comparisons;
|
||||
|
||||
func void test_signed()
|
||||
fn void test_signed()
|
||||
{
|
||||
int a = 0;
|
||||
int b = 1;
|
||||
@@ -14,7 +14,7 @@ func void test_signed()
|
||||
|
||||
}
|
||||
|
||||
func void test_unsigned()
|
||||
fn void test_unsigned()
|
||||
{
|
||||
uint a = 0;
|
||||
uint b = 1;
|
||||
@@ -28,9 +28,9 @@ func void test_unsigned()
|
||||
|
||||
}
|
||||
|
||||
extern func void printf(char *s);
|
||||
extern fn void printf(char *s);
|
||||
|
||||
func void test_signedunsigned()
|
||||
fn void test_signedunsigned()
|
||||
{
|
||||
char a = 0 - 1;
|
||||
byte b = (byte)(a);
|
||||
@@ -100,7 +100,7 @@ func void test_signedunsigned()
|
||||
|
||||
}
|
||||
|
||||
func void test_unsignedsigned()
|
||||
fn void test_unsignedsigned()
|
||||
{
|
||||
int b = -1;
|
||||
uint a = (uint)(b);
|
||||
@@ -170,7 +170,7 @@ func void test_unsignedsigned()
|
||||
|
||||
}
|
||||
|
||||
func void main()
|
||||
fn void main()
|
||||
{
|
||||
test_signedunsigned();
|
||||
test_unsignedsigned();
|
||||
|
||||
@@ -13,7 +13,7 @@ public struct BigInt @opaque
|
||||
char sign;
|
||||
}
|
||||
|
||||
public func void BigInt.init(BigInt& bigInt)
|
||||
public fn void BigInt.init(BigInt& bigInt)
|
||||
{
|
||||
bigInt.number = malloc(1);
|
||||
bigInt.number[0] = 0;
|
||||
@@ -21,7 +21,7 @@ public func void BigInt.init(BigInt& bigInt)
|
||||
bigInt.sign = 1;
|
||||
}
|
||||
|
||||
public func void BigInt.initFromString(BigInt& bigInt, char& str)
|
||||
public fn void BigInt.initFromString(BigInt& bigInt, char& str)
|
||||
{
|
||||
uint size = strlen(str);
|
||||
bigInt.sign = 1;
|
||||
@@ -46,14 +46,14 @@ public func void BigInt.initFromString(BigInt& bigInt, char& str)
|
||||
bigInt.length = size;
|
||||
}
|
||||
|
||||
public func BigInt& BigInt.newFromString(char& str)
|
||||
public fn BigInt& BigInt.newFromString(char& str)
|
||||
{
|
||||
BigInt& bigInt = malloc(sizeof(BigInt));
|
||||
bigInt.initFromString(str);
|
||||
return bigInt;
|
||||
}
|
||||
|
||||
public func void BigInt.copyTo(BigInt& source, BigInt& target)
|
||||
public fn void BigInt.copyTo(BigInt& source, BigInt& target)
|
||||
{
|
||||
target.number = realloc(target.number, source.length);
|
||||
target.sign = source.sign;
|
||||
@@ -61,12 +61,12 @@ public func void BigInt.copyTo(BigInt& source, BigInt& target)
|
||||
for (uint i = 0; i < target.length; i++) target.number[i] = source.number[i];
|
||||
}
|
||||
|
||||
public func void BigInt.destroy(BigInt& bigInt)
|
||||
public fn void BigInt.destroy(BigInt& bigInt)
|
||||
{
|
||||
free(bigInt.number);
|
||||
}
|
||||
|
||||
func void BigInt.addIgnoreSign(BigInt& a, BigInt& b, BigInt& result)
|
||||
fn void BigInt.addIgnoreSign(BigInt& a, BigInt& b, BigInt& result)
|
||||
{
|
||||
uint length = @max(a.length, b.length) + 1;
|
||||
byte* res = malloc(length);
|
||||
@@ -105,7 +105,7 @@ func void BigInt.addIgnoreSign(BigInt& a, BigInt& b, BigInt& result)
|
||||
result.length = length;
|
||||
}
|
||||
|
||||
public func void BigInt.getMaxVal(BigInt &bigInt, uint& pos, int& val)
|
||||
public fn void BigInt.getMaxVal(BigInt &bigInt, uint& pos, int& val)
|
||||
{
|
||||
for (uint i = bigInt.length; i > 0; i++)
|
||||
{
|
||||
@@ -120,7 +120,7 @@ public func void BigInt.getMaxVal(BigInt &bigInt, uint& pos, int& val)
|
||||
*val = 0;
|
||||
}
|
||||
|
||||
public func char BigInt.compare(BigInt& a, BigInt& b)
|
||||
public fn char BigInt.compare(BigInt& a, BigInt& b)
|
||||
{
|
||||
if (a.sign != b.sign) return a.sign;
|
||||
byte aMax;
|
||||
@@ -137,7 +137,7 @@ public func char BigInt.compare(BigInt& a, BigInt& b)
|
||||
return 0;
|
||||
}
|
||||
|
||||
public func char BigInt.compareNoSign(BigInt& a, BigInt& b)
|
||||
public fn char BigInt.compareNoSign(BigInt& a, BigInt& b)
|
||||
{
|
||||
byte aMax;
|
||||
uint aMaxPos;
|
||||
@@ -153,7 +153,7 @@ public func char BigInt.compareNoSign(BigInt& a, BigInt& b)
|
||||
return 0;
|
||||
}
|
||||
|
||||
func void BigInt.subIgnoreSign(BigInt& a, BigInt& b, BigInt& result)
|
||||
fn void BigInt.subIgnoreSign(BigInt& a, BigInt& b, BigInt& result)
|
||||
{
|
||||
uint length = @max(a.length, b.length);
|
||||
byte& res = malloc(length);
|
||||
@@ -194,7 +194,7 @@ func void BigInt.subIgnoreSign(BigInt& a, BigInt& b, BigInt& result)
|
||||
result.length = length;
|
||||
}
|
||||
|
||||
public func void BigInt.add(BigInt& a, BigInt& b, BigInt& result)
|
||||
public fn void BigInt.add(BigInt& a, BigInt& b, BigInt& result)
|
||||
{
|
||||
if (a.sign == b.sign)
|
||||
{
|
||||
@@ -212,7 +212,7 @@ public func void BigInt.add(BigInt& a, BigInt& b, BigInt& result)
|
||||
}
|
||||
}
|
||||
|
||||
public func char* BigInt.toCharArray(BigInt* bigInt)
|
||||
public fn char* BigInt.toCharArray(BigInt* bigInt)
|
||||
{
|
||||
uint charLen = bigInt.length + 1 + (bigInt.sign < 0 ? 1 : 0);
|
||||
byte* out = malloc(charLen);
|
||||
@@ -234,7 +234,7 @@ public func char* BigInt.toCharArray(BigInt* bigInt)
|
||||
return out;
|
||||
}
|
||||
|
||||
public func void BigInt.print(BigInt& bigInt)
|
||||
public fn void BigInt.print(BigInt& bigInt)
|
||||
{
|
||||
char* chars = bigInt.toCharArray();
|
||||
puts(chars);
|
||||
@@ -251,7 +251,7 @@ public func void BigInt.fprint(BigInt* bigInt, FILE* file)
|
||||
}*/
|
||||
|
||||
|
||||
public func int main(int size, char*& args)
|
||||
public fn int main(int size, char*& args)
|
||||
{
|
||||
BigInt minus2;
|
||||
BigInt minus1;
|
||||
|
||||
@@ -5,7 +5,7 @@ int bob = 'HELO';
|
||||
|
||||
typedef Foo* as Bob;
|
||||
|
||||
func void testdefer(int x)
|
||||
fn void testdefer(int x)
|
||||
{
|
||||
defer printf("A");
|
||||
defer
|
||||
@@ -67,7 +67,7 @@ struct Simple
|
||||
int i;
|
||||
double j;
|
||||
}
|
||||
func int boo()
|
||||
fn int boo()
|
||||
{
|
||||
Zed zfe;
|
||||
Simple s = { 1 };
|
||||
@@ -148,11 +148,11 @@ func int boo()
|
||||
return 1;
|
||||
}
|
||||
|
||||
func int helo(int i)
|
||||
fn int helo(int i)
|
||||
{
|
||||
return i + 1;
|
||||
}
|
||||
func void while_test()
|
||||
fn void while_test()
|
||||
{
|
||||
|
||||
int a = 10;
|
||||
@@ -164,7 +164,7 @@ func void while_test()
|
||||
}
|
||||
}
|
||||
|
||||
func void test()
|
||||
fn void test()
|
||||
{
|
||||
int a = 10;
|
||||
while (1)
|
||||
@@ -183,7 +183,7 @@ func void test()
|
||||
return;
|
||||
}
|
||||
|
||||
func void main()
|
||||
fn void main()
|
||||
{
|
||||
helo(2);
|
||||
printf("Helo\n");
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
module demo1;
|
||||
|
||||
// Use C functions directly.
|
||||
extern func int printf(char *, ...);
|
||||
extern func void puts(char *);
|
||||
extern fn int printf(char *, ...);
|
||||
extern fn void puts(char *);
|
||||
|
||||
struct Foo
|
||||
{
|
||||
@@ -10,7 +10,7 @@ struct Foo
|
||||
int b;
|
||||
}
|
||||
|
||||
func Foo createFoo(int a, int b = 10)
|
||||
fn Foo createFoo(int a, int b = 10)
|
||||
{
|
||||
// Compound initializer
|
||||
return Foo({a, b});
|
||||
@@ -23,7 +23,7 @@ struct Bar
|
||||
}
|
||||
|
||||
|
||||
func void testStruct()
|
||||
fn void testStruct()
|
||||
{
|
||||
// Default arguments
|
||||
Foo foo = createFoo(100);
|
||||
@@ -47,17 +47,17 @@ func void testStruct()
|
||||
|
||||
}
|
||||
|
||||
func int Bar.add(Bar* b)
|
||||
fn int Bar.add(Bar* b)
|
||||
{
|
||||
return b.x + b.y;
|
||||
}
|
||||
|
||||
func int Foo.mult(Foo* f)
|
||||
fn int Foo.mult(Foo* f)
|
||||
{
|
||||
return f.a * f.b;
|
||||
}
|
||||
|
||||
func void printArray(int[] array)
|
||||
fn void printArray(int[] array)
|
||||
{
|
||||
printf("[");
|
||||
foreach (i, a : array)
|
||||
@@ -69,7 +69,7 @@ func void printArray(int[] array)
|
||||
}
|
||||
|
||||
|
||||
func void testArrays()
|
||||
fn void testArrays()
|
||||
{
|
||||
int[5] x = { [0] = 100, [1..2] = 4 };
|
||||
puts("Testing arrays---");
|
||||
@@ -118,7 +118,7 @@ func void testArrays()
|
||||
printf("Pointer to array: %p\nPointer to slice: %p\nPointer to first element of slice: %p\n", z, &y, &y[0]);
|
||||
}
|
||||
|
||||
func void testExpressionBlocks()
|
||||
fn void testExpressionBlocks()
|
||||
{
|
||||
int x = {|
|
||||
int j = 0;
|
||||
@@ -144,7 +144,7 @@ func void testExpressionBlocks()
|
||||
}
|
||||
}
|
||||
|
||||
func void main()
|
||||
fn void main()
|
||||
{
|
||||
testStruct();
|
||||
testArrays();
|
||||
|
||||
@@ -11,7 +11,7 @@ struct Foo
|
||||
|
||||
//define bar::blub(Foo, 1) as fooblub;
|
||||
|
||||
public func void main()
|
||||
public fn void main()
|
||||
{
|
||||
Foo f = { 3, 4 };
|
||||
//Foo g = fooblub(&f);
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
module bar(Type, i);
|
||||
|
||||
public func Type blub(Type type)
|
||||
public fn Type blub(Type type)
|
||||
{
|
||||
type.x = i;
|
||||
return type;
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
module helloworld;
|
||||
|
||||
extern func void printf(char *str, ...);
|
||||
extern fn void printf(char *str, ...);
|
||||
|
||||
func void main()
|
||||
fn void main()
|
||||
{
|
||||
printf("Hello World!\n");
|
||||
}
|
||||
@@ -11,7 +11,7 @@ struct Boo
|
||||
};
|
||||
}
|
||||
|
||||
func void test()
|
||||
fn void test()
|
||||
{
|
||||
int i = 0;
|
||||
i++;
|
||||
|
||||
@@ -68,7 +68,7 @@ error Errors
|
||||
OTHER_ERROR
|
||||
}
|
||||
|
||||
func Foom test(int a)
|
||||
fn Foom test(int a)
|
||||
{
|
||||
while (int x = 0, int y = 3; int y = foo())
|
||||
{
|
||||
@@ -85,7 +85,7 @@ func Foom test(int a)
|
||||
return 1 + 2;
|
||||
}
|
||||
|
||||
func boo::Bar zab::Baz.sd(die::Eij i) throws Zab // , sij:Zig
|
||||
fn boo::Bar zab::Baz.sd(die::Eij i) throws Zab // , sij:Zig
|
||||
{
|
||||
float a = 0, b = 3, double c = 1, d;
|
||||
int i = 0;
|
||||
@@ -111,20 +111,20 @@ generic boor2(i)
|
||||
|
||||
$if ($e > 0)
|
||||
{
|
||||
func void foo() {}
|
||||
fn void foo() {}
|
||||
}
|
||||
$elif ($e < 0)
|
||||
{
|
||||
func void foo() { printf("HELO"); }
|
||||
fn void foo() { printf("HELO"); }
|
||||
}
|
||||
$else
|
||||
{
|
||||
func void foo() { printf("OLEH"); }
|
||||
fn void foo() { printf("OLEH"); }
|
||||
}
|
||||
|
||||
$if ($e > 0)
|
||||
{
|
||||
func void foo() {}
|
||||
fn void foo() {}
|
||||
}
|
||||
|
||||
$if ($b > 0)
|
||||
@@ -151,7 +151,7 @@ generic boofer2(i, g, eok)
|
||||
|
||||
|
||||
|
||||
func void hello() throws Errors
|
||||
fn void hello() throws Errors
|
||||
{
|
||||
int i, j;
|
||||
throw FOO;
|
||||
@@ -229,11 +229,11 @@ func void hello() throws Errors
|
||||
}
|
||||
|
||||
typedef Foo* as Bar;
|
||||
typedef func void(int, Foo*) as Zoo;
|
||||
typedef fn void(int, Foo*) as Zoo;
|
||||
|
||||
|
||||
|
||||
func void test2()
|
||||
fn void test2()
|
||||
{
|
||||
return;
|
||||
}
|
||||
@@ -26,11 +26,11 @@ void* gWindow = null;
|
||||
void* gScreenSurface = null;
|
||||
|
||||
|
||||
extern func int init(uint flags) @extname("SDL_Init");
|
||||
extern func int initSubSystem(uint flags) @extname("SDL_InitSubSystem");
|
||||
extern func void quitSubSystem(uint flags) @extname("SDL_QuitSubSystem");
|
||||
extern func uint wasInit(uint flags) @extname("SDL_WasInit");
|
||||
extern func void quit() @extname("SDL_Quit");
|
||||
extern fn int init(uint flags) @extname("SDL_Init");
|
||||
extern fn int initSubSystem(uint flags) @extname("SDL_InitSubSystem");
|
||||
extern fn void quitSubSystem(uint flags) @extname("SDL_QuitSubSystem");
|
||||
extern fn uint wasInit(uint flags) @extname("SDL_WasInit");
|
||||
extern fn void quit() @extname("SDL_Quit");
|
||||
|
||||
enum SDLWindowFlags : c_int
|
||||
{
|
||||
@@ -59,13 +59,13 @@ enum SDLWindowFlags : c_int
|
||||
VULKAN = 0x10000000 /**< window usable for Vulkan surface */
|
||||
}
|
||||
|
||||
extern func void* createWindow(char *title, uint x, uint y, int w, int h, uint flags) @extname("SDL_CreateWindow");
|
||||
extern func void* getWindowSurface(void *window) @extname("SDL_GetWindowSurface");
|
||||
extern fn void* createWindow(char *title, uint x, uint y, int w, int h, uint flags) @extname("SDL_CreateWindow");
|
||||
extern fn void* getWindowSurface(void *window) @extname("SDL_GetWindowSurface");
|
||||
const uint WINDOWPOS_UNDEFINED_MASK = 0x1FFF0000;
|
||||
extern func int exit(int code);
|
||||
extern func int printf(char *mess, ...);
|
||||
extern fn int exit(int code);
|
||||
extern fn int printf(char *mess, ...);
|
||||
|
||||
func bool initX()
|
||||
fn bool initX()
|
||||
{
|
||||
//Initialization flag
|
||||
bool success = true;
|
||||
@@ -86,7 +86,7 @@ func bool initX()
|
||||
}
|
||||
|
||||
|
||||
func void close()
|
||||
fn void close()
|
||||
{
|
||||
//Destroy window
|
||||
// SDL_DestroyWindow( gWindow );
|
||||
@@ -96,8 +96,8 @@ func void close()
|
||||
quit();
|
||||
}
|
||||
|
||||
extern func int pollEvent(SDL_Event *event) @extname("SDL_PollEvent");
|
||||
extern func int updateWindowSurface(void *window) @extname("SDL_UpdateWindowSurface");
|
||||
extern fn int pollEvent(SDL_Event *event) @extname("SDL_PollEvent");
|
||||
extern fn int updateWindowSurface(void *window) @extname("SDL_UpdateWindowSurface");
|
||||
|
||||
enum SDLEventType : uint
|
||||
{
|
||||
@@ -223,7 +223,7 @@ union SDL_Event
|
||||
|
||||
const uint SDL_QUIT = 0x100;
|
||||
|
||||
func int main(int argc, char** args)
|
||||
fn int main(int argc, char** args)
|
||||
{
|
||||
initX();
|
||||
//Main loop flag
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import std::io;
|
||||
|
||||
extern func int printf(char* message, ...);
|
||||
extern fn int printf(char* message, ...);
|
||||
|
||||
macro void swap(&a, &b)
|
||||
{
|
||||
@@ -9,7 +9,7 @@ macro void swap(&a, &b)
|
||||
b = temp;
|
||||
}
|
||||
|
||||
func void main()
|
||||
fn void main()
|
||||
{
|
||||
int x = 1;
|
||||
int y = 2;
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
module foo;
|
||||
|
||||
extern func void printf(char *hello, ...);
|
||||
extern fn void printf(char *hello, ...);
|
||||
|
||||
error MyError;
|
||||
error YourError;
|
||||
func void main()
|
||||
fn void main()
|
||||
{
|
||||
int! i = 1;
|
||||
catch (i)
|
||||
|
||||
@@ -1,19 +1,19 @@
|
||||
|
||||
extern func void printf(char* message, ...);
|
||||
extern fn void printf(char* message, ...);
|
||||
|
||||
public func void defer1() {}
|
||||
public func void defer2() {}
|
||||
public func void defer3() {}
|
||||
public func void defer4() {}
|
||||
public func void defer5() {}
|
||||
public func void defer6() {}
|
||||
public func void defer7() {}
|
||||
public func void defer8() {}
|
||||
public func void defer9() {}
|
||||
public func void defer10() {}
|
||||
public func void defer11() {}
|
||||
public fn void defer1() {}
|
||||
public fn void defer2() {}
|
||||
public fn void defer3() {}
|
||||
public fn void defer4() {}
|
||||
public fn void defer5() {}
|
||||
public fn void defer6() {}
|
||||
public fn void defer7() {}
|
||||
public fn void defer8() {}
|
||||
public fn void defer9() {}
|
||||
public fn void defer10() {}
|
||||
public fn void defer11() {}
|
||||
|
||||
public func int main(int argc)
|
||||
public fn int main(int argc)
|
||||
{
|
||||
int a = 0;
|
||||
{
|
||||
|
||||
@@ -10,7 +10,7 @@ struct String
|
||||
char* ptr;
|
||||
}
|
||||
|
||||
func void String.init(String *s, char[] c)
|
||||
fn void String.init(String *s, char[] c)
|
||||
{
|
||||
s.capacity = c.len + 16;
|
||||
s.ptr = mem::_malloc(s.capacity);
|
||||
@@ -18,7 +18,7 @@ func void String.init(String *s, char[] c)
|
||||
mem::copy(s.ptr, (char*)(c), c.len);
|
||||
}
|
||||
|
||||
func char* String.zstr(String *s)
|
||||
fn char* String.zstr(String *s)
|
||||
{
|
||||
char* c = mem::_malloc(s.len + 1);
|
||||
mem::copy(c, s.ptr, s.len);
|
||||
@@ -26,7 +26,7 @@ func char* String.zstr(String *s)
|
||||
return c;
|
||||
}
|
||||
|
||||
func void String.appendc(String *s, char c)
|
||||
fn void String.appendc(String *s, char c)
|
||||
{
|
||||
if (s.capacity == s.len)
|
||||
{
|
||||
@@ -38,7 +38,7 @@ func void String.appendc(String *s, char c)
|
||||
s.ptr[s.len++] = c;
|
||||
}
|
||||
|
||||
func void String.append(String *s, char[] other_string)
|
||||
fn void String.append(String *s, char[] other_string)
|
||||
{
|
||||
if (s.capacity < s.len + other_string.len)
|
||||
{
|
||||
@@ -55,7 +55,7 @@ func void String.append(String *s, char[] other_string)
|
||||
s.len += other_string.len;
|
||||
}
|
||||
|
||||
func void String.concat(String *s, String* other_string)
|
||||
fn void String.concat(String *s, String* other_string)
|
||||
{
|
||||
if (s.capacity < s.len + other_string.len)
|
||||
{
|
||||
@@ -72,7 +72,7 @@ func void String.concat(String *s, String* other_string)
|
||||
s.len += other_string.len;
|
||||
}
|
||||
|
||||
func void main()
|
||||
fn void main()
|
||||
{
|
||||
String s;
|
||||
s.init("Hello");
|
||||
|
||||
@@ -2,7 +2,7 @@ module topologicalsort;
|
||||
import std::mem;
|
||||
import std::array;
|
||||
|
||||
extern func void printf(char* x, ...);
|
||||
extern fn void printf(char* x, ...);
|
||||
|
||||
struct InputPair
|
||||
{
|
||||
@@ -23,7 +23,7 @@ struct TopoList
|
||||
}
|
||||
|
||||
|
||||
func void sort(InputPair[] pairs, uint elements)
|
||||
fn void sort(InputPair[] pairs, uint elements)
|
||||
{
|
||||
InputPair[] result = @array::make(InputPair, pairs.len);
|
||||
TopoList* top = @array::make(TopoList, elements);
|
||||
@@ -70,7 +70,7 @@ func void sort(InputPair[] pairs, uint elements)
|
||||
}
|
||||
}
|
||||
|
||||
func void main()
|
||||
fn void main()
|
||||
{
|
||||
InputPair[10] pairs = {
|
||||
{ 9, 2 },
|
||||
|
||||
Reference in New Issue
Block a user