среда, 22 декабря 2010 г.

YAR: Added explicit type cast

a:integer;
d:double;

begin
...
d:=a; //Implicit
d:=double(a); //Explicit

But! I am still thinking about the syntax for declaring new implicit or explicit operators: Delphi or Free Pascal like. :)

YAR: Enhance syntax of [ ] array operator

Now support [.. , ..]

A sample

integerarrarr:Myrecord[6][3][5][3][3][6];

integerarrarr[1,1,2][1][1,2].c[1]:=abc().a;

вторник, 7 декабря 2010 г.

YAR and static arrays

Working on support static arrays in YAR.
The shortest sample

program Helloworld;

integerarr:integer[6];

begin
integerarr[2]:=1;
end

=>

.assembly extern mscorlib { auto }
.assembly project {}
.field public static int32* integerarr

.method static public void main() cil managed
{
.entrypoint
ldc.i4 28
localloc
stsfld int32* integerarr
ldsfld int32* integerarr
ldc.i4 2
ldc.i4 4
mul
add
ldc.i4 1
stind.i4
ret
}

воскресенье, 5 декабря 2010 г.

YAR Update: Importing external function

Yar supports now for

import external functions

sample

program Helloworld;

function importedfunc(var a:integer):integer;external library=mydll name=importfunc;

GField:integer;

begin
GField:=1;
write importedfunc(GField);
end

=>

.assembly extern mscorlib { auto }
.assembly project {}
.field public static int32 GField

.method static public void main() cil managed
{
.entrypoint
ldc.i4 1
stsfld int32 GField
ldsflda int32 GField
call int32 importedfunc(int32& a)
call void [mscorlib]System.Console::Write(int32)
ret
}

.method public static pinvokeimpl("mydll.dll" as "importfunc" winapi)
int32 importedfunc(int32& a) cil managed preservesig
{}

пятница, 3 декабря 2010 г.

YAR: records with methods

Syntax:

program Helloworld;

Myrecord=record
c:integer;
function abc(a:integer):integer;
begin
self.c:=a;
result:=self.c;
end;
end;

mr:Myrecord;

function Func(var a:Myrecord):integer;
begin
a.c:=4;
write mr.c;
a.abc(5);
write a.c;
result:=6;
end;

begin
Func(mr);
end

.NET BackEnd:

.assembly extern mscorlib { auto }
.assembly project {}
.class public sealed Myrecord extends [mscorlib]System.ValueType
{
.field public static int32 c
.method public instance int32 abc(int32 a) cil managed
{
ldarg.0
ldarg a
stfld int32 .this::c
ldarg.0
ldfld int32 .this::c
ret
}
}
.field public static valuetype Myrecord mr

.method static public void main() cil managed
{
.entrypoint
ldsflda valuetype Myrecord mr
call int32 Func( valuetype Myrecord& a)
pop
ret
}

.method static public int32 Func( valuetype Myrecord& a) cil managed
{
ldarg a
ldc.i4 4
stfld int32 Myrecord::c
ldsflda valuetype Myrecord mr
ldfld int32 Myrecord::c
call void [mscorlib]System.Console::Write(int32)
ldarg a
ldc.i4 5
call instance int32 Myrecord::abc(int32 a)
pop
ldarg a
ldfld int32 Myrecord::c
call void [mscorlib]System.Console::Write(int32)
ldc.i4 6
ret
}