Last active
October 5, 2017 08:42
-
-
Save adler3d/98cc3717f8ec01828c9c4c7833d6fb9d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
struct i_type{TSelfPtr<SelfClass> self;}; | |
//struct t_string:i_type{}; | |
struct t_bit:i_type{}; | |
struct t_autoptr:i_type{TWeakPtr<i_type> elem_type;}; | |
struct t_weakptr:i_type{TWeakPtr<i_type> elem_type;}; | |
struct t_selfptr:i_type{TWeakPtr<i_type> elem_type;}; | |
struct t_vector:i_type{TWeakPtr<i_type> elem_type;}; | |
struct t_field{ | |
TWeakPtr<i_type> type; | |
}; | |
struct t_struct:i_type{ | |
TWeakPtr<t_struct> parent; | |
vector<t_field> fields; | |
}; | |
vector<t_vector> vecs; | |
vector<t_struct> structs; | |
vecs.resize($); | |
structs.resize($); | |
QAP_FOREACH(vecs,ex.elem_type=&any_elem_of(bit,structs,vecs)); | |
QAP_FOREACH(structs,ex.parent=$?&structs[$]:nullptr); | |
QAP_FOREACH(structs,for(;$;)qap_add_back(ex.fields).type=&any_elem_of(bit,structs,vecs);); | |
struct t_foo{ | |
string name; | |
int z; | |
}; | |
TTypeStruct::TField f=Sys$$<t_foo>::GetType()->fields[0]; | |
t_foo foo; foo.name="cool"; | |
int z=f.z; | |
t_foo::field_z_type z=foo.z; | |
string bar(auto param){ ... }; | |
string s=bar(foo.z); // s = "typeof(param) = t_foo::z" + "\n" + "parent_obj_of(param).name = 'cool'"; | |
//V2 | |
struct t_struct_without_parent:i_type{ | |
struct t_field{ | |
TWeakPtr<i_type> type; // can point to t_struct, but only t_struct_without_parent aviable; = poor design | |
}; | |
vector<t_field> fields; | |
}; | |
vector<t_vector> vecs; | |
vector<t_struct_without_parent> swp; | |
vector<t_struct> structs; | |
//V3 | |
struct t_struct:i_type{ | |
struct t_field{ | |
TWeakPtr<i_type...> type; | |
}; | |
vector<t_field...> fields; | |
}; | |
//example as user story | |
struct t_bar{}; | |
struct t_foo{ | |
t_bar bar; | |
}; | |
generated from: | |
qap_add_back(structs); | |
qap_add_back(qap_add_back(structs).fields).type=context.get_struct_type_by_id(0); | |
binary representation: | |
vec.size=0 | |
swp.size=2 | |
swp[0].fields.size=0 | |
swp[1].fields.size=1 | |
swp[1].fields[1].type=0 | |
structs.size=0 | |
t_struct_foo{ | |
t_field_bar{bitset<$> type;} | |
t_field_bar bar; | |
}; | |
// const object at compile time as concrete type | |
auto t_foo_where_name_is_cool_and_z_is_5=code_scope(){ | |
t_foo foo; | |
foo.name='cool' | |
foo.z=5; | |
}.typeof(foo); | |
sizeof(t_foo_where_name_is_cool_and_z_is_5)==0; | |
t_foo_where_name_is_cool_and_z_is_5 tmp; | |
tmp.name=='cool'; | |
tmp.z==5; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment