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


C# Emitter.EmitLoadFloat方法代码示例

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


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

示例1: Compile

        public override void Compile(Emitter.Emitter emitter)
        {
            var leftType = Left.GetExpressionType(emitter);
              var rightType = Right.GetExpressionType(emitter);

              var type = GetExpressionType(emitter);

              // subtract matrices
              if(type == "matrix")
              {
            Left.Compile(emitter);
            Right.Compile(emitter);

            var matrixType = typeof(MN.Matrix<double>);
            var method = emitter.AssemblyImport(matrixType.GetMethod("Subtract", new [] { matrixType } ));
            emitter.EmitCall(method);
              }

              // subtract dicts
              else if (type == "dict")
              {
            Left.Compile(emitter);
            Right.Compile(emitter);

            var dictType = typeof(Dict);
            var method = emitter.AssemblyImport(dictType.GetMethod("Subtract", new[] { dictType }));
            emitter.EmitCall(method);
              }

              // subtract complex numbers
              else if (type == "complex")
              {
            Left.Compile(emitter);
            if (leftType != "complex")
            {
              emitter.EmitUpcastBasicType(leftType, "float");
              emitter.EmitLoadFloat(0);
              emitter.EmitNewObj(emitter.FindMethod("complex", ".ctor", "float", "float"));
            }

            Right.Compile(emitter);
            if (rightType != "complex")
            {
              emitter.EmitUpcastBasicType(rightType, "float");
              emitter.EmitLoadFloat(0);
              emitter.EmitNewObj(emitter.FindMethod("complex", ".ctor", "float", "float"));
            }

            emitter.EmitCall(emitter.AssemblyImport(typeof(SN.Complex).GetMethod("op_Subtraction", new[] { typeof(SN.Complex), typeof(SN.Complex) })));
              }
              // add floating point numbers or integers
              else if (type.IsAnyOf("int", "float"))
              {
            Left.Compile(emitter);
            emitter.EmitUpcastBasicType(leftType, type);
            Right.Compile(emitter);
            emitter.EmitUpcastBasicType(rightType, type);
            emitter.EmitSub();
              }
        }
开发者ID:menozz,项目名称:mirelle,代码行数:60,代码来源:OperatorSubtractNode.cs

示例2: Compile

        public override void Compile(Emitter.Emitter emitter)
        {
            var leftType = Left.GetExpressionType(emitter);
              var rightType = Right.GetExpressionType(emitter);

              var type = GetExpressionType(emitter);

              // divide matrix by a number
              if(type == "matrix")
              {
            Left.Compile(emitter);

            // division is broken, therefore multiply by an inverse value
            emitter.EmitLoadFloat(1);
            Right.Compile(emitter);

            if (rightType != "float")
              emitter.EmitConvertToFloat();

            emitter.EmitDiv();

            var matrixType = typeof(MN.Matrix<double>);
            var method = emitter.AssemblyImport(matrixType.GetMethod("Multiply", new[] { typeof(double) }));
            emitter.EmitCall(method);
              }

              // divide complex numbers
              else if (type == "complex")
              {
            Left.Compile(emitter);
            if (leftType != "complex")
            {
              emitter.EmitUpcastBasicType(leftType, "float");
              emitter.EmitLoadFloat(0);
              emitter.EmitNewObj(emitter.FindMethod("complex", ".ctor", "float", "float"));
            }

            Right.Compile(emitter);
            if (rightType != "complex")
            {
              emitter.EmitUpcastBasicType(rightType, "float");
              emitter.EmitLoadFloat(0);
              emitter.EmitNewObj(emitter.FindMethod("complex", ".ctor", "float", "float"));
            }

            emitter.EmitCall(emitter.AssemblyImport(typeof(SN.Complex).GetMethod("op_Division", new[] { typeof(SN.Complex), typeof(SN.Complex) })));
              }

              // divide floating point numbers or integers
              else if (type.IsAnyOf("int", "float"))
              {
            Left.Compile(emitter);
            emitter.EmitUpcastBasicType(leftType, type);
            Right.Compile(emitter);
            emitter.EmitUpcastBasicType(rightType, type);
            emitter.EmitDiv();
              }
        }
开发者ID:menozz,项目名称:mirelle,代码行数:58,代码来源:OperatorDivideNode.cs

示例3: Compile

        public override void Compile(Emitter.Emitter emitter)
        {
            var type = Expression.GetExpressionType(emitter);
              if (type.IsAnyOf("int", "float", "complex"))
              {
            if(type == "complex")
            {
              // simple case: the complex is a constant
              if(Expression is ComplexNode)
              {
            (Expression as ComplexNode).Imaginary *= -1;
            Expression.Compile(emitter);
              }
              // complex case: complex is an expression result
              else
              {
            Expression.Compile(emitter);

            // tmp = ...
            var tmpVar = emitter.CurrentMethod.Scope.Introduce("complex", emitter.FindType("complex").Type);
            emitter.EmitSaveVariable(tmpVar);

            // tmp.real
            emitter.EmitLoadVariableAddress(tmpVar);
            emitter.EmitCall(emitter.AssemblyImport(typeof(SN.Complex).GetMethod("get_Real")));

            // tmp.imaginary * -1
            emitter.EmitLoadVariableAddress(tmpVar);
            emitter.EmitCall(emitter.AssemblyImport(typeof(SN.Complex).GetMethod("get_Imaginary")));
            emitter.EmitLoadFloat(-1);
            emitter.EmitMul();

            // new complex
            emitter.EmitNewObj(emitter.FindMethod("complex", ".ctor", "float", "float"));
              }
            }
            else
            {
              // multiply by -1
              Expression.Compile(emitter);
              if (type == "int")
            emitter.EmitLoadInt(-1);
              else
            emitter.EmitLoadFloat(-1);
              emitter.EmitMul();
            }
              }
              else
            Error(String.Format(Resources.errInvertType, type));
        }
开发者ID:menozz,项目名称:mirelle,代码行数:50,代码来源:OperatorInvertNode.cs

示例4: Compile

 public override void Compile(Emitter.Emitter emitter)
 {
     emitter.EmitLoadFloat(Real);
       emitter.EmitLoadFloat(Imaginary);
       emitter.EmitNewObj(emitter.FindMethod("complex", ".ctor", "float", "float"));
 }
开发者ID:menozz,项目名称:mirelle,代码行数:6,代码来源:ComplexNode.cs

示例5: Compile

 public override void Compile(Emitter.Emitter emitter)
 {
     emitter.EmitLoadFloat(Value);
 }
开发者ID:menozz,项目名称:mirelle,代码行数:4,代码来源:FloatNode.cs

示例6: Compile

        public override void Compile(Emitter.Emitter emitter)
        {
            var leftType = Left.GetExpressionType(emitter);
              var rightType = Right.GetExpressionType(emitter);

              var type = GetExpressionType(emitter);

              // concat strings
              if (type == "string")
              {
            Left.Compile(emitter);
            Right.Compile(emitter);
            emitter.EmitCall(emitter.FindMethod("string", "concat", "string", "string"));
              }

              // add matrices
              else if(type == "matrix")
              {
            Left.Compile(emitter);
            Right.Compile(emitter);

            var matrixType = typeof(MN.Matrix<double>);
            var method = emitter.AssemblyImport(matrixType.GetMethod("Add", new [] { matrixType } ));
            emitter.EmitCall(method);
              }

              // add dicts
              else if (type == "dict")
              {
            Left.Compile(emitter);
            Right.Compile(emitter);

            var dictType = typeof(Dict);
            var method = emitter.AssemblyImport(dictType.GetMethod("Add", new[] { dictType }));
            emitter.EmitCall(method);
              }

              // add complex numbers
              else if(type == "complex")
              {
            Left.Compile(emitter);
            if(leftType != "complex")
            {
              emitter.EmitUpcastBasicType(leftType, "float");
              emitter.EmitLoadFloat(0);
              emitter.EmitNewObj(emitter.FindMethod("complex", ".ctor", "float", "float"));
            }

            Right.Compile(emitter);
            if (rightType != "complex")
            {
              emitter.EmitUpcastBasicType(rightType, "float");
              emitter.EmitLoadFloat(0);
              emitter.EmitNewObj(emitter.FindMethod("complex", ".ctor", "float", "float"));
            }

            emitter.EmitCall(emitter.AssemblyImport(typeof(SN.Complex).GetMethod("op_Addition", new[] { typeof(SN.Complex), typeof(SN.Complex) })));
              }

              // add floating point numbers or integers
              else if(type.IsAnyOf("int", "float"))
              {
            Left.Compile(emitter);
            emitter.EmitUpcastBasicType(leftType, type);
            Right.Compile(emitter);
            emitter.EmitUpcastBasicType(rightType, type);
            emitter.EmitAdd();
              }

              // array addition
              else if(type.Contains("[]"))
              {
            Left.Compile(emitter);
            Right.Compile(emitter);

            var method = emitter.AssemblyImport(typeof(ArrayHelper).GetMethod("AddArrays", new[] { typeof(object), typeof(object) } ));
            emitter.EmitCall(method);
              }
        }
开发者ID:menozz,项目名称:mirelle,代码行数:79,代码来源:OperatorAddNode.cs

示例7: Compile

        public override void Compile(Emitter.Emitter emitter)
        {
            var leftType = Left.GetExpressionType(emitter);
              var rightType = Right.GetExpressionType(emitter);

              var type = GetExpressionType(emitter);

              // repeat a string
              if (type == "string")
              {
            Left.Compile(emitter);
            Right.Compile(emitter);
            emitter.EmitCall(emitter.FindMethod("string", "repeat", "int"));
              }

              // multiply matrices
              else if(type == "matrix")
              {
            var matrixType = typeof(MN.Matrix<double>);

            // matrix by matrix
            if(leftType == rightType)
            {
              Left.Compile(emitter);
              Right.Compile(emitter);

              var method = emitter.AssemblyImport(matrixType.GetMethod("Multiply", new[] { matrixType }));
              emitter.EmitCall(method);
            }
            else
            {
              // matrix should be the first in stack
              if(leftType == "matrix")
              {
            Left.Compile(emitter);
            Right.Compile(emitter);
            if (rightType != "float")
              emitter.EmitConvertToFloat();
              }
              else
              {
            Right.Compile(emitter);
            Left.Compile(emitter);
            if (leftType != "float")
              emitter.EmitConvertToFloat();
              }

              var method = emitter.AssemblyImport(matrixType.GetMethod("Multiply", new[] { typeof(double) }));
              emitter.EmitCall(method);
            }
              }

              // multiply complex numbers
              else if (type == "complex")
              {
            Left.Compile(emitter);
            if (leftType != "complex")
            {
              emitter.EmitUpcastBasicType(leftType, "float");
              emitter.EmitLoadFloat(0);
              emitter.EmitNewObj(emitter.FindMethod("complex", ".ctor", "float", "float"));
            }

            Right.Compile(emitter);
            if (rightType != "complex")
            {
              emitter.EmitUpcastBasicType(rightType, "float");
              emitter.EmitLoadFloat(0);
              emitter.EmitNewObj(emitter.FindMethod("complex", ".ctor", "float", "float"));
            }

            emitter.EmitCall(emitter.AssemblyImport(typeof(SN.Complex).GetMethod("op_Multiply", new[] { typeof(SN.Complex), typeof(SN.Complex) })));
              }

              // repeat array
              else if (leftType.EndsWith("[]"))
              {
            Left.Compile(emitter);
            Right.Compile(emitter);
            var method = emitter.AssemblyImport(typeof(MirelleStdlib.ArrayHelper).GetMethod("RepeatArray", new[] { typeof(object), typeof(int) }));
            emitter.EmitCall(method);
              }

              // multiply floating point numbers or integers
              else if (type.IsAnyOf("int", "float"))
              {
            Left.Compile(emitter);
            emitter.EmitUpcastBasicType(leftType, type);
            Right.Compile(emitter);
            emitter.EmitUpcastBasicType(rightType, type);
            emitter.EmitMul();
              }
        }
开发者ID:menozz,项目名称:mirelle,代码行数:93,代码来源:OperatorMultiplyNode.cs


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