本文整理汇总了C#中CodeGeneration.CGenState.CGenPushLong方法的典型用法代码示例。如果您正苦于以下问题:C# CGenState.CGenPushLong方法的具体用法?C# CGenState.CGenPushLong怎么用?C# CGenState.CGenPushLong使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CodeGeneration.CGenState
的用法示例。
在下文中一共展示了CGenState.CGenPushLong方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CGenPrepareIntegralOperands
// %eax = left, %ebx = right, stack unchanged
private void CGenPrepareIntegralOperands(CGenState state) {
// 1. Load Left to EAX.
//
// regs:
// %eax = Left
//
// stack:
// +-----+
// | ... | <- %esp
// +-----+
//
if (this.Left.CGenValue(state) != Reg.EAX) {
throw new InvalidOperationException();
}
// 2. Push Left to stack.
//
// regs:
// %eax = Left
//
// stack:
// +-----+
// | ... |
// +-----+
// | Left | <- %esp has decreased by 4
// +-----+
//
Int32 stack_size = state.CGenPushLong(Reg.EAX);
// 3. Load Right to EAX.
//
// regs:
// %eax = Right
//
// stack:
// +-----+
// | ... |
// +-----+
// | Left | <- %esp
// +-----+
//
if (this.Right.CGenValue(state) != Reg.EAX) {
throw new InvalidOperationException();
}
// 4. Move Right into EBX. Pop Left from stack, into EAX.
//
// regs:
// %eax = Left
// %ebx = Right
//
// stack:
// +-----+
// | ... | <- %esp has moved back.
// +-----+
//
state.MOVL(Reg.EAX, Reg.EBX);
state.CGenPopLong(stack_size, Reg.EAX);
}
示例2: CGenValue
public override sealed Reg CGenValue(CGenState state) {
// 1. Get the address of expr.
//
// regs:
// %eax = &expr
//
// stack:
// +-------+
// | ..... | <- %esp
// +-------+
//
this.Expr.CGenAddress(state);
// 2. Push address.
//
// regs:
// %eax = &expr
//
// stack:
// +-------+
// | ..... |
// +-------+
// | &expr | <- %esp
// +-------+
//
Int32 stack_size = state.CGenPushLong(Reg.EAX);
// 3. Get current Value of expr.
//
// 1) If expr is an integral or pointer:
//
// regs:
// %eax = expr
//
// stack:
// +-------+
// | ..... |
// +-------+
// | &expr | <- %esp
// +-------+
//
//
// 2) If expr is a float:
//
// regs:
// %eax = &expr
//
// stack:
// +-------+
// | ..... |
// +-------+
// | &expr | <- %esp
// +-------+
//
// float stack:
// +-------+
// | expr | <- %st(0)
// +-------+
//
Reg ret = this.Expr.CGenValue(state);
switch (ret) {
case Reg.EAX:
// expr is an integral or pointer.
// 4. Pop address to %ecx.
//
// regs:
// %eax = expr
// %ecx = &expr
//
// stack:
// +-------+
// | ..... | <- %esp
// +-------+
//
state.CGenPopLong(stack_size, Reg.ECX);
// 5. Cache current Value of Expr in %ebx.
//
// regs:
// %eax = expr
// %ebx = expr
// %ecx = &expr
//
// stack:
// +-------+
// | ..... | <- %esp
// +-------+
//
state.MOVL(Reg.EAX, Reg.EBX);
// 6. Calculate the new value in %ebx or %eax and save.
// Set %eax to be the return Value.
//
// regs:
// %eax = expr or (expr +- 1)
// %ebx = (expr +- 1) or expr
// %ecx = &expr
//.........这里部分代码省略.........
示例3: CGenValue
public override Reg CGenValue(CGenState state) {
// 1. %eax = &left
this.Left.CGenAddress(state);
// 2. push %eax
Int32 pos = state.CGenPushLong(Reg.EAX);
Reg ret = this.Right.CGenValue(state);
switch (this.Left.Type.Kind) {
case ExprTypeKind.CHAR:
case ExprTypeKind.UCHAR:
// pop %ebx
// now %ebx = %Left
state.CGenPopLong(pos, Reg.EBX);
// *%ebx = %al
state.MOVB(Reg.AL, 0, Reg.EBX);
return Reg.EAX;
case ExprTypeKind.SHORT:
case ExprTypeKind.USHORT:
// pop %ebx
// now %ebx = %Left
state.CGenPopLong(pos, Reg.EBX);
// *%ebx = %al
state.MOVW(Reg.AX, 0, Reg.EBX);
return Reg.EAX;
case ExprTypeKind.LONG:
case ExprTypeKind.ULONG:
case ExprTypeKind.POINTER:
// pop %ebx
// now %ebx = &Left
state.CGenPopLong(pos, Reg.EBX);
// *%ebx = %al
state.MOVL(Reg.EAX, 0, Reg.EBX);
return Reg.EAX;
case ExprTypeKind.FLOAT:
// pop %ebx
// now %ebx = &Left
state.CGenPopLong(pos, Reg.EBX);
// *%ebx = %st(0)
state.FSTS(0, Reg.EBX);
return Reg.ST0;
case ExprTypeKind.DOUBLE:
// pop %ebx
// now %ebx = &Left
state.CGenPopLong(pos, Reg.EBX);
// *%ebx = %st(0)
state.FSTL(0, Reg.EBX);
return Reg.ST0;
case ExprTypeKind.STRUCT_OR_UNION:
// pop %edi
// now %edi = &Left
state.CGenPopLong(pos, Reg.EDI);
// %esi = &Right
state.MOVL(Reg.EAX, Reg.ESI);
// %ecx = nbytes
state.MOVL(this.Left.Type.SizeOf, Reg.ECX);
state.CGenMemCpy();
// %eax = &Left
state.MOVL(Reg.EDI, Reg.EAX);
return Reg.EAX;
case ExprTypeKind.FUNCTION:
case ExprTypeKind.VOID:
case ExprTypeKind.ARRAY:
case ExprTypeKind.INCOMPLETE_ARRAY:
default:
throw new InvalidProgramException("cannot assign to a " + this.Type.Kind);
}
}