本文整理汇总了C#中Operand类的典型用法代码示例。如果您正苦于以下问题:C# Operand类的具体用法?C# Operand怎么用?C# Operand使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Operand类属于命名空间,在下文中一共展示了Operand类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Instruction
public Instruction(Mnemonic mnemonic, Operand? operand, byte opcode, int length)
{
this.Mnemonic = mnemonic;
this.Operand = operand;
this.Opcode = opcode;
this.Length = length;
}
示例2: ComputeOpCode
/// <summary>
///
/// </summary>
/// <param name="destination"></param>
/// <param name="source"></param>
/// <param name="third"></param>
/// <returns></returns>
protected override OpCode ComputeOpCode(Operand destination, Operand source, Operand third)
{
if (source.Type.Type == CilElementType.R4)
return R4;
return R8;
}
示例3: Calculate
/// <summary>
/// Builds up an expression to divide the left operand by the right operand.
/// </summary>
/// <param name="left">The left operand.</param>
/// <param name="right">The right operand.</param>
/// <returns>The operand that consists of the expression to divide the left operand by the right operand.</returns>
public override Operand Calculate(Operand left, Operand right)
{
Logger.Info("Dividing operands (left = '{0}', right = '{1}').", left.OperandType.FullName, right.OperandType.FullName);
Operand result = null;
var operands = new OperandPair(left, right);
if (operands.Are(typeof(decimal)))
{
result = new Operand(Expression.Divide(left.Expression, right.Expression), typeof(decimal));
}
else
{
Warn("'{0}' doesn't support to divide '{1}' and '{2}'.", GetType().FullName, left.OperandType.FullName, right.OperandType.FullName);
var l = Expression.Call(null, typeof(Convert).GetMethod("ToString", new Type[] { typeof(object) }), Expression.Convert(left.Expression, typeof(object)));
var r = Expression.Call(null, typeof(Convert).GetMethod("ToString", new Type[] { typeof(object) }), Expression.Convert(right.Expression, typeof(object)));
var method = typeof(string).GetMethod("Concat", BindingFlags.Static | BindingFlags.Public, null, new Type[] { typeof(string), typeof(string), typeof(string) }, null);
result = new Operand(Expression.Call(null, method, l, Expression.Constant(Symbol), r), typeof(string));
}
Logger.Info("Divided operands (result = '{0}').", result.OperandType.FullName);
return result;
}
示例4: ComputeOpCode
/// <summary>
/// Computes the opcode.
/// </summary>
/// <param name="destination">The destination operand.</param>
/// <param name="source">The source operand.</param>
/// <param name="third">The third operand.</param>
/// <returns></returns>
protected override OpCode ComputeOpCode(Operand destination, Operand source, Operand third)
{
if ((destination is MemoryOperand) && (source is RegisterOperand))
{
if (IsByte(destination) || IsByte(source))
return M_R_8;
if (IsChar(destination) || IsChar(source))
return M_R_16;
return M_R;
}
if ((destination is RegisterOperand) && (source is MemoryOperand))
{
if (IsByte(source) || IsByte(destination))
return R_M_8;
if (IsChar(source) || IsShort(source))
return R_M_16;
return R_M;
}
if ((destination is RegisterOperand) && (source is RegisterOperand)) return R_R;
if ((destination is MemoryOperand) && (source is ConstantOperand)) return M_C;
if ((destination is RegisterOperand) && (source is ConstantOperand))
{
if (IsByte(source) || IsByte(destination))
return R_C_8;
if (IsChar(source) || IsShort(source))
return R_C_16;
return R_C;
}
throw new ArgumentException(String.Format(@"x86.CmpInstruction: No opcode for operand types {0} and {1}.", destination, source));
}
示例5: ComputeOpCode
/// <summary>
/// Computes the opcode.
/// </summary>
/// <param name="destination">The destination operand.</param>
/// <param name="source">The source operand.</param>
/// <param name="third">The third operand.</param>
/// <returns></returns>
protected override OpCode ComputeOpCode(Operand destination, Operand source, Operand third)
{
if ((destination is RegisterOperand) && (source is LabelOperand)) return opcode;
if ((destination is RegisterOperand) && (source is RegisterOperand)) return opcode;
if ((destination is RegisterOperand) && (source is MemoryOperand)) return opcode;
throw new ArgumentException(@"No opcode for operand type.");
}
示例6: Internal
/// <summary>
/// Allows quick internal call replacements
/// </summary>
/// <param name="context">The context.</param>
/// <param name="methodCompiler">The method compiler.</param>
/// <param name="internalMethod">The internal method to replace with.</param>
/// <param name="internalClass">The internal class that has the internal method.</param>
protected void Internal(Context context, BaseMethodCompiler methodCompiler, string internalMethod, string internalClass = "Internal")
{
if (context == null || methodCompiler == null || internalMethod == null || internalClass == null)
throw new ArgumentNullException();
var type = methodCompiler.TypeSystem.GetTypeByName("Mosa.Runtime", internalClass);
Debug.Assert(type != null, "Cannot find Mosa.Runtime." + internalClass);
var method = type.FindMethodByName(internalMethod);
Debug.Assert(method != null, "Cannot find " + internalMethod + " in " + type.Name);
Operand callTargetOperand = Operand.CreateSymbolFromMethod(methodCompiler.TypeSystem, method);
var operands = new Operand[context.OperandCount];
for (int i = 0; i < context.OperandCount; i++)
operands[i] = context.GetOperand(i);
Operand result = context.Result;
context.SetInstruction(IRInstruction.Call, result, callTargetOperand);
for (int i = 0; i < operands.Length; i++)
{
context.SetOperand(1 + i, operands[i]);
}
context.OperandCount = (byte)(1 + operands.Length);
context.InvokeMethod = method;
}
示例7: ComputeOpCode
/// <summary>
/// Computes the opcode.
/// </summary>
/// <param name="destination">The destination operand.</param>
/// <param name="source">The source operand.</param>
/// <param name="third">The third operand.</param>
/// <returns></returns>
protected override OpCode ComputeOpCode(Operand destination, Operand source, Operand third)
{
//if (source.Type.Type == CilElementType.R4) return DIVSS;
return opcode;
//return DIVSD;
}
示例8: ComputeOpCode
/// <summary>
/// Computes the opcode.
/// </summary>
/// <param name="destination">The destination operand.</param>
/// <param name="source">The source operand.</param>
/// <param name="third">The third operand.</param>
/// <returns></returns>
protected override OpCode ComputeOpCode(Operand destination, Operand source, Operand third)
{
if ((destination is MemoryOperand) && (source is RegisterOperand))
{
if (IsByte (destination) || IsByte (source))
return M_R_8;
if (IsChar (destination) || IsChar (source))
return M_R_16;
return M_R;
}
if ((destination is RegisterOperand) && (source is MemoryOperand))
{
if (IsByte (source) || IsByte (destination))
return R_M_8;
if (IsChar (source) || IsShort (source))
return R_M_16;
return R_M;
}
if ((destination is RegisterOperand) && (source is RegisterOperand))
return R_R;
if ((destination is MemoryOperand) && (source is ConstantOperand))
return M_C;
if ((destination is RegisterOperand) && (source is ConstantOperand))
{
if (IsByte (source) || IsByte (destination))
return R_C_8;
if (IsChar (source) || IsShort (source))
return R_C_16;
return R_C;
}
throw new ArgumentException ("No opcode for operand type.");
}
示例9: ConversationWrapper
public ConversationWrapper(Conversion conv, Operand op, Type @from, Type to)
{
_conv = conv;
_op = op;
_to = to;
_from = @from;
}
示例10: Awake
//FUNCTIONS
void Awake()
{
base.initialize(); //this calls initialization stuff inside the Symbol class
operand = transform.parent.GetComponent<Operand>(); //refernce to parent Operand
Debug.Log("Operand: " + operand);
_padding = 0;
}
示例11: SafeCast
public SafeCast(Operand op, Type t)
{
_op = op;
_t = t;
if (t.IsValueType)
_conditional = _op.Is(_t).Conditional(_op.Cast(_t), new DefaultValue(_t));
}
示例12: EmitFloatingPointConstant
/// <summary>
/// This function emits a constant variable into the read-only data section.
/// </summary>
/// <param name="operand">The operand.</param>
/// <returns>
/// An operand, which represents the reference to the read-only constant.
/// </returns>
protected Operand EmitFloatingPointConstant(Operand operand)
{
if (!operand.IsConstant || !operand.IsR)
return operand;
int size, alignment;
Architecture.GetTypeRequirements(TypeLayout, operand.Type, out size, out alignment);
string name = String.Format("C_{0}", Guid.NewGuid());
using (Stream stream = MethodCompiler.Linker.Allocate(name, SectionKind.ROData, size, alignment))
{
using (BinaryWriter writer = new BinaryWriter(stream))
{
if (operand.IsR4)
{
writer.Write(operand.ConstantSingleFloatingPoint);
}
else if (operand.IsR8)
{
writer.Write(operand.ConstantDoubleFloatingPoint);
}
}
}
return Operand.CreateLabel(operand.Type, name);
}
示例13: AssemblerInstruction
public AssemblerInstruction(int line, Opcode opcode, Operand left, Operand right)
{
Line = line;
Opcode = opcode;
Left = left;
Right = right;
}
示例14: ComputeOpCode
/// <summary>
/// Computes the opcode.
/// </summary>
/// <param name="destination">The destination operand.</param>
/// <param name="source">The source operand.</param>
/// <param name="third">The third operand.</param>
/// <returns></returns>
protected override OpCode ComputeOpCode(Operand destination, Operand source, Operand third)
{
if (destination is RegisterOperand)
if ((destination as RegisterOperand).Register is ControlRegister) return CR_R;
else if ((destination as RegisterOperand).Register is SegmentRegister)
throw new ArgumentException(@"TODO: No opcode for move to segment register");
if (source is RegisterOperand)
if ((source as RegisterOperand).Register is ControlRegister) return R_CR;
else if ((source as RegisterOperand).Register is SegmentRegister)
throw new ArgumentException(@"TODO: No opcode for move from segment register");
if ((destination is RegisterOperand) && (source is ConstantOperand)) return R_C;
if ((destination is MemoryOperand) && (source is ConstantOperand)) return M_C;
if ((destination is RegisterOperand) && (source is LabelOperand)) return R_C;
if ((destination is MemoryOperand) && (source is LabelOperand)) return M_C;
if ((destination is RegisterOperand) && (source is RegisterOperand)) {
if (IsByte(source) || IsByte(destination)) return R_R_U8;
if (IsChar(source) || IsChar(destination) || IsShort(source) || IsShort(destination)) return R_R_16;
return R_R;
}
if ((destination is RegisterOperand) && (source is MemoryOperand)) {
if (IsByte(destination)) return R_M_U8;
if (IsChar(destination) || IsShort(destination)) return R_M_16;
return R_M;
}
if ((destination is MemoryOperand) && (source is RegisterOperand)) {
if (IsByte(destination)) return M_R_U8;
if (IsChar(destination) || IsShort(destination)) return M_R_16;
return M_R;
}
throw new ArgumentException(@"No opcode for operand type. [" + destination.GetType() + ", " + source.GetType() + ")");
}
示例15: Is32Bit
/// <summary>
/// Determines whether the specified operand is 32 bits.
/// </summary>
/// <param name="operand">The operand.</param>
/// <returns></returns>
protected static bool Is32Bit(Operand operand)
{
return (operand.Type.Type == CilElementType.U4)
|| (operand.Type.Type == CilElementType.I4)
|| IsPointer(operand)
|| IsObject(operand);
}