本文整理汇总了C#中CodeGeneration.CGenState.CGenExpandStackTo方法的典型用法代码示例。如果您正苦于以下问题:C# CGenState.CGenExpandStackTo方法的具体用法?C# CGenState.CGenExpandStackTo怎么用?C# CGenState.CGenExpandStackTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CodeGeneration.CGenState
的用法示例。
在下文中一共展示了CGenState.CGenExpandStackTo方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CGenDecln
//.........这里部分代码省略.........
last = offset + expr.Type.SizeOf;
});
} else {
// Global without initialization.
switch (this.scs) {
case StorageClass.AUTO:
// .comm name,size,align
break;
case StorageClass.EXTERN:
break;
case StorageClass.STATIC:
// .local name
// .comm name,size,align
state.LOCAL(this.name);
break;
case StorageClass.TYPEDEF:
// Ignore.
return;
default:
throw new InvalidProgramException();
}
if (this.type.Kind != ExprTypeKind.FUNCTION) {
state.COMM(this.name, this.type.SizeOf, ExprType.ALIGN_LONG);
}
}
state.NEWLINE();
} else {
// stack object
state.CGenExpandStackTo(env.StackSize, ToString());
Int32 stack_size = env.StackSize;
// pos should be equal to stack_size, but whatever...
Int32 pos = env.Find(this.name).Value.Offset;
if (this.initr.IsNone) {
return;
}
Initr initr = this.initr.Value;
initr.Iterate(this.type, (Int32 offset, Expr expr) => {
Reg ret = expr.CGenValue(state);
switch (expr.Type.Kind) {
case ExprTypeKind.CHAR:
case ExprTypeKind.UCHAR:
state.MOVB(Reg.EAX, pos + offset, Reg.EBP);
break;
case ExprTypeKind.SHORT:
case ExprTypeKind.USHORT:
state.MOVW(Reg.EAX, pos + offset, Reg.EBP);
break;
case ExprTypeKind.DOUBLE:
state.FSTPL(pos + offset, Reg.EBP);
break;
case ExprTypeKind.FLOAT:
state.FSTPS(pos + offset, Reg.EBP);
break;
case ExprTypeKind.LONG:
case ExprTypeKind.ULONG:
case ExprTypeKind.POINTER:
state.MOVL(Reg.EAX, pos + offset, Reg.EBP);
break;
case ExprTypeKind.STRUCT_OR_UNION:
state.MOVL(Reg.EAX, Reg.ESI);
state.LEA(pos + offset, Reg.EBP, Reg.EDI);
state.MOVL(expr.Type.SizeOf, Reg.ECX);
state.CGenMemCpy();
break;
case ExprTypeKind.ARRAY:
case ExprTypeKind.FUNCTION:
throw new InvalidProgramException($"How could a {expr.Type.Kind} be in a init list?");
default:
throw new InvalidProgramException();
}
state.CGenForceStackSizeTo(stack_size);
});
} // stack object
}