Click here to Skip to main content
15,895,084 members
Articles / High Performance Computing / Vectorization

Bird Programming Language: Part 1

Rate me:
Please Sign up or sign in to vote.
4.92/5 (129 votes)
1 Jan 2013GPL312 min read 383.6K   2.7K   153  
A new general purpose language that aims to be fast, high level and simple to use.
rem
	command in command
	asm command
	vec, long ops
	unnessesary casting params, return value
	GetNodePos() -> GetExprCode()
	x86Compiler.MoveData() SSEReg -> GReg

	cast nodes
	x86 func scope
	TypeMgrPlugIn: Assignment
	x86NodeData.Input
	.Constructor
	ref assignvar
	new parameters
	TypeMgr, Compiler plugin node replacing

	Optimizations:
		swap
		index op
		loop unwinding
		a = 10; print a -> print 10
		same func args
		var in eax
		use lea
		vars in same pos
		MoveCondBranch with Casting
		struct align 16
		imul 3
		vars in fpu regs
		push long arg after sub add
		for loops: dec reg, jnz lbl

	TODO:
		function overloading
		func param def
		goto only outer
		multi-line expr conds
		x64

		?. op					| var obj = valami?.a?.b ' ha egyik null akkor obj = null
		?: op					| var obj = valami ?: "sdfdf" ' ha null, akkor sdfdf, egyébként valami
								| var obj = valami ?null "sdfdf"
		in op					| x in { 1, 3, 5 } ' not { 1, 3, 5 }.Contains(x)
		
void VarInExpr(int a)
	if (var b = a * 2) > 10
		VarInExpr b
		b++
		VarInExpr b
	else
		VarInExpr b + 1
		
bool Test1232(int x, y)
	return x == y and Test1232(x - 1, y - 2)

void Test123(int x)
	for var a = 0 until x
		if a == 10 then break

long Add(long A, long B)
	var Z = A + B
	return Z * Z

uint FloatToUnsigned(float f)
	return (uint)f

float UnsignedToFloat(uint i)
	return (float)i
		
int Main(int x)
	int d

	if x < 0 then d = 1
	else if x > 0 then d = -1
	else d = 0

	return d

void CastingTest(int* pInt)
	var pByte = (byte*)pInt

	pInt[0] = 345
	pByte[2] = 23b
	void* pVoid = pByte + 3
	
int Fib(int x)
	if x < 2 then return 1
	else return Fib(x - 1) + Fib(x - 2)

#define min(x, y) if x < y then x else y
#define max(x, y) if x < y then x else y

int MacroTest(int x, y)
	var m = min(x, y)
	var ma = max(x, y)
	return ma / m

bool Func(int Number)
	while Number > 9
		var Ossz = 0
		while Number <> 0
			Ossz += Number % 10
			Number /= 10

		Number = Ossz

	return Number == 0	

int TestF(int x)
	if 0 < TestF(x) * 2 < 10 then return 0
	else return x
		
int Main456(int x)
	'(var a = x * 2) < 10

	if (var a = x * 2) < 10 then return 0
	else if (var b = x * 2) < 20 then return 1
	else if (var c = x * 2) < 30 then return 2
	else return c
	
int Test2(int x)
	return Test2(x) * 2

int Test456(int x)
	return Test456(x) * 2
	x = 10

int ElseIfTest(int x)
	if x == 0 then return 0
	else if x == 1 then return 1
	else if x == 2 then return 2
	else return -1
		
float Zero = 0, One = 1 

#define MACRO(x, y) x * y + x
int Test456456(int x, y, z)
	if (x > 0 and y > 0) or x == y
		return MACRO(x + z, y)
	else
		return MACRO(x, y + z)
				
int CantBeTest(int a)
	return CantBeTest(if 0 < CantBeTest(a) < 10 then 0 else a)

float ByteToFloat(byte a)
	return a

byte FloatToByte(float a)
	return (byte)a

float Testert(int x)
	int y = x
	return y

float FltCastTest(int x)
	return x + x

int FltCastTest2(float x)
	return (int)x

bool FltTst(float x, y)
	return x == y

float FloatTest(float x, y)
	if x == y then return 0
	return (float)((x + y) * pi)

double FloatTest2(float x)
	return FloatTest((float)x, (float)x * 2)

int DivTest(int x, y)
	return x / y

int LocalVarTest(int x, y)
	var a = x + y
	var b = x * y
	var c = x - y
	var d = x / y
	var e = x * y

	return (a + b) * (c + d) * e
	
void SetVar(int* p, int From, Count)
	var pVar = p

	for int i = 0 until Count
		pVar[i] = From + i
		
void SetVar2(int* pVar, int From, Count)
	for int i = 0 until Count
		pVar[i] = From + i

int ShlTest(int x)
	return x * 8

int ShrTest(int x)
	return x / 8

void PointerTest(int* pInt, int x, y)
	var p2Int = &pInt[2]
	pInt = null

int CantBeTest2(int a)
	return if 0 < CantBeTest2(a) < 10 then 0 else a

bool Test(int x, y, dif)
	return -dif <= x - y <= dif

byte Test123123(byte x)
	return (byte)((x + 1b) * 123b)

byte ByteTest(byte x, y)
	return (((((x - y) + (x - y)) - ((x - y) + (x - y))) + (((x - y) + (x - y)) - ((x - y) + (x - y)))) - ((((x - y) + (x - y)) - ((x - y) + (x - y))) + (((x - y) + (x - y)) - ((x - y) + (x - y))))) + (((((x - y) + (x - y)) - ((x - y) + (x - y))) + (((x - y) + (x - y)) - ((x - y) + (x - y)))) - ((((x - y) + (x - y)) - ((x - y) + (x - y))) + (((x - y) + (x - y)) - ((x - y) + (x - y)))))

int Test24(int x)
	var Ret = x
	Test24 Ret
	return Ret

int Test22345()
	var Ret = 0
	for int x = 1 to 10
		Ret += x % 4
	
	Test22345
	return Ret

bool Prim(int x)
	for var a = 2 until x
		if x % a == 0 then return false

	return true 

int Test5(int x, y)
	return ((x * y) + (x * y)) - ((x * y) + (x * y))

int Test4(int x)
	return Fib(Fib(Fib(10)))

int Test345(int x, y, z)
	return (x + y) * (y - z)

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The GNU General Public License (GPLv3)


Written By
Software Developer
Hungary Hungary
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions