📄 context.h
字号:
typedef struct mrs {
ushort cbFrameVars; /* Cb of variables in the frame. */
ushort cbFrameTemp; /* Temp space needed */
ushort ogNam; /* [1] source file path name (global name table
[1] offset, or 0 in the case of an untitled
[1] module or OGNAM_GMRS for the global mrs */
bd bdVar; /* Table of all module's variables (including
variables which are local to procedures */
char flags; /* bit flags; FM_ constants defined above */
char flags2; /* bit flags; FM2_ constants defined above */
char flags3; /* bit flags; FM3_ constants defined above */
char dummy1; /* Extra byte to word align */
/* WARNING: Before this point data is initialized to zero.
* After this point, data is initialized to UNDEFINED. */
ushort oMrsNext; /* [4] offset to next mrs in the Rs table */
ushort otxHandler; /* Text offset to error handler */
bdl bdlNam; /* Module's Name table */
txd txd; /* Text Descriptor for pcode for module */
/* WARNING: Binary SAVE/LOAD depend on otxDefFnLink, oPastLastVar, and the
'data' struct being contiguous and in the following order */
ushort otxDefFnLink; /* textmgr maintains this linked list of DEF FN's */
ushort oPastLastVar; /* offset to first byte past last variable in the
module variable table; used to ensure dead
direct mode FOR entries don't waste tVar space */
struct { /* Head of data chain */
ushort otxFirst; /* opTxt operand for 1st data statement */
ushort otxCur; /* opTxt operand for current data statement */
ushort oLineCur; /* byte offset for next READ */
} data;
} mrs;
/**==================== Global Register Set =================================
The global register set owns heap entries which define the current context.
Only one module table entry or procedure table entry may be active at any
one time. These tables are managed by swapping a new mrs into mrsCur or
swapping a new procedure into prsCur.
While a module or procedure is loaded into mrsCur or prsCur, its entry
in the global Rs table should not be referenced or updated.
=======================================================================**/
/* WARNING: the context manager initialization code depends on the prs, mrs,
and grs structures being setup such that all items to be zero-
filled (on struct init.) are at the beginning of the structure */
typedef struct grsType {
char fScan; /* TRUE if all modules and procedures are scanned */
char fDirect; /* TRUE if we're executing instructions out of
direct-mode text buffer bdlDirect.
This is set by UserInterface(), procedure exit,
RETURN. Reset by opStDmGoto, GOSUB, CALL etc. */
bd bdRs; /* [4] */
bd bdtComBlk; /* COMMON block table owner */
char flags; /* These are general flags which are independently
set and reset */
char filler; /* unused */
/* WARNING: Before this point grs struct is initialized to zero.
After this point, it's initialized to UNDEFINED. */
ushort oMrsMain; /* Offset within mrs table for main module. Can be
modified by UI. Note that if mrs with this offset
is discarded, oMrsMain is set to UNDEFINED and
there is NO main module - - - RunInit checks for
this condition. */
ushort oRsCur; /* Redundant copy of oMrsCur and oPrsCur.
If high bit is set, a procedure is active and
low 15 bits = oPrsCur
else
no procedure is active and oRsCur == oMrsCur */
ushort pMrsCur;
ushort pRsCur;
ushort offsetTxdSeg; /* offset into bdtMrs or bdtPrs to the segment
address for the current txd */
ushort oMrsCur; /* Offset within mrs table for module currently
loaded into mrsCur */
ushort oPrsCur; /* Offset within prs table for procedure currently
loaded into prsCur */
ushort otxCur; /* Offset within current text table to next
instruction to be executed. This is only valid
while we're in UserInterface(). While executing,
this value is always maintained in SI reg */
ushort oRsCONT; /* register set where we are to CONTinue */
ushort otxCONT; /* text offset where we are to CONTinue. Set by
UserInterface(), CantCONT(). Used by ExStCONT.
We can't continue if grs.otxCONT == UNDEFINED */
ushort oRsContTxtTbl; /* Identical to oRsCONT, except when oRsCONT is
for a DEF FN, this is the oRs of the module
containing the DEF FN. It always identifies
the text table where containing next stmt to
be executed */
bdl bdlDirect; /* Direct mode pcode buffer owner */
char flagsDir; /* These flags get reset every time we begin
begin executing pcode, and when a runtime error
occurs. They are defined below (FDIR_xxx) */
} grsType;
#define FDIR_cleared 0x01 /* TRUE when ClearWorld has been called. Reset
at end of CLEAR statement. It is strictly a
speed optimization */
#define FDIR_new 0x02 /* Set at start of NewStmt and reset at end of
NewStmt. Speed optimization for Text Manager. */
/* bits for general grs flags */
#define FG_WatchActive 0x01 /* set if watch pcode is active */
#define FG_RetDir 0x02 /* 1 return address to direct-mode buffer
* exists on the stack. Entry of direct-mode
* stmts when this is true causes FG_RetDirBad
* to be set. */
#define FG_AllSsExecute 0x04H /* set if all text tables are in SS_EXECUTE */
#define FG_OtxInDir 0x08H /* set if dir mode stmt contains an oxt ref */
/* bits for mask passed to ForEach[CP]: */
#define FE_PcodeMrs 0x01 /* TRUE if mrs's containing pcode are to
be visited */
#define FE_TextMrs 0x02 /* TRUE if FM_TEXT and FM_TEXTFILE mrs's
are to be visited (i.e. command window's
mrs, docuemnt files) */
#define FE_CallMrs 0x04 /* TRUE if pFunc is to be called for mrs's
text table BEFORE it is called for prs's
text tables */
#define FE_PcodePrs 0x08 /* TRUE if prs's with text tables (SUBs/
FUNCTIONs) are to be visited */
#define FE_NoPcodePrs 0x10 /* TRUE if DEF FN and DECLARE prs's are
to be visited */
#define FE_FarCall 0x20 /* TRUE if function to be called is FAR */
#define FE_SaveRs 0x40 /* TRUE if ForEach is to restore caller's
oRsCur on exit */
#define FE_CallMrsAfter 0x80 /* TRUE if pFunc is to be called for mrs's
text table AFTER it is called for prs's
text tables. */
/**========================= Binary SAVE/LOAD Constants ========================
/* these three bit fields are OR'd together as inputs to Binary SAVE; the
first two are also used in the header of a binary SAVEd file: */
#define BINSAV_SingleModule 0x01
#define BINSAV_MultipleModule 0x02
#define BINSAV_fProtected 0x0100
/**========================= EXTERNAL VARIABLES ===============================
context.c includes this file after defining EXTERNAL as empty, causing these
variables to actually be defined.
============================================================================**/
EXTERNAL grsType PLM grs; /* global register set */
EXTERNAL mrs PLM mrsCur; /* module register set for active module */
EXTERNAL prs PLM prsCur; /* procedure register set for active procedure */
EXTERNAL txd PLM txdCur; /* current text table (from prs or mrs) */
EXTERNAL ushort PLM pGosubLast; /* Pointer to last stack GOSUB frame */
EXTERNAL ushort PLM fNonQBI_Active; /* set non-zero whenever non-QBI code
is activated (non-0 ==> old BP) */
EXTERNAL ushort PLM bcurlevel_QBI; /* value of b$curlevel for most recent
QBI frame when fNonQBI_Active != 0 */
#ifndef CONTEXT_NOFUNCS
VOID FAR InitContext(VOID);
ushort FAR MrsFind(ushort);
ushort FAR PrsFind(ushort);
VOID FAR RsActivate(ushort); /* EB_API */
VOID NEAR RsActivateCP(ushort);
ushort FAR MrsMake(ushort, ushort);
VOID NEAR MrsDeActivate(VOID);
VOID FAR MrsActivate(ushort);
boolean FAR MrsDiscard(VOID);
boolean FAR ForEachMrs(boolean (far *)());
ushort NEAR PrsRef(ushort, uchar, ushort);
ushort FAR PrsMake(ushort, char);
VOID NEAR PrsDeActivate(VOID);
VOID FAR PrsDeActivateFar(VOID);
VOID NEAR PrsActivateCP(ushort);
VOID FAR PrsActivate(ushort);
boolean FAR ForEachPrsInMrs(boolean (far *)());
ushort FAR NextPrsInMrs(VOID);
ushort FAR NextTextPrsInMrs(VOID);
ushort FAR NextMrsFile_All(VOID);
ushort FAR NextMrsFile(VOID);
boolean FAR PrsDiscard(VOID);
VOID FAR PrsFree(VOID);
ushort NEAR FieldsOfPrs(ushort);
ushort FAR FieldsOfPrsFar(ushort);
ushort NEAR SetPrsField(ushort, ushort, ushort);
VOID FAR NewStmt(VOID);
VOID FAR RunInit(VOID);
VOID FAR ContReinit(VOID);
VOID FAR ContReinitStat(VOID);
boolean FAR ClearStmt(ushort, ushort);
VOID FAR CantCont(VOID);
VOID NEAR VarDealloc(VOID);
boolean FAR FreeAllUnrefdPrs(VOID);
VOID FAR AdjustITable(char *, ushort, uchar);
boolean FAR ForEach(uchar, boolean (far *)());
ushort FAR AlphaBuildORs(void); //[23]
ushort FAR oRsOfAlpha(ushort);
ushort FAR NextAlphaPrs(void);
VOID FAR AlphaORsFree(void);
boolean FAR FindORsFrame(void);
ushort FAR OTypeOfTypeCharFar(char); //[22]
/**========================= Non-RELEASE Macros ===============================
Non-RELEASE and DEBUG macros, used with context.c
============================================================================**/
#define DbChkGrs() {;}
#define DbChkMrsCur() {;}
#define DbChkPrsCur() {;}
#define DbChkoMrs(oMrs) {;}
#define DbChkoPrs(oPrs) {;}
#define DbOMrsCur() {;}
#define DbOPrsCur() {;}
#endif /* ifndef CONTEXT_NOFUNCS */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -