// already I am eating from this trashcan
// define ordinary module
mod example {
pub struct nothing {
x: i32,
y: f64[],
z: i32[1:10, 9:17],
end: i32,
}
pub fn f(x: i32, y: &f64[]; z: bool = true) -> str {
// WOW
// use-before declare: we need to catch this
let f: str = "it's got the same name as the function!";
let money: currency = 12345.6789currency;
let more_money: currency = money * 10000;
print more_money;
// need deferred type resolution...
let s: nothing;
s.x = 17;
// s.f(23);
// s.end = 92.3;
// s.begin = 17;
let end: f64 = 17, lbound: f64 = end;
// while loop
while x < 17 {
x = x + 1;
x += 3;
f @= " haha";
/*
print other_mod::y[x]; // Debug.Print
other_mod::z @= "whatever";
*/
}
let v: var = nullptr;
v = 23;
v = nullptr;
let o: obj = nullptr;
return "lo siento";
}
// = Private Sub
fn do_something(x: /* ByRef Long */ &i32) {
let y: i32, z: str = "string literal";
if x != 7 {
x /= 2; // inferred integer divide
}
for i: i32 = x > 7 ? 23 : 5 : 7 : 1 {
// brutal
// n.b. bug here in pre-visitor gensym pass
for j: i32 = x : 10 {
print i;
print j;
x = x / j;
}
}
let o: obj;
// we're still gensymming the parameter...
for x: obj in o.arr {
// this doesn't get renamed because we don't have a memberdef anywhere
// for lbound, which I guess I'm ok with
x.lbound(3);
print x;
}
if x != 2 && `Application.WorksheetFunction("SIN", 7)` > 3 {
print "what";
}
`Debug.Print "hi mom"`; // literal VBA
}
// pub fn f() {}
}
mod more_examples {
fn is_null(o: obj) -> bool {
return o === nullptr;
}
fn is_db_null(v: var) -> bool {
return v == nullvar;
}
fn retobj() -> obj {
let Sheet1: obj;
if 9 > 7 {
return nullptr;
} else if 1 != 23 {
return Sheet1.Range("B3");
} else {
return Sheet1.Range("A1");
}
}
fn objasvar() -> var {
if true {
return nullptr;
} else {
return 7;
}
}
fn arrays() {
let x: i32[10];
let y: obj[];
let z: example::nothing[2:17];
z[3].x = 22;
// z[3].blah = 899;
for i: i32 = `LBound(x)` : `UBound(x)` {
print x[i];
}
let weird_str: str = "You're not\tmy \"supervisor\"";
print retobj() !== retobj();
let matrix: i32[10, 10];
// it's a VB keyword
other_mod::input(matrix);
let res: bool = other_mod::fun2(x, y, z);
}
}
mod other_mod {
pub fn input(xs: &i32[,]) {
xs[1, 2] = 3;
}
pub fn fun2(x: &i32[], y: &obj[], z: &example::nothing[]) -> bool {
return true;
}
pub fn weird(weird: bool) -> bool {
if weird(weird) {
return !!!weird;
} else {
return weird;
}
defbool::dummy();
}
}
// conflicting name
mod defbool {
pub fn dummy() { }
}