本文整理汇总了C#中CodeGen类的典型用法代码示例。如果您正苦于以下问题:C# CodeGen类的具体用法?C# CodeGen怎么用?C# CodeGen使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
CodeGen类属于命名空间,在下文中一共展示了CodeGen类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: Emit
public override void Emit(CodeGen cg) {
//EmitLocation(cg);
_value.EmitAsObject(cg);
cg.EmitCodeContext();
cg.EmitSymbolId(_name);
cg.EmitCall(typeof(RuntimeHelpers), "SetNameReorder");
}
开发者ID:JamesTryand,项目名称:IronScheme,代码行数:7,代码来源:UnboundAssignment.cs
示例2: Emit
public override void Emit(CodeGen cg)
{
bool eoiused = false;
Label eoi = cg.DefineLabel();
foreach (IfStatementTest t in _tests) {
Label next = cg.DefineLabel();
if (t.Test.Span.IsValid)
{
cg.EmitPosition(t.Test.Start, t.Test.End);
}
t.Test.EmitBranchFalse(cg, next);
t.Body.Emit(cg);
// optimize no else case
if (IsNotIfOrReturn(t.Body))
{
eoiused = true;
cg.Emit(OpCodes.Br, eoi);
}
cg.MarkLabel(next);
}
if (_else != null) {
_else.Emit(cg);
}
if (eoiused)
{
cg.MarkLabel(eoi);
}
}
开发者ID:robertlj,项目名称:IronScheme,代码行数:32,代码来源:IfStatement.cs
示例3: EmitGet
internal override void EmitGet(CodeGen g)
{
int[] bits = decimal.GetBits(value);
byte exponent = unchecked((byte)((bits[3] >> 16) & 0x1f));
bool sign = bits[3] < 0;
if (exponent == 0 && bits[2] == 0)
{
if (bits[1] == 0 && (bits[0] > 0 || (bits[0] == 0 && !sign))) // fits in int32 - use the basic int constructor
{
g.EmitI4Helper(sign ? -bits[0] : bits[0]);
g.IL.Emit(OpCodes.Newobj, decimalIntConstructor);
return;
}
if (bits[1] > 0) // fits in int64
{
long l = unchecked((long)(((ulong)(uint)bits[1] << 32) | (ulong)(uint)bits[0]));
g.IL.Emit(OpCodes.Ldc_I8, sign ? -l : l);
g.IL.Emit(OpCodes.Newobj, decimalLongConstructor);
return;
}
}
g.EmitI4Helper(bits[0]);
g.EmitI4Helper(bits[1]);
g.EmitI4Helper(bits[2]);
g.EmitI4Helper(sign ? 1 : 0);
g.EmitI4Helper(exponent);
g.IL.Emit(OpCodes.Newobj, decimalExtConstructor);
}
开发者ID:amithasan,项目名称:Framework-Class-Library-Extension,代码行数:30,代码来源:DecimalLiteral.cs
示例4: Emit
public override void Emit(CodeGen cg)
{
//cg.EmitPosition(Start, End);
// expression needs to be emitted incase it has side-effects.
var ex = Expression.Unwrap(_expression);
ex.EmitAs(cg, typeof(void));
}
开发者ID:robertlj,项目名称:IronScheme,代码行数:7,代码来源:ExpressionStatement.cs
示例5: Emit
public override void Emit(CodeGen cg) {
if (_typeOperand.IsAssignableFrom(_expression.Type)) {
// if its always true just emit the bool
cg.EmitConstant(true);
return;
}
_expression.EmitAsObject(cg);
EmitLocation(cg);
cg.Emit(OpCodes.Isinst, _typeOperand);
cg.Emit(OpCodes.Ldnull);
cg.Emit(OpCodes.Cgt_Un);
if (ScriptDomainManager.Options.LightweightDebugging)
{
if (!cg.IsDynamicMethod)
{
var s = SpanToLong(Span);
cg.EmitConstant(s);
cg.EmitCall(Debugging.DebugMethods.ExpressionOut);
}
}
}
开发者ID:JamesTryand,项目名称:IronScheme,代码行数:26,代码来源:TypeBinaryExpression.cs
示例6: Emit
public override void Emit(CodeGen cg)
{
if (_statement != null)
{
_statement.Emit(cg);
}
}
开发者ID:robertlj,项目名称:IronScheme,代码行数:7,代码来源:VoidExpression.cs
示例7: Emit
public override void Emit(CodeGen cg) {
if (_valueTypeType != null)
{
EmitLocation(cg);
cg.EmitMissingValue(_valueTypeType); // seems ok?
}
else
{
for (int i = 0; i < _parameterInfos.Length; i++)
{
_arguments[i].Emit(cg);
if (_arguments[i].Type != _parameterInfos[i].ParameterType && _arguments[i].Type.IsValueType && typeof(SymbolId) != _arguments[i].Type)
{
cg.EmitBoxing(_arguments[i].Type);
}
}
EmitLocation(cg);
cg.EmitNew(_constructor);
}
if (ScriptDomainManager.Options.LightweightDebugging && Span.IsValid)
{
cg.EmitConstant(SpanToLong(Span));
cg.EmitCall(Debugging.DebugMethods.ExpressionOut);
}
}
开发者ID:JamesTryand,项目名称:IronScheme,代码行数:26,代码来源:NewExpression.cs
示例8: EmitGet
public override void EmitGet(CodeGen cg)
{
// RuntimeHelpers.LookupName(context, name)
_frame.EmitGet(cg);
cg.EmitSymbolId(_name);
cg.EmitCall(typeof(RuntimeHelpers), "LookupName");
}
开发者ID:robertlj,项目名称:IronScheme,代码行数:7,代码来源:LocalNamedFrameSlot.cs
示例9: EmitGet
protected internal override void EmitGet(CodeGen g)
{
OperandExtensions.SetLeakedState(this, false);
int[] bits = decimal.GetBits(_value);
byte exponent = unchecked((byte)((bits[3] >> 16) & 0x1f));
bool sign = bits[3] < 0;
Type intType = g.TypeMapper.MapType(typeof(int));
if (exponent == 0 && bits[2] == 0)
{
if (bits[1] == 0 && (bits[0] > 0 || (bits[0] == 0 && !sign))) // fits in int32 - use the basic int constructor
{
g.EmitI4Helper(sign ? -bits[0] : bits[0]);
g.IL.Emit(OpCodes.Newobj, (ConstructorInfo)g.TypeMapper.MapType(typeof(decimal)).GetConstructor(new Type[] { intType }));
return;
}
if (bits[1] > 0) // fits in int64
{
long l = unchecked((long)(((ulong)(uint)bits[1] << 32) | (ulong)(uint)bits[0]));
g.IL.Emit(OpCodes.Ldc_I8, sign ? -l : l);
g.IL.Emit(OpCodes.Newobj, (ConstructorInfo)g.TypeMapper.MapType(typeof(decimal)).GetConstructor(new Type[] { g.TypeMapper.MapType(typeof(long)) }));
return;
}
}
g.EmitI4Helper(bits[0]);
g.EmitI4Helper(bits[1]);
g.EmitI4Helper(bits[2]);
g.EmitI4Helper(sign ? 1 : 0);
g.EmitI4Helper(exponent);
g.IL.Emit(OpCodes.Newobj, (ConstructorInfo)g.TypeMapper.MapType(typeof(decimal)).GetConstructor(
new Type[] { intType, intType, intType, g.TypeMapper.MapType(typeof(bool)), g.TypeMapper.MapType(typeof(byte)) }));
}
开发者ID:AqlaSolutions,项目名称:runsharp,代码行数:33,代码来源:DecimalLiteral.cs
示例10: Emit
public override void Emit(CodeGen cg)
{
if (Span.IsValid)
{
cg.EmitPosition(Start, End);
if (ScriptDomainManager.Options.LightweightDebugging)
{
if (!cg.IsDynamicMethod)
{
var s = SpanToLong(Span);
cg.EmitConstant(s);
cg.EmitCall(Debugging.DebugMethods.ExpressionInTail); // not really but will do for LW debugger
}
}
}
if (_statement != null) {
cg.CheckAndPushTargets(_statement);
}
cg.EmitContinue();
if (_statement != null) {
cg.PopTargets();
}
}
开发者ID:robertlj,项目名称:IronScheme,代码行数:27,代码来源:ContinueStatement.cs
示例11: EmitGet
internal override void EmitGet(CodeGen g)
{
op.EmitGet(g);
foreach (OpCode oc in opCodes)
g.IL.Emit(oc);
}
开发者ID:amithasan,项目名称:Framework-Class-Library-Extension,代码行数:7,代码来源:SimpleOperation.cs
示例12: EmitGet
internal override void EmitGet(CodeGen g)
{
Operand before = g.Local(target);
baseOp.SetOperand(before);
target.EmitSet(g, baseOp, false);
before.EmitGet(g);
}
开发者ID:jimmmeh,项目名称:runsharp,代码行数:7,代码来源:PostfixOperation.cs
示例13: EmitDerivation
public IEnumerable<Instruction> EmitDerivation(MethodDef method, ConfuserContext ctx, Local dst, Local src) {
var ret = new List<Instruction>();
var codeGen = new CodeGen(dst, src, method, ret);
codeGen.GenerateCIL(derivation);
codeGen.Commit(method.Body);
return ret;
}
开发者ID:EmilZhou,项目名称:ConfuserEx,代码行数:7,代码来源:DynamicDeriver.cs
示例14: Emit
public override void Emit(CodeGen cg)
{
// RuntimeHelpers.RemoveName(CodeContext, name)
cg.EmitCodeContext();
cg.EmitSymbolId(_name);
cg.EmitCall(typeof(RuntimeHelpers), "RemoveName");
}
开发者ID:robertlj,项目名称:IronScheme,代码行数:7,代码来源:DeleteUnboundExpression.cs
示例15: FixReturn
public void FixReturn(CodeGen cg)
{
_argSlot.EmitGet(cg);
_refSlot.EmitGet(cg);
cg.EmitCall(typeof(BinderOps).GetMethod("GetBox").MakeGenericMethod(_argSlot.Type.GetElementType()));
cg.EmitStoreValueIndirect(_argSlot.Type.GetElementType());
}
开发者ID:robertlj,项目名称:IronScheme,代码行数:7,代码来源:ReturnFixer.cs
示例16: Execute
public override bool Execute()
{
var codegen = new CodeGen();
if (SchemaFiles != null)
{
foreach (var schemaFile in SchemaFiles)
{
var schema = Schema.Parse(System.IO.File.ReadAllText(schemaFile.ItemSpec));
codegen.AddSchema(schema);
}
}
if (ProtocolFiles != null)
{
foreach (var protocolFile in ProtocolFiles)
{
var protocol = Protocol.Parse(System.IO.File.ReadAllText(protocolFile.ItemSpec));
codegen.AddProtocol(protocol);
}
}
var generateCode = codegen.GenerateCode();
var namespaces = generateCode.Namespaces;
for (var i = namespaces.Count - 1; i >= 0; i--)
{
var types = namespaces[i].Types;
for (var j = types.Count - 1; j >= 0; j--)
{
Log.LogMessage("Generating {0}.{1}", namespaces[i].Name, types[j].Name);
}
}
codegen.WriteTypes(OutDir.ItemSpec);
return true;
}
开发者ID:jbadorek,项目名称:avro,代码行数:34,代码来源:AvroBuilldTask.cs
示例17: GetEnvironmentType
private static Type GetEnvironmentType(int size, CodeGen cg, out ConstructorInfo ctor, out EnvironmentFactory ef)
{
Type envType;
#region Generated partial factories
// *** BEGIN GENERATED CODE ***
if (size <= 32 && Options.OptimizeEnvironments) {
if (size <= 2) {
envType = typeof(FunctionEnvironment2Dictionary);
} else if (size <= 4) {
envType = typeof(FunctionEnvironment4Dictionary);
} else if (size <= 8) {
envType = typeof(FunctionEnvironment8Dictionary);
} else if (size <= 16) {
envType = typeof(FunctionEnvironment16Dictionary);
} else {
envType = typeof(FunctionEnvironment32Dictionary);
}
ctor = envType.GetConstructor(new Type[] { typeof(FunctionEnvironmentDictionary), typeof(IModuleEnvironment), typeof(SymbolId[]), typeof(SymbolId[]) });
ef = new FieldEnvironmentFactory(envType);
} else {
cg.EmitInt(size);
envType = typeof(FunctionEnvironmentNDictionary);
ctor = envType.GetConstructor(new Type[] { typeof(int), typeof(FunctionEnvironmentDictionary), typeof(IModuleEnvironment), typeof(SymbolId[]), typeof(SymbolId[]) });
ef = new IndexEnvironmentFactory(size);
}
// *** END GENERATED CODE ***
#endregion
return envType;
}
开发者ID:FabioNascimento,项目名称:DICommander,代码行数:35,代码来源:ScopeStatement.Generated.cs
示例18: button2_Click
private void button2_Click(object sender, EventArgs e)
{
label2.ForeColor = Color.Cyan;
label2.Text = "Being Compiled.";
try
{
Scanner scanner = null;
using (TextReader input = File.OpenText(openFileDialog1.FileName))
{
scanner = new Scanner(input);
}
Parser parser = new Parser(scanner.Tokens);
CodeGen codeGen = new CodeGen(parser.Result, Path.GetFileNameWithoutExtension(openFileDialog1.FileName) + ".exe");
label2.ForeColor = Color.Lime;
label2.Text = "Compiled! Check the directory this program is in, or click 'Test File' and check the console.";
button3.Enabled = true;
}
catch (Exception ex)
{
textBox3.Show();
textBox3.Text = ex.Message;
label2.ForeColor = Color.Red;
label2.Text = "Error!";
button3.Enabled = false;
}
}
开发者ID:Merbo,项目名称:CSharpBot,代码行数:26,代码来源:GUI.cs
示例19: Emit
public override void Emit(CodeGen cg) {
// emit "this", if any
EmitInstance(cg);
if (ScriptDomainManager.Options.LightweightDebugging && Span.IsValid)
{
cg.EmitConstant(SpanToLong(Span));
cg.EmitCall(Debugging.DebugMethods.ExpressionIn);
}
EmitLocation(cg);
switch (_member.MemberType) {
case MemberTypes.Field:
FieldInfo field = (FieldInfo)_member;
cg.EmitFieldGet(field);
break;
case MemberTypes.Property:
PropertyInfo property = (PropertyInfo)_member;
cg.EmitPropertyGet(property);
break;
default:
Debug.Assert(false, "Invalid member type");
break;
}
if (ScriptDomainManager.Options.LightweightDebugging && Span.IsValid)
{
cg.EmitConstant(SpanToLong(Span));
cg.EmitCall(Debugging.DebugMethods.ExpressionOut);
}
}
开发者ID:JamesTryand,项目名称:IronScheme,代码行数:32,代码来源:MemberExpression.cs
示例20: EnsureLabel
internal Label EnsureLabel(CodeGen cg) {
if (!_initialized) {
_label = cg.DefineLabel();
_initialized = true;
}
return _label;
}
开发者ID:JamesTryand,项目名称:IronScheme,代码行数:7,代码来源:YieldTarget.cs
注:本文中的CodeGen类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论