|
Is the correct answer - you are up tomorrow!
Nice and straightforward!
"I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
AntiTwitter: @DalekDave is now a follower!
|
|
|
|
|
So I parsed that 8000+ line source file i threw at Slang, and then I rebuilt the tree, and spit out VB all in about 5-10 seconds, which isn't too bad considering what a monster it is.
The VB code is nasty looking because it's declaring arrays with 100s of elements on a single line
But it should work. It's all valid codedom constructs.
There's still work to be done on it but I think i'm at or almost at the point where I can start using it in my own projects.
I'm looking forward to never having to touch the actual codedom tree again, but I can't believe how difficult it was to resolve the tree.
I had to load assemblies and types, and crawl using reflect AND crawl the codedom looking for fields, properties, methods, signatures and return types.
In order to even know which methods were what I had to do SIGNATURE MATCHING. Do you have any idea what that entails? Never underestimate the work your compiler does for you. Jeez that's hard.
All this so I can call GetTypeOfExpression() on a codedom expression. What if the expression is a method call? what if it's one of several overloaded methods each with a different return type? I had to get it right.
This is probably the most extensively I've ever used reflection in a single project.
But the worst part wasn't even reflection. It was *emulating* reflection over the codedom.
If any of you know what I'm talking about here, then that last line should give you pause.
Yes, I did that. It was necessary.
But I feel pretty cool right now.
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
|
|
|
|
|
OMG! Are you the hidden herald of the VBpocalypse?!
|
|
|
|
|
If anything I just gave people less of a reason to write any code in VB. Just write it in Slang and translate it. That way you can stick to C#
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
|
|
|
|
|
Phew.. I feared the worst for a moment!
|
|
|
|
|
Frankly, I'd be more interested in rendering to F# than VB but their CodeDOM is new and still dodgy so I haven't been able to build it.
I can try the nuget package again now that I moved away from .NET standard/code (there are codedom dependency issues I could bore you with)
But eventually i'll have it rendering in other languages too. It's just that VB and C# are what are shipped with .NET so it's what I have installed.
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
|
|
|
|
|
Well... you can always try C++/CLI?! It's supported by .NET Core 3.1!
|
|
|
|
|
It's probably possible to build a CodeDOM renderer for it but I'd be more inclined to build a CodeDOM renderer for IL.
Any C++ code rendered from the CodeDOM will be hopelessly OO and crappy for C++
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
|
|
|
|
|
|
Actually yes. Combined with slang it would let you write IL in a C# subset.
However, it wouldn't support generating all IL instructions, and you can do the same thing with a real C# compiler + IL Spy
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
|
|
|
|
|
honey the codewitch wrote: and you can do the same thing with a real C# compiler + IL Spy
yeah, that's why I do, once every few years.. and then I forget all I learn doing it!
modified 11-Dec-19 0:55am.
|
|
|
|
|
honey the codewitch wrote: Just write it in Slang and translate it
Yo, sup honey? How 'bout you add dem numbers, yo! Translating...
int Add(int a, int b)
{
return a + b;
}
|
|
|
|
|
Where's the CodeDOM provider for LOLCODE[^]?
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
honey the codewitch wrote: Just write it in Slang and translate it
Why bother translating it? Are there any constructs that exist in VB and are not available in C#?
(I thought that you were writing a code translator that makes CodeDom easier to use, not a C#-to-VB translator.)
Freedom is the freedom to say that two plus two make four. If that is granted, all else follows.
-- 6079 Smith W.
|
|
|
|
|
Because my code generation tools don't dictate what language you have to generate the code in.
My code generators are not C# only.
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
|
|
|
|
|
honey the codewitch wrote: But I feel pretty cool right now
You should.
I don't know codedom, and don't think I will get the reason to, but if it's anything similar to learning expressions I can appreciate the level of your achievement.
I'm quite convinced I couldn't have done it in the time you have. If at all.
|
|
|
|
|
In some ways it's similar territory. However,
Expressions lib in .NET only handles expressions, not statements, nor type, field and method declarations. It also renders to IL.
The codedom does not render to IL (though i'm thinking of making a codedom for that) but it renders to one of X target languages (stock C# or VB but extensible), and it handles expressions, statements, types - basically entire groups of code "files" meant for the compiler.
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
|
|
|
|
|
|
That's cool. Still, I can't render whole programs with it.
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
|
|
|
|
|
Ha, I bet you could if you tried hard enough.
Yes, it would probable be the wrong tool. But still...
|
|
|
|
|
Could you make a version that I could write something in Fortran-77 and convert it to C#?
I only ask because I used to really enjoy writing in FORTRAN in the old days, but perhaps that was more because of what I was writing than what I was writing it in, hmmm... (An expert system for flight test analysis of jet fighters - whooooosh!)
Not really serious - just wondering.
- I would love to change the world, but they won’t give me the source code.
|
|
|
|
|
Probably not. The trouble is the runtime libraries are entirely different. If it weren't for .net languages all sharing the same BCL this wouldn't be feasible at all.
When I was growin' up, I was the smartest kid I knew. Maybe that was just because I didn't know that many kids. All I know is now I feel the opposite.
|
|
|
|
|
I wasn't really serious (but..?).
I am very impressed with your project as, I think, many other here are.
- I would love to change the world, but they won’t give me the source code.
|
|
|
|
|
My condolences.
#SupportHeForShe
Government can give you nothing but what it takes from somebody else. A government big enough to give you everything you want is big enough to take everything you've got, including your freedom.-Ezra Taft Benson
You must accept 1 of 2 basic premises: Either we are alone in the universe or we are not alone. Either way, the implications are staggering!-Wernher von Braun
|
|
|
|
|
The more I read about your endeavors (and better yet, accomplishments), the more I'm wondering why you're not on MS's payroll, showing them how to make VS not suck so much.
Although I do understand you were with them for a while...?
|
|
|
|