Fixed bug that would intermittently arise from multiple contexts having the same pointer (should preferably be fixed in a different way later). Free all the arenas before codegen. Change "next" to "nextcase". Allow missing function parameters. Add "inline" structs.

This commit is contained in:
Christoffer Lerno
2021-01-03 00:15:51 +01:00
parent 781638d207
commit 564c93700e
28 changed files with 427 additions and 192 deletions

View File

@@ -0,0 +1,36 @@
module antiprime;
import std::io;
extern func int printf(char* message, ...);
func int countDivisors(int n)
{
if (n < 2) return 1;
int count = 2;
for (int i = 2; i <= n / 2; i++)
{
if (n % i == 0) count++;
}
return count;
}
func int main()
{
int maxDiv;
int count;
io::println("The first 20 anti-primes are:");
int n = 1;
while (count < 20)
{
int d = countDivisors(n);
if (d > maxDiv)
{
printf("%d ", n);
maxDiv = d;
count++;
}
n++;
}
io::println("");
return 0;
}

View File

@@ -0,0 +1,7 @@
import std::io;
func int main()
{
io::println("Hello world");
return 0;
}