本文整理汇总了C#中CodeGen类的典型用法代码示例。如果您正苦于以下问题:C# CodeGen类的具体用法?C# CodeGen怎么用?C# CodeGen使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CodeGen类属于命名空间,在下文中一共展示了CodeGen类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Emit
public override void Emit(CodeGen cg) {
//EmitLocation(cg);
_value.EmitAsObject(cg);
cg.EmitCodeContext();
cg.EmitSymbolId(_name);
cg.EmitCall(typeof(RuntimeHelpers), "SetNameReorder");
}
示例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);
}
}
示例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);
}
示例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));
}
示例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);
}
}
}
示例6: Emit
public override void Emit(CodeGen cg)
{
if (_statement != null)
{
_statement.Emit(cg);
}
}
示例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);
}
}
示例8: EmitGet
public override void EmitGet(CodeGen cg)
{
// RuntimeHelpers.LookupName(context, name)
_frame.EmitGet(cg);
cg.EmitSymbolId(_name);
cg.EmitCall(typeof(RuntimeHelpers), "LookupName");
}
示例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)) }));
}
示例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();
}
}
示例11: EmitGet
internal override void EmitGet(CodeGen g)
{
op.EmitGet(g);
foreach (OpCode oc in opCodes)
g.IL.Emit(oc);
}
示例12: EmitGet
internal override void EmitGet(CodeGen g)
{
Operand before = g.Local(target);
baseOp.SetOperand(before);
target.EmitSet(g, baseOp, false);
before.EmitGet(g);
}
示例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;
}
示例14: Emit
public override void Emit(CodeGen cg)
{
// RuntimeHelpers.RemoveName(CodeContext, name)
cg.EmitCodeContext();
cg.EmitSymbolId(_name);
cg.EmitCall(typeof(RuntimeHelpers), "RemoveName");
}
示例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());
}