mirror of
https://github.com/c3lang/c3c.git
synced 2026-02-27 12:01:16 +00:00
190 lines
2.7 KiB
Plaintext
190 lines
2.7 KiB
Plaintext
module bar;
|
|
|
|
typedef int as Bob;
|
|
|
|
|
|
struct Test
|
|
{
|
|
int a;
|
|
}
|
|
|
|
struct Test2
|
|
{
|
|
Test t;
|
|
int b;
|
|
}
|
|
|
|
union Test3
|
|
{
|
|
long eo;
|
|
Test t;
|
|
int b;
|
|
}
|
|
|
|
func int boba(int y, int j)
|
|
{
|
|
Test2 bar;
|
|
bar.b = 1;
|
|
//int w = y ? y : j;
|
|
int x = y * 2;
|
|
int z = j;
|
|
while (j > 10)
|
|
{
|
|
z--;
|
|
x = x + z * 2;
|
|
}
|
|
return x;
|
|
}
|
|
func int test(int x)
|
|
{
|
|
Test3 foekf;
|
|
Test oef;
|
|
Test2 foek;
|
|
int i = x;
|
|
Bob foo = x;
|
|
Bob fe = 0;
|
|
fe++;
|
|
switch (fe + 1)
|
|
{
|
|
case 1:
|
|
i = i + 1;
|
|
next;
|
|
case 3:
|
|
case 2:
|
|
i = i + 2;
|
|
case 5:
|
|
default:
|
|
i = i * 100;
|
|
case 7:
|
|
}
|
|
i++;
|
|
int y = i--;
|
|
return y;
|
|
}
|
|
|
|
func int test3()
|
|
{
|
|
if (test() < 0) return -1;
|
|
return 5;
|
|
}
|
|
|
|
|
|
typedef func void(int) as Foo;
|
|
//typedef int as Foo;
|
|
func void printf(char *hello);
|
|
|
|
macro @hello()
|
|
{
|
|
printf("Hello world!\n");
|
|
}
|
|
|
|
func void bob()
|
|
{
|
|
byte a = 2;
|
|
short b = 3;
|
|
int c = 4;
|
|
bool eok = true;
|
|
long deee = (eok ? a : b) + c;
|
|
}
|
|
|
|
func int main(int x)
|
|
{
|
|
Test2 efe;
|
|
efe.t.a = 3;
|
|
if (efe.t.a > 2) printf("Works!\n");
|
|
int ef = 3;
|
|
int *eff = &ef;
|
|
eff[0] = 4;
|
|
byte *ex = cast(byte *, eff);
|
|
ex[0] = 5;
|
|
if (eff[0] == 5) printf("Works-5!\n");
|
|
ex[1] = 5;
|
|
if (eff[0] == 5 + 5 * 256) printf("Works-5*256!\n");
|
|
if (ef == 4) printf("Works5!\n");
|
|
if (ef == 4) printf("Works1!\n");
|
|
ef = 0;
|
|
/*
|
|
byte a = 2;
|
|
short b = 3;
|
|
int c = 4;
|
|
bool eok = true;
|
|
long deee = (eok ? a : b) + (eok ? b : c);*/
|
|
int i = 0;
|
|
JUMP:
|
|
i = i + 1;
|
|
//@hello();
|
|
printf("Hello worldABC" "D" "E\u2701\n");
|
|
float f = 3.0;
|
|
float* pf = &f;
|
|
switch (i)
|
|
{
|
|
case 0:
|
|
printf("c0\n");
|
|
case 1:
|
|
printf("c1\n");
|
|
case 2:
|
|
printf("c2\n");
|
|
case 3:
|
|
printf("c3\n");
|
|
default:
|
|
printf("default\n");
|
|
}
|
|
if (*pf > i) goto JUMP;
|
|
goto EX;
|
|
YEF:
|
|
return 4;
|
|
EX:
|
|
printf("EX\n");
|
|
goto YEF;
|
|
}
|
|
|
|
func void test2(int* x, int y, int z)
|
|
{
|
|
z = 0;
|
|
z ? y : z;
|
|
x += 1;
|
|
y += z;
|
|
x -= 1;
|
|
y -= z;
|
|
y *= 2;
|
|
y /= 2;
|
|
y /= *x;
|
|
y |= 2;
|
|
y ^= 2;
|
|
y &= 2;
|
|
z ^ y;
|
|
z | y;
|
|
int g = z & y;
|
|
g <<= 2;
|
|
g <<= z;
|
|
g >>= 2;
|
|
g >>= z;
|
|
int fz = 100;
|
|
y && z;
|
|
y || z;
|
|
y >> z;
|
|
z << y;
|
|
~z;
|
|
!z;
|
|
-z;
|
|
|
|
int i = 3;
|
|
uint ui = 2;
|
|
int j = 129;
|
|
float f = 23.2;
|
|
f = f + 1.0;
|
|
f = f - 1.0;
|
|
f = f * 2.0;
|
|
f = f / 3.0;
|
|
i = i * 2;
|
|
ui = ui * 2;
|
|
i = i / 2;
|
|
ui = ui / 2;
|
|
i = i + 1;
|
|
ui = ui + 1;
|
|
i = i - 1;
|
|
ui = ui - 1;
|
|
x + 1;
|
|
int j1 = x[0];
|
|
j1 = *x;
|
|
} |