Named function args
This commit is contained in:
181
ideas.cpp
181
ideas.cpp
@@ -1,170 +1,33 @@
|
||||
Thing :: struct{
|
||||
data: (U32) U32; // Function pointer
|
||||
data: (U32) U32 @ [32]; // Array of function pointers
|
||||
data: (U32) U32* @ [32]; // Array of function pointers, they return a pointer
|
||||
|
||||
actual_function :: (first: Thing*, last: Thing*, node: Thing*)/*no type == void*/{
|
||||
if first == 0 {
|
||||
first = last = node;
|
||||
}
|
||||
else{
|
||||
last = last->next = node;
|
||||
}
|
||||
}
|
||||
|
||||
StructInside :: struct { // This is not part of struct
|
||||
// just in scope
|
||||
some_val: U16;
|
||||
some_val2: U16;
|
||||
}
|
||||
|
||||
insider: StructInside;
|
||||
|
||||
named_union_part_of_struct: union{
|
||||
some_val: U16;
|
||||
some_val2: U32;
|
||||
}
|
||||
|
||||
_: union {
|
||||
// Unamed union
|
||||
val: U32;
|
||||
}
|
||||
|
||||
New_Data_Type::typedef int;
|
||||
CONST_VAL::const 324;
|
||||
|
||||
Ideas::enum{
|
||||
One,
|
||||
Two,
|
||||
Three
|
||||
}
|
||||
|
||||
Scope :: scope{
|
||||
Thingy::enum:U32{
|
||||
@str=10 Value = 1,
|
||||
|
||||
}
|
||||
Data::struct{
|
||||
first: int;
|
||||
second: int;
|
||||
idea: Ideas;
|
||||
}
|
||||
|
||||
//Scope.Thingy
|
||||
|
||||
Thing::union{
|
||||
union:{
|
||||
}
|
||||
struct:{
|
||||
function_call::(first_param: Data*, second_param: int[32]){
|
||||
first_param.first = 10;
|
||||
first_param.second = 10;
|
||||
first_param.idea = Ideas.One;
|
||||
p:= first_param;
|
||||
|
||||
for i in 0...32 {
|
||||
second_param[i] = i;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Thing::struct{
|
||||
data: U32;
|
||||
|
||||
inside_call :: (param: U32){
|
||||
for i := 0; i < 32; i++ {
|
||||
second_param[i] = i;
|
||||
}
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
call :: (param:U32) U32{
|
||||
inner_call :: (param2:U32){
|
||||
size_of_s64 = sizeof(:S64);
|
||||
size_of_val = sizeof(param);
|
||||
|
||||
|
||||
param2 + 10;
|
||||
return;
|
||||
}
|
||||
|
||||
inner_call();
|
||||
}
|
||||
|
||||
@stringify
|
||||
Enumeration:enum{
|
||||
None,
|
||||
Thing = 1 << 10,
|
||||
Thing2,
|
||||
Thing3,
|
||||
}
|
||||
|
||||
@sllqueue()
|
||||
@sllqueue(prefix=thing_scope, next=next_scope)
|
||||
Thing::struct{
|
||||
Inner_Struct :: {
|
||||
test_val : U32;
|
||||
}
|
||||
thing:Inner_Struct;
|
||||
next: Thing*;
|
||||
first: Thing*;
|
||||
last: Thing*;
|
||||
next_scope: Thing*;
|
||||
|
||||
val: U32[16];
|
||||
str: String;
|
||||
embed: struct{
|
||||
thing: S32;
|
||||
}
|
||||
}
|
||||
|
||||
@register(sllqueue, first, last, next)
|
||||
sllqueue_push:(base:T1, child:T2) void {
|
||||
if(base.first == 0){
|
||||
base.first = base.last = child;
|
||||
}
|
||||
else{
|
||||
base.last = base.last.next = child;
|
||||
}
|
||||
}
|
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
//
|
||||
//-----------------------------------------------------------------------------
|
||||
/*
|
||||
function void
|
||||
thing_sllqueue_push(){
|
||||
|
||||
}
|
||||
|
||||
function void
|
||||
thing_scope_sllqueue_push(){
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
Builtin types:
|
||||
B8,B16,B32,B64
|
||||
S8,S16,S32,S64
|
||||
U8,U16,U32,U64
|
||||
SizeI, SizeU
|
||||
F32, F64
|
||||
|
||||
Decls:
|
||||
S32 *var;
|
||||
S32 (*func)();
|
||||
S32 *var[expr][expr];
|
||||
S32 **var;
|
||||
|
||||
Global scope:
|
||||
function S32
|
||||
do_thing(S32 a, U32 b){
|
||||
stmt_list
|
||||
}
|
||||
|
||||
function S32
|
||||
do_thing(S32 a, S32 b);
|
||||
|
||||
typedef struct Thing Thing;
|
||||
struct Thing{};
|
||||
typedef struct Thing{} Thing;
|
||||
|
||||
typedef enum Thingy Thingy;
|
||||
enum Thingy{};
|
||||
typedef enum Thingy{} Thingy;
|
||||
|
||||
global S32 variable = expr | compound;
|
||||
|
||||
// typedef S32 NewName;
|
||||
// typedef S32 BaseFunctionType(S32 thing);
|
||||
// typedef S32 (*FunctionPointer)(S32 thing);
|
||||
|
||||
Local scope-(stmts):
|
||||
S32 variable = expr;
|
||||
variable = expr;
|
||||
variable++;
|
||||
return 0;
|
||||
if(a){}elseif(b){}else{}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user