48 lines
890 B
OpenEdge ABL
48 lines
890 B
OpenEdge ABL
struct Foo {
|
|
static Func2<U>(u: U) : U {
|
|
return u;
|
|
}
|
|
|
|
static Func<T>(t: T): T {
|
|
foo: T = t;
|
|
return Foo.Func2(foo);
|
|
}
|
|
}
|
|
|
|
struct MemoryBlock<T>
|
|
{
|
|
start: MemoryAddress;
|
|
capacity: uint;
|
|
|
|
AddressOf(index: uint): MemoryAddress
|
|
{
|
|
return start + (index * @sizeof<T>());
|
|
}
|
|
|
|
Get(index: uint): T
|
|
{
|
|
return @bitcast<T>(AddressOf(index));
|
|
}
|
|
|
|
Free(): void
|
|
{
|
|
@free(start);
|
|
}
|
|
}
|
|
|
|
struct Program {
|
|
static Main(): int {
|
|
x: int = 4;
|
|
y: int = Foo.Func(x);
|
|
block: MemoryBlock<uint>;
|
|
block.capacity = y;
|
|
block.start = @malloc(y * @sizeof<int>());
|
|
z: MemoryAddress = block.AddressOf(2);
|
|
Console.PrintLine("%u", block.Get(0));
|
|
Console.PrintLine("%p", block.start);
|
|
Console.PrintLine("%p", z);
|
|
block.Free();
|
|
return 0;
|
|
}
|
|
}
|