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


C# CodeGen.EmitConstant方法代码示例

本文整理汇总了C#中CodeGen.EmitConstant方法的典型用法代码示例。如果您正苦于以下问题:C# CodeGen.EmitConstant方法的具体用法?C# CodeGen.EmitConstant怎么用?C# CodeGen.EmitConstant使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CodeGen的用法示例。


在下文中一共展示了CodeGen.EmitConstant方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: 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

示例2: 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

示例3: 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

示例4: EmitLocation

 protected override void EmitLocation(CodeGen cg)
 {
   if (ScriptDomainManager.Options.LightweightDebugging)
   {
     if (!cg.IsDynamicMethod)
     {
       var s = SpanToLong(Span);
       cg.EmitConstant(s);
       cg.EmitCall(Debugging.DebugMethods.ExpressionIn);
     }
   }
   else
   {
     base.EmitLocation(cg);
   }
 }
开发者ID:JamesTryand,项目名称:IronScheme,代码行数:16,代码来源:TypeBinaryExpression.cs

示例5: Emit

 internal override void Emit(CodeGen cg)
 {
     cg.EmitConstant(value);
 }
开发者ID:FabioNascimento,项目名称:DICommander,代码行数:4,代码来源:Expressions.cs

示例6: Emit

        public override void Emit(CodeGen cg) {
          
            // TODO: code gen will be suboptimal for chained AndAlsos and AndAlso inside If
            if (NodeType == AstNodeType.AndAlso || NodeType == AstNodeType.OrElse) {
                EmitBooleanOperator(cg, NodeType == AstNodeType.AndAlso);
                return;
            }

            _left.EmitAs(cg, GetEmitType());
            _right.EmitAs(cg, GetEmitType());

            EmitLocation(cg);

            switch (NodeType) {
                case AstNodeType.Equal:
                    cg.Emit(OpCodes.Ceq);
                    break;

                case AstNodeType.NotEqual:
                    cg.Emit(OpCodes.Ceq);
                    cg.EmitInt(0);
                    cg.Emit(OpCodes.Ceq);
                    break;

                case AstNodeType.GreaterThan:
                    cg.Emit(OpCodes.Cgt);
                    break;

                case AstNodeType.LessThan:
                    cg.Emit(OpCodes.Clt);
                    break;

                case AstNodeType.GreaterThanOrEqual:
                    cg.Emit(OpCodes.Clt);
                    cg.EmitInt(0);
                    cg.Emit(OpCodes.Ceq);
                    break;

                case AstNodeType.LessThanOrEqual:
                    cg.Emit(OpCodes.Cgt);
                    cg.EmitInt(0);
                    cg.Emit(OpCodes.Ceq);
                    break;
                case AstNodeType.Multiply:
                    cg.Emit(OpCodes.Mul);
                    break;
                case AstNodeType.MultiplyChecked:
                    cg.Emit(OpCodes.Mul_Ovf);
                    break;
                case AstNodeType.Modulo:
                    cg.Emit(OpCodes.Rem);
                    break;
                case AstNodeType.Add:
                    cg.Emit(OpCodes.Add);
                    break;
                case AstNodeType.AddChecked:
                    cg.Emit(OpCodes.Add_Ovf);
                    break;
                case AstNodeType.Subtract:
                    cg.Emit(OpCodes.Sub);
                    break;
                case AstNodeType.SubtractChecked:
                    cg.Emit(OpCodes.Sub_Ovf);
                    break;
                case AstNodeType.Divide:
                    cg.Emit(OpCodes.Div);
                    break;
                case AstNodeType.LeftShift:
                    cg.Emit(OpCodes.Shl);
                    break;
                case AstNodeType.RightShift:
                    cg.Emit(OpCodes.Shr);
                    break;
                case AstNodeType.And:
                    cg.Emit(OpCodes.And);
                    break;
                case AstNodeType.Or:
                    cg.Emit(OpCodes.Or);
                    break;
                case AstNodeType.ExclusiveOr:
                    cg.Emit(OpCodes.Xor);
                    break;
                default:
                    throw new InvalidOperationException(NodeType.ToString());
            }

            if (ScriptDomainManager.Options.LightweightDebugging)
            {
              if (!cg.IsDynamicMethod)
              {
                var s = SpanToLong(Span);
                cg.EmitConstant(s);
                cg.EmitCall(Debugging.DebugMethods.ExpressionOut);
              }
            }
        }
开发者ID:JamesTryand,项目名称:IronScheme,代码行数:96,代码来源:BinaryExpression.cs

示例7: EmitBranchTrue

 public override void EmitBranchTrue(CodeGen cg, Label label) {
     if (!EmitBranchTrue(cg, NodeType, label)) {
       EmitLocation(cg);
         base.EmitBranchTrue(cg, label);
         if (ScriptDomainManager.Options.LightweightDebugging)
         {
           if (!cg.IsDynamicMethod)
           {
             var s = SpanToLong(Span);
             cg.EmitConstant(s);
             cg.EmitCall(Debugging.DebugMethods.ExpressionOut);
           }
         }
     }
 }
开发者ID:JamesTryand,项目名称:IronScheme,代码行数:15,代码来源:BinaryExpression.cs

示例8: EmitBranchFalse

        public override void EmitBranchFalse(CodeGen cg, Label label) {
            switch (NodeType) {
                case AstNodeType.Equal:
                    EmitLocation(cg);
                    EmitBranchTrue(cg, AstNodeType.NotEqual, label);
                    if (ScriptDomainManager.Options.LightweightDebugging)
                    {
                      if (!cg.IsDynamicMethod)
                      {
                        var s = SpanToLong(Span);
                        cg.EmitConstant(s);
                        cg.EmitCall(Debugging.DebugMethods.ExpressionOut);
                      }
                    }
                    break;

                case AstNodeType.NotEqual:
                    EmitLocation(cg);
                    EmitBranchTrue(cg, AstNodeType.Equal, label);
                    if (ScriptDomainManager.Options.LightweightDebugging)
                    {
                      if (!cg.IsDynamicMethod)
                      {
                        var s = SpanToLong(Span);
                        cg.EmitConstant(s);
                        cg.EmitCall(Debugging.DebugMethods.ExpressionOut);
                      }
                    }
                    break;

                case AstNodeType.AndAlso:
                    // if NOT (left AND right) branch label

                    if (_left.IsConstant(false)) {
                        cg.Emit(OpCodes.Br, label);
                    } else {
                        if (!_left.IsConstant(true)) {
                            _left.EmitBranchFalse(cg, label);
                        }

                        if (_right.IsConstant(false)) {
                            cg.Emit(OpCodes.Br, label);
                        } else if (!_right.IsConstant(true)) {
                            _right.EmitBranchFalse(cg, label);
                        }
                    }
                    break;

                case AstNodeType.OrElse:
                    // if NOT left AND NOT right branch label

                    if (!_left.IsConstant(true) && !_right.IsConstant(true)) {
                        if (_left.IsConstant(false)) {
                            _right.EmitBranchFalse(cg, label);
                        } else if (_right.IsConstant(false)) {
                            _left.EmitBranchFalse(cg, label);
                        } else {
                            // if (NOT left) then 
                            //   if (NOT right) branch label
                            // endif

                            Label endif = cg.DefineLabel();
                            _left.EmitBranchTrue(cg, endif);
                            _right.EmitBranchFalse(cg, label);
                            cg.MarkLabel(endif);
                        }
                    }
                    break;
                case AstNodeType.LessThan:
                    EmitLocation(cg);
                    EmitBranchTrue(cg, AstNodeType.GreaterThanOrEqual, label);      
                    break;
                case AstNodeType.LessThanOrEqual:
                    EmitLocation(cg);
                    EmitBranchTrue(cg, AstNodeType.GreaterThan, label);
                    break;
                case AstNodeType.GreaterThan:
                    EmitLocation(cg);
                    EmitBranchTrue(cg, AstNodeType.LessThanOrEqual, label);
                    break;
                case AstNodeType.GreaterThanOrEqual:
                    EmitLocation(cg);
                    EmitBranchTrue(cg, AstNodeType.LessThan, label);
                    break;
                default:

                    base.EmitBranchFalse(cg, label);
                    break;
            }
        }
开发者ID:JamesTryand,项目名称:IronScheme,代码行数:90,代码来源:BinaryExpression.cs

示例9: Emit

        public override void Emit(CodeGen cg)
        {
            _value.EmitAs(cg, _vr.Slot.Type);

              if (ScriptDomainManager.Options.LightweightDebugging && Span.IsValid)
              {
            cg.EmitConstant(SpanToLong(Span));
            cg.EmitCall(Debugging.DebugMethods.ExpressionIn);
              }

              _vr.Slot.EmitSet(cg);

              if (ScriptDomainManager.Options.LightweightDebugging && Span.IsValid)
              {
            cg.EmitConstant(SpanToLong(Span));
            cg.EmitCall(Debugging.DebugMethods.ExpressionOut);
              }

              _vr.Variable.SetInitialized();
        }
开发者ID:robertlj,项目名称:IronScheme,代码行数:20,代码来源:BoundAssignment.cs

示例10: EmitAddress

 internal override void EmitAddress(CodeGen cg, Type asType)
 {
     EmitLocation(cg);
     _value.Emit(cg);
     _vr.Slot.EmitSet(cg);
     //_vr.Slot.EmitGetAddr(cg);
     if (ScriptDomainManager.Options.LightweightDebugging && Span.IsValid)
     {
       cg.EmitConstant(SpanToLong(Span));
       cg.EmitCall(Debugging.DebugMethods.ExpressionOut);
     }
 }
开发者ID:robertlj,项目名称:IronScheme,代码行数:12,代码来源:BoundAssignment.cs

示例11: Emit

    public override void Emit(CodeGen cg)
    {
      _value.EmitAs(cg, _vr.Slot.Type);
      //if (_vr.Variable.Type == typeof(object) && _value.Type.IsValueType && _value.Type != typeof(SymbolId))
      //{
      //  cg.EmitBoxing(_value.Type);
      //}

      if (ScriptDomainManager.Options.LightweightDebugging && Span.IsValid)
      {
        cg.EmitConstant(SpanToLong(Span));
        cg.EmitCall(Debugging.DebugMethods.ExpressionIn);
      }
      
      _vr.Slot.EmitSet(cg);

      if (ScriptDomainManager.Options.LightweightDebugging && Span.IsValid)
      {
        cg.EmitConstant(SpanToLong(Span));
        cg.EmitCall(Debugging.DebugMethods.ExpressionOut);
      }

      _vr.Variable.SetInitialized();
    }
开发者ID:JamesTryand,项目名称:IronScheme,代码行数:24,代码来源:BoundAssignment.cs

示例12: EmitDefaultValue

 private static void EmitDefaultValue(CodeGen cg, object value, Type type) {
     if (value is Missing) {
         cg.EmitMissingValue(type);
     } else {
         cg.EmitConstant(value);
         //TODO This should turn into cg.EmitConvert(value.GetType(), type)
         if (type.IsValueType) {
             if (value == null) cg.EmitTypeError("Cannot cast None to {0}", type);
             else if (value.GetType() != type) cg.EmitTypeError("Cannot cast {0} to {1}", value, type);
         } else {
             // null is any reference type
             if (value != null) {
                 Type from = value.GetType();
                 if (!type.IsAssignableFrom(from)) {
                     cg.EmitTypeError("Cannot cast {0} to {1}", value, type);
                 } else {
                     if (from.IsValueType) {
                         cg.Emit(OpCodes.Box, from);
                     }
                 }
             }
         }
     }
 }
开发者ID:JamesTryand,项目名称:IronScheme,代码行数:24,代码来源:DefaultArgBuilder.cs

示例13: EmitCreation

 public override void EmitCreation(CodeGen cg)
 {
     cg.EmitConstant(new FractionConstant(value.Real));
       cg.EmitConstant(new FractionConstant(value.Imag));
       cg.EmitNew(typeof(ComplexFraction), new Type[] { typeof(Fraction), typeof(Fraction) });
 }
开发者ID:tshaug,项目名称:IronScheme,代码行数:6,代码来源:IronSchemeConstant.cs

示例14: Emit

 public override void Emit(CodeGen cg)
 {
     var et = _type.GetElementType();
     cg.EmitArray(
         et,
         _expressions.Count,
         delegate(int index) {
           var ex = _expressions[index];
           ex.Emit(cg);
           if (ex.Type != et && ex.Type.IsValueType)
           {
             cg.EmitBoxing(ex.Type);
           }
         }
     );
       // fake it...
     EmitLocation(cg);
     if (ScriptDomainManager.Options.LightweightDebugging)
     {
       cg.EmitConstant(SpanToLong(Span));
       cg.EmitCall(Debugging.DebugMethods.ExpressionOut);
     }
 }
开发者ID:robertlj,项目名称:IronScheme,代码行数:23,代码来源:NewArrayExpression.cs

示例15: Emit

        public override void Emit(CodeGen cg)
        {
            //EmitLocation(cg);
              if (_instance != null && !cg.IsDynamicMethod) // damn DM! // go away! // this dangerous too for now
              {
            if (!IsParamsMethod())
            {
              if (_instance is CodeBlockExpression)
              {
                CodeBlockExpression cbe = (CodeBlockExpression)_instance;

                Debug.Assert(_arguments.Count == _parameterInfos.Length);
                for (int arg = 0; arg < _parameterInfos.Length; arg++)
                {
                  Expression argument = _arguments[arg];
                  Type type = _parameterInfos[arg].ParameterType;
                  EmitArgument(cg, argument, type);
                }

                EmitLocation(cg);

                cbe.EmitDirect(cg, tailcall);

                if (ScriptDomainManager.Options.LightweightDebugging && !tailcall && Span.IsValid)
                {
                  cg.EmitConstant(SpanToLong(Span));
                  cg.EmitCall(Debugging.DebugMethods.ExpressionOut);
                }

                return;
              }
            }
            else // 'params'
            {

            }

              }

              var ii = _instance;

              ii = Unwrap(ii);

              BoundExpression.Emitter fixup = null;
              bool varargs = false;
              var pttt = Array.ConvertAll(_parameterInfos, x => x.ParameterType);

              if (ii is BoundExpression)
              {
            var be = ii as BoundExpression;

            if (BoundExpression.Fixups.ContainsKey(be.Variable.Name))
            {
              fixup = BoundExpression.Fixups[be.Variable.Name];
              pttt = BoundExpression.FixupTypes[be.Variable.Name];
            }
            else
            {
              CodeGen rcg;
              CodeGenDescriptor[] cgd;
              if (CodeGen._codeBlockLookup.TryGetValue(be.Variable.Name, out rcg))
              {
                var lpttt = pt.GetValue(rcg.MethodInfo) as Type[];
                if (_arguments.Count == lpttt.Length)
                {
                  _method = rcg.MethodInfo;
                  pttt = lpttt;
                }
              }
              else if (CodeGen._codeBlockLookupX.TryGetValue(be.Variable.Name, out rcg))
              {
                var lpppt = pt.GetValue(rcg.MethodInfo) as Type[];
                if (lpppt.Length - 1 > _arguments.Count)
                {
                }
                else if (AllArgsAreObject(_arguments))
                {
                  _method = rcg.MethodInfo;
                  pttt = lpppt;
                  varargs = true;
                }
                else if (_arguments.Count == 1 && lpppt.Length == 1 &&
                  _arguments[0].Type == typeof(object[]) && _arguments[0] is MethodCallExpression &&
                  ((MethodCallExpression)_arguments[0])._method.Name == "ListToVector")
                {
                  _arguments[0] = Unwrap(((MethodCallExpression)_arguments[0]).Arguments[0]);
                  _method = rcg.MethodInfo;
                  pttt = lpppt;
                }
              }
              else if (CodeGen._codeBlockLookupN.TryGetValue(be.Variable.Name, out cgd))
              {
                if (AllArgsAreObject(_arguments))
                {
                  foreach (var i in cgd)
                  {
                    if (i.arity == _arguments.Count)
                    {
                      _method = i.cg.MethodInfo;
                      pttt = pt.GetValue(_method) as Type[];
//.........这里部分代码省略.........
开发者ID:kkirstein,项目名称:IronScheme,代码行数:101,代码来源:MethodCallExpression.cs


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