www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.announce - dnet - a D compiler to target the CLR (.Net / Mono)

reply Tim Matthews <tim.matthews7 gmail.com> writes:
dnet. D frontend (dmd 2.036). CLR backend.

It is in a very alpha like state and this is just a callout for 
developers to work on this compiler. Not for anyone intending to 
immediately target the CLR with D.

Cristi Vlasceanu wrote most of the backend code but he was always 
finding increasingly less time to work on it with new employment 
opportunities. I have been trying to keep this project alive but I may 
not be able to give full commitment either.

C++ developers wanted. Maybe other roles too.

A few things are working, for example a Quine:

module io;

import System;
import System.IO;

void main()
{
     String s = File.ReadAllText("./io.d".sys);
     Console.WriteLine(s);
}


compiling this with "dnet io.d" produces io.il:

//--------------------------------------------------------------
// io.d compiled: Mon Dec 21 09:58:42 2009
//--------------------------------------------------------------
.assembly extern 'System'
{
   .publickeytoken = (b7 7a 5c 56 19 34 e0 89 )
   .ver 2:0:0:0
}
.assembly extern 'System.Configuration'
{
   .publickeytoken = (b0 3f 5f 7f 11 d5 0a 3a )
   .ver 2:0:0:0
}
.assembly extern 'System.Drawing'
{
   .publickeytoken = (b0 3f 5f 7f 11 d5 0a 3a )
   .ver 2:0:0:0
}
.assembly extern 'System.Security'
{
   .publickeytoken = (b0 3f 5f 7f 11 d5 0a 3a )
   .ver 2:0:0:0
}
.assembly extern 'System.Windows.Forms'
{
   .publickeytoken = (b7 7a 5c 56 19 34 e0 89 )
   .ver 2:0:0:0
}
.assembly extern 'System.Xml'
{
   .publickeytoken = (b7 7a 5c 56 19 34 e0 89 )
   .ver 2:0:0:0
}
.assembly extern 'mscorlib'
{
   .publickeytoken = (b7 7a 5c 56 19 34 e0 89 )
   .ver 2:0:0:0
}
.assembly extern dnetlib {}
.assembly 'io' {}
.module 'io'

//--------------------------------------------------------------
// main program
//--------------------------------------------------------------
.method public hidebysig static void '_Dmain' ()
{
   .entrypoint
   .maxstack 2
   .locals init (
     [0] string 's' /* refcount=2 */
   )
   call class [mscorlib]System.Text.Encoding 
[mscorlib]System.Text.Encoding::get_UTF8()
   ldstr "./io.d"
   callvirt instance uint8[] 
[mscorlib]System.Text.Encoding::GetBytes(string)
   call string [dnetlib]runtime.dnet::'sys' (unsigned int8 [])
   call string [mscorlib]System.IO.File::'ReadAllText' (string)
   stloc.s 0	// 's' (string)
   ldloc.0	// 's' (string)
   call void [mscorlib]System.Console::'WriteLine' (string)
   ret
}


the dnet compiler then automatically calls ilasm on this file to produce 
io.exe.
Dec 20 2009
next sibling parent reply dsimcha <dsimcha yahoo.com> writes:
Quick question:  Will D .net allow for the use of regular Phobos I/O
functionality
instead of the .net versions if one prefers?  If basic I/O functionality isn't
compatible between D .net and other implementations of D, then for all practical
purposes they will be different languages.
Dec 20 2009
parent Tim Matthews <tim.matthews7 gmail.com> writes:
On 21/12/2009 10:42 a.m., dsimcha wrote:
 Quick question:  Will D .net allow for the use of regular Phobos I/O
functionality
 instead of the .net versions if one prefers?  If basic I/O functionality isn't
 compatible between D .net and other implementations of D, then for all
practical
 purposes they will be different languages.

No. Currently it cannot use any native code. It would be nice to have eventually in the future the D equivalent of http://en.wikipedia.org/wiki/C%2B%2B/CLI. Some developers find C++/CLI very awkward with all the extra syntax for GC code but as D is a GC language it should fit nicely. A native-managed bridge could also be made. This would probably simpler but less than ideal.
Dec 20 2009
prev sibling parent reply Tim Matthews <tim.matthews7 gmail.com> writes:
Sorry I forgot the link :)

http://github.com/tim-m89/dnet
Dec 20 2009
parent reply Joel Christensen <joelcnz gmail.com> writes:
Is it like what these people are doing?
http://dnet.codeplex.com/
Dec 20 2009
parent Tim Matthews <tim.matthews7 gmail.com> writes:
On 21/12/2009 7:08 p.m., Joel Christensen wrote:
 Is it like what these people are doing?
 http://dnet.codeplex.com/

That's Cristi Vlasceanu's original code. http://github.com/tim-m89/dnet is the fork I created. He has become overwhelmed with work issues and not being able to find the time to apply my patches. Then when he asked if I would like to take more control I chose a separate git based repo.
Dec 20 2009