воскресенье, 25 февраля 2018 г.

Change syntax

myrec=record
a:integer;
method ab2<T>(a:T);static;
method ab1(a:integer):integer;static;
method ab1(a:string);
method ab1<T>(a:integer):T;
end;

понедельник, 19 декабря 2011 г.

Moscow and SAP

Now, working in Moscow.
SAP, ABAP, JAVA, Javascript, VBA.

P.S. at night I'm working on YAR.

суббота, 16 апреля 2011 г.

четверг, 24 февраля 2011 г.

Parallel front-end, Units and other tasks

Now working on 5 tasks

1. Support Units.
2. Forward types using without predeclaring.
3. Cross units references resolving with cycles too.
4. Parallel front-end to process units simultaneously.
5. Extend .NET back-end to support units.

четверг, 3 февраля 2011 г.

Changes to POINTERMATH

Now the operator[] of typed pointer returns the dereferenced pointer to type(ref to value).

Thanks to DiamondShark.

A sample

program myprogram;

procedure pf < T> (cnt:integer);
p:pointer;
ptype:^T;
valueA:T;
i:integer;
begin
GetMem(p,cnt*sizeof(T));
ptype:=p;
for i:=0 to cnt-1 do ptype[i]:=valueA;
FreeMem(p);
end;

begin
pf < boolean> (100);
pf < integer> (200);
pf < double> (300);
end

среда, 2 февраля 2011 г.

Getmem, Freemem, Pointer math

YAR language is enhanced by supporting Getmem, Freemem and pointer math.
Sample

program myprogram;

procedure dosample();
p:pointer;
pinteger:^integer;
i:integer;
begin
GetMem(p,400);
pinteger:=p;
for i:=0 to 99 do pinteger[i]^:=i;
for i:=0 to 99 do write pinteger[i]^;
FreeMem(p);
end;

begin
dosample();
end

вторник, 25 января 2011 г.

понедельник, 24 января 2011 г.

Mutable string and pinned managed objects

Added String type to YAR

sample

program myprogram;

procedure abc();
a:string;
i:integer;
begin
a:='abcdefghij';
for i:=0 to a.length()-1 do a[i]:='1';
write a;
end;

begin
abc();
end

=>

.assembly extern mscorlib { auto }
.assembly project {}
.method public static void main() cil managed
{
.entrypoint
call void abc()
ret
}
.method public static void abc() cil managed
{
.locals init(int32 _autoname0,string pinned a,int32 i)
ldstr "abcdefghij"
stloc a
ldc.i4 0
stloc i
ldloc a
callvirt instance int32 [mscorlib]System.String::get_Length()
ldc.i4 1
sub
stloc _autoname0
Label0:
ldloc i
ldloc _autoname0
cgt
brtrue Label1
ldloc a
conv.i
call int32 [mscorlib]System.Runtime.CompilerServices.RuntimeHelpers::get_OffsetToStringData()
add
ldloc i
ldc.i4 2
mul
add
conv.i
ldc.i4 49
stobj char
ldloc i
ldc.i4 1
add
stloc i
br Label0
Label1:
ldloc a
call void [mscorlib]System.Console::Write(string)
ret
}

среда, 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
}

понедельник, 8 ноября 2010 г.

Added @ and ^ operators

I have just added.

begin
pinteger:=@mr.c;
a:=pinteger^;
mr.c:=@a^;
end

=>

.entrypoint
ldsflda valuetype Myrecord mr
ldflda int32 Myrecord::c
stsfld int32* pinteger
ldsfld int32* pinteger
ldobj int32
stsfld int32 a
ldsflda valuetype Myrecord mr
ldsflda int32 a
ldobj int32
stfld int32 Myrecord::c
ret

среда, 3 ноября 2010 г.

Test YAR Type inference

Todays working sample

function abc < T,U > (a:T):^U;
begin
end

pinteger:^integer;
d:double;

pinteger:=abc(d);

=> T=double
=> U=integer

So generic operators like @, [], sizeof .. to come very soon.

вторник, 2 ноября 2010 г.

YAR and Type inference

Working on support Type Inference in YAR.
A sample:

mr:Myrecord;
a,b:integer;
d:double;

function GenericFunc < T, U , Z> (var a:T;b:U):Z;
begin
end;
..
begin
GenericFunc(a,a):=d; //I know this function result is not a lvalue.
//I relax the assign op type checking rules
//to test of infering of result type

среда, 27 октября 2010 г.

Процесс рефакторинга

Сам по себе процесс продвигался достаточно безболезненно, однако долго.
Приятно, что планируемые изменения в целом концептуально гладко уложились с текущей структурой компилятора. Однако переименование типов и небольшое изменение их зоны отвественности("утрясание" иерархий классов) отняли большую часть времени. Но в целом остался доволен, хотя и утомительное это занятие заниматься не делом.

вторник, 12 октября 2010 г.

Время для рефакторинга

Достаточно сложно считать на несколько шагов вперед, хотя и очень интересно. Не всегда удается выбрать баланс между выразительностью и скоростью на ранних этапах, да и просто порой принятые решения по проектированию на ранних этапах в меньшей степени предусмотрены для задач для более поздних. Хотя технически работать можно и в рамках текущих проектных решений, однако это требует лишних движений, что отвлекает от решения текущих подзадач.

четверг, 7 октября 2010 г.

Added Procedural Types

Added procedural Types to YAR Language
Extend .NET codegen by MSIL calli instruction

Sample

TMyFunc=function(a:integer):integer;
TXfunc=function(var a:double):TMyFunc;

function abc(a:integer):integer;
begin
result:=a;
end;

function abc(var a:double):TMyFunc;
begin
result:=abc;
end;

e:double;
f:integer;
g:TXfunc;

begin
g:=abc;
f:=g(e)(f);
end

=>

.method static public void main() cil managed
{
.entrypoint
ldftn native int abc(float64& a)
stsfld native int g
ldsfld int32 f
ldsflda float64 e
ldsfld native int g
calli native int (float64& a)
calli int32 (int32 a)
stsfld int32 f
ret
}

вторник, 5 октября 2010 г.

Supporting dot operator for .NET backend

A sample

program Helloworld;

MyrecordStuff=record
a:integer;
b:integer;
c:boolean;
d:double;
f:double;
end;

Myrecord=record
a,b,c:integer;
private
d:integer;
f:integer;
public
pp:MyrecordStuff;
end;

function abc(var a:integer):integer;
begin
a:=1;
result:=5;
end;

function abc(var a:MyrecordStuff):integer;
begin
a.a:=7;
result:=5;
end;

a,b,c,d:Myrecord;
e:double;
f:integer;
begin
abc(a.a);
abc(a.pp.a);
e:=a.pp.d;
a.pp.a:=f;
a.pp.a:=a.pp.b;
write abc(a.pp);
write a.pp.a;
end

Generated MSIL code


.assembly extern mscorlib { auto }
.assembly project {}
.class public sealed MyrecordStuff extends [mscorlib]System.ValueType
{
.field public static int32 b
.field public static float64 f
.field public static int32 a
.field public static bool c
.field public static float64 d
}
.class public sealed Myrecord extends [mscorlib]System.ValueType
{
.field private static int32 f
.field private static int32 d
.field public static int32 b
.field public static int32 a
.field public static int32 c
.field public static valuetype MyrecordStuff pp
}
.field public static valuetype Myrecord b
.field public static float64 e
.field public static valuetype Myrecord a
.field public static int32 f
.field public static valuetype Myrecord c
.field public static valuetype Myrecord d

.method static public void main() cil managed
{
.entrypoint
ldsflda valuetype Myrecord a
ldflda int32 Myrecord::a
call int32 abc(int32& a)
pop
ldsflda valuetype Myrecord a
ldflda valuetype MyrecordStuff Myrecord::pp
ldflda int32 MyrecordStuff::a
call int32 abc(int32& a)
pop
ldsflda valuetype Myrecord a
ldflda valuetype MyrecordStuff Myrecord::pp
ldfld float64 MyrecordStuff::d
stsfld float64 e
ldsflda valuetype Myrecord a
ldflda valuetype MyrecordStuff Myrecord::pp
ldsfld int32 f
stfld int32 MyrecordStuff::a
ldsflda valuetype Myrecord a
ldflda valuetype MyrecordStuff Myrecord::pp
ldsflda valuetype Myrecord a
ldflda valuetype MyrecordStuff Myrecord::pp
ldfld int32 MyrecordStuff::b
stfld int32 MyrecordStuff::a
ldsflda valuetype Myrecord a
ldflda valuetype MyrecordStuff Myrecord::pp
call int32 abc( valuetype MyrecordStuff& a)
call void [mscorlib]System.Console::Write(int32)
ldsflda valuetype Myrecord a
ldflda valuetype MyrecordStuff Myrecord::pp
ldfld int32 MyrecordStuff::a
call void [mscorlib]System.Console::Write(int32)
ret
}

.method static public int32 abc(int32& a) cil managed
{
ldarg a
ldc.i4 1
stind.i4
ldc.i4 5
ret
}

.method static public int32 abc( valuetype MyrecordStuff& a) cil managed
{
ldarg a
ldc.i4 7
stfld int32 MyrecordStuff::a
ldc.i4 5
ret
}