Page 1 of 1

Inline CIL-assembler

PostPosted: Fri Feb 03, 2012 11:55 pm
by Zmeeed
Is it possible? If no, I am satisfied with any less-level (compared to Cobra) language: C, C++, and even the C#.

Re: Inline CIL-assembler

PostPosted: Sat Feb 04, 2012 12:16 am
by Charles
We have "C# strings" which can be used wherever an expression is expected:
s = 'cobra'
n = sharp's.Length * 2' to int
trace n

The sharp string contents get passed to the C# back-end compiler as-is. Since Cobra does not understand the contents, it's not uncommon to provide a type cast like you see above ("to int").

Sharp strings are primarily an escape hatch for when we need a workaround for some issue. If you find yourself needing this, let me know. Maybe there is a Cobra way or maybe Cobra needs improvement.

If you're looking for dynamic, run-time code gen, look for the open source Cecil library.