QL code and tests for C#/C++/JavaScript.

This commit is contained in:
Pavel Avgustinov
2018-08-02 17:53:23 +01:00
commit b55526aa58
10684 changed files with 581163 additions and 0 deletions

View File

@@ -0,0 +1,52 @@
struct BoxedInt {
BoxedInt(int x) {
m_ptr = new int(x);
}
~BoxedInt() {
delete m_ptr;
}
operator int() {
return *m_ptr;
}
int* m_ptr;
};
void if_decl_bind(int x) {
if(BoxedInt bi = x) {
++*bi.m_ptr;
}
else {
--*bi.m_ptr;
}
x = 1;
}
void switch_decl_bind(int x) {
switch(BoxedInt bi = x) {
case 0:
--*bi.m_ptr;
break;
case 1:
++*bi.m_ptr;
break;
default:
*bi.m_ptr /= 2;
/* no break -- this is important */
}
x = 1;
}
void while_decl_bind(int x) {
while(BoxedInt bi = x) {
--x;
}
++x;
}
void for_decl_bind(int x) {
for(BoxedInt init = -x; BoxedInt bi = x; x *= 2) {
++x;
}
--x;
}