#include "litpool.h"
#include "locals.h"
#include "scanner.h"
+#include "segments.h"
#include "stmt.h"
#include "symtab.h"
#include "function.h"
{
if (F->Reserved > 0) {
- /* Switch to the code segment */
- g_usecode ();
-
/* Create space on the stack */
g_space (F->Reserved);
{
int HadReturn;
int IsVoidFunc;
- unsigned Flags;
/* Get the function descriptor from the function entry */
FuncDesc* D = Func->V.F.Func;
InitRegVars ();
/* Allocate code and data segments for this function */
- g_pushseg (&Func->V.F.CS, &Func->V.F.DS, Func->Name);
+ Func->V.F.Seg = PushSegments (Func);
/* If this is a fastcall function, push the last parameter onto the stack */
if (IsFastCallFunc (Func->Type) && D->ParamCount > 0) {
/* Now process statements in this block */
HadReturn = 0;
- while (curtok != TOK_RCURLY) {
- if (curtok != TOK_CEOF) {
- HadReturn = Statement ();
+ while (CurTok.Tok != TOK_RCURLY) {
+ if (CurTok.Tok != TOK_CEOF) {
+ HadReturn = Statement (0);
} else {
break;
}
#endif
/* Output the function exit code label */
- g_defloclabel (GetRetLab (CurrentFunc));
+ g_defcodelabel (GetRetLab (CurrentFunc));
/* Restore the register variables */
RestoreRegVars (!IsVoidFunc);
/* Generate the exit code */
- Flags = IsVoidFunc? CF_NONE : CF_REG;
- g_leave (Flags, 0);
+ g_leave ();
/* Eat the closing brace */
ConsumeRCurly ();
LeaveFunctionLevel ();
/* Switch back to the old segments */
- g_popseg ();
+ PopSegments ();
/* Reset the current function pointer */
FreeFunction (CurrentFunc);