wraith-lang/example.w

70 lines
1.1 KiB
OpenEdge ABL
Raw Normal View History

2021-05-03 07:06:54 +00:00
interface Increments
{
Increment(): void;
}
2021-04-28 23:01:48 +00:00
struct YourStruct
{
yourInt: int;
2021-05-03 07:06:54 +00:00
IncrementOther<T: Increments>(other: T): void
{
other.Increment();
}
2021-04-28 23:01:48 +00:00
}
struct MyStruct
{
myInt: int;
myBool: bool;
yourStructReference: Reference<YourStruct>;
yourStruct: YourStruct;
Increment(): void
{
myInt = myInt + 1;
}
2021-04-29 19:42:51 +00:00
Decrement(): void
{
myInt = myInt - 1;
}
2021-04-28 23:01:48 +00:00
static MyFunction(input: int): int
{
return input * 2;
}
}
struct Program
{
static Main(): int
{
myStruct: MyStruct;
myReference: Reference<MyStruct>;
myInt: int;
myReference = alloc MyStruct;
myInt = MyStruct.MyFunction(2);
myStruct.myInt = myInt;
myStruct.Increment();
2021-04-29 04:25:25 +00:00
if (myStruct.myInt < 5)
{
myStruct.Increment();
}
2021-04-29 22:26:30 +00:00
else if (myStruct.myInt > 10)
2021-04-29 19:42:51 +00:00
{
myStruct.Decrement();
}
2021-04-29 22:26:30 +00:00
else
{
myStruct.myInt = 4;
}
2021-04-29 04:25:25 +00:00
2021-04-28 23:01:48 +00:00
return myStruct.myInt;
}
}