当前位置: 首页>>代码示例>>C#>>正文


C# CodeGen类代码示例

本文整理汇总了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");
 }
开发者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


注:本文中的CodeGen类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。