⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 txtmgr.asm

📁 Microsoft MS-DOS6.0 完整源代码
💻 ASM
📖 第 1 页 / 共 5 页
字号:
;==========================================================================
;
;Module:  txtmgr.asm - Text Management Functions
;System:  Quick BASIC Interpreter
;
;=========================================================================

	.xlist
	include		version.inc
	TXTMGR_ASM = ON
	includeOnce	architec
	includeOnce	context
	includeOnce	heap
	includeOnce	lister
	includeOnce	names
	includeOnce	opcodes
	includeOnce	parser
	includeOnce	pcode
	includeOnce	qbimsgs
	includeOnce	rtps
	includeOnce	scanner
	includeOnce	txtmgr
	includeOnce	txtint
	includeOnce	ui
	includeOnce	util
	includeOnce	variable
	.list

assumes	ds,DATA
assumes	ss,DATA
assumes	es,NOTHING

;-----------------------------------------------------------------------
; Scoping of legal statements:
;
; Some statements are invalid in protected-direct mode (i.e. only
;   valid in a program or unprotected-direct-mode).  These are
;   caught by the parser's NtStatement() function which checks
;   a list of statements which ARE legal in protected direct mode
;   (a much smaller list than those which are illegal).
;
; Some statements are invalid in direct mode (i.e. only valid within
;   a program).  Those which can be identified by Reserved Word are
;   caught by the parser's NtStatement() function which checks the
;   'no_direct' flag as set in file 'bnf.prs'.
;   Those which can be identified by opcode are caught by TxtDirect()
;   when it finds entries for them in the table tOpDirect[].
;
; Some statements are only valid at module level.  This includes
;   DECLARE, DEF FNxxx, which are caught by the parser, and
;   END DEF, DATA which are caught by TxtChange.
;
; Some statements are only valid within a SUB/FUNCTION.  This includes
;   SUB/FUNCTION which is caught by the parser, and
;   END SUB/FUNCTION which is caught by TxtChange.
;
; Some opcodes are only valid after the defintion line of a SUB/FUNCTION.
;   These are caught by TxtChange.  Those which can precede a SUB/FUNCTION
;   include opBol, opBolSp, opBolInclude, opStRem, opQuoteRem,
;   opStDefType, opStInclude
;   (and op_Static, op_Dynamic in QB4 and the like [4]).
;
;-----------------------------------------------------------------------

; Typical text table:
; ------------------
;			         opBol:...
;    txdCur.otxLabLink---------->opBolLab(x)
;			         opBol:...
;				    :
;			         opBol:...
;				 opEndProg:...
;    				 opEot
;    txdCur.bdlText.cbLogical--->
; 
; 
; Text table with active Watch expressions:
; ----------------------------------------
; 			         opBol:...
;			 	    :
; 			         opBol:...
;    				 opEndProg
;			         <exp>:opWatchExp
;			         <exp>:opWatchStop
;			         <exp>:opWatchExp
;			         opEot
;    txdCur.bdlText.cbLogical--->
;
;----------------------------------------------------------------------------



sBegin	DATA

	extrn	fMergeInSub:byte	;non-zero if MERGING into SUB/FUNCTION
					;only valid when FLoadActive is TRUE

	extrn	b$SdBuf1:word		; SD to b$Buf1 (from runtime)

;see comments in txtint.inc for bigEditState flag values, and TxtStartBigEdit
;for further details.
;
DbPub	bigEditState
bigEditState DB BIG_EDIT_FALSE

cForDel		DB 0			;1+num of FOR stmts deleted by TxtDelete
cForStepDel	DB 0			;1+num of FOR ... STEP stmts deleted

;bdlTxtScrap holds deleted pcode in case the user wants to back out of the
;edit (for Edit & Continue).
;
PUBLIC	bdlTxtScrap			
bdlTxtScrap	BDL <0,NOT_OWNER,0,0> ;initializes status field to NOT_OWNER

;fFillScrap is FALSE if TxtDelete should not copy deleted text to bdTxtScrap
;	(see comments for Big Edit)
;
fFillScrap	DB 0

;otxScrapStart & otxScrapEnd represent the offsets into the current text table
;where pcode was deleted and copied into bdTxtScrap
;
otxScrap	DW 0

;otxBigIns and cbBigIns identify all pcode inserted since the BigEdit
;started.  If the user wants to back out of the BigEdit, they represent
;the text which needs to be deleted.
;
otxBigIns	DW 0
cbBigIns	DW 0

;fBindStatic is input parm to TxtBindPrs
;
fBindStatic	DB 0

;bindErrCode is result parm of TxtBindPrs
;
bindErrCode	DW 0

;text mgr flags - FTM_xxx
PUBLIC	flagsTm
flagsTm 	DB 0
flagsTm2	DB 0	;must immediately follow flagsTm
FTM2_PrsRefDeleted EQU 01h


externB fLoadInclude	


sEnd	DATA

sBegin	CODE

;Table of all the opcodes that contain oPrs operands
;The order of entries in this table is VERY important
;
tOpPrsDef LABEL WORD
	opTabStart	PRSDEF
	opTabEntry	PRSDEF,opStDeclare
	opTabEntry	PRSDEF,opStSub
	opTabEntry	PRSDEF,opStFunction
	opTabEntry	PRSDEF,opStDefFn
		PRSDEF_DefineMax EQU PRSDEF_opStDefFn
	opTabEntry	PRSDEF,opStCall
	opTabEntry	PRSDEF,opStCallS
	opTabEntry	PRSDEF,opStCallLess
	opTabEntry	PRSDEF,opEot

;These opcodes are of special interest BEFORE they are deleted:
; Reasons why we have to descan to RUDE when certain opcodes are deleted:
;  opStSub, opStFunction, opStDefFn :
;    MakeVariable would be called again to evaluate the parm list, and
;    would give duplicate definition errors for each parm.
;
;  If line containing opStDimTo, opStRedimTo, opShared, opStShared,
;     opStStatic, opAsType, opAsTypeExp, or opAsTypeFixed 
;     (or opCmdAsType in EB) is edited, the variable
;     manager would give a duplicate definition error when new edited line
;     is inserted.
;
;  If a break point is being toggled on the current line, then edit and
;     continue is allowable, as only the opBreakPoint will be inserted
;     on the line.
;
tOpPreDel LABEL WORD
	opTabStart	PREDEL
	; opBol and opBolLab are in this list as TxtFind terminators
	; They will keep us from Searching to opEot if no other interesting
	; opcodes are found after the otx range deleted.  This significantly
	; speeds up edits for generic programs with large text tables.
	
	opTabEntry	PREDEL,opBol
	opTabEntry	PREDEL,opBolLab
		PREDEL_BolMax EQU PREDEL_opBolLab
	opTabEntry	PREDEL,op_Include
		PREDEL_IncludeMax EQU	PREDEL_op_Include
		;The following opcodes cause rude-edit when deleted
	opTabEntry	PREDEL,opStDefType
		PREDEL_rudeMin EQU PREDEL_opStDefType
	; opStDeclare is included here to ensure that variable tables get
	; recreated in case a DECLARE for a quicklib function is deleted.
	; e.g. DECLARE FUNCTION FOO () : x = foo where foo is in a qlb.
	; deleting the DECLARE will cause a variable named foo to be defined.
	
	opTabEntry	PREDEL,opStDeclare
	opTabEntry	PREDEL,opStSub
	opTabEntry	PREDEL,opStFunction
	opTabEntry	PREDEL,opStDefFn
	opTabEntry	PREDEL,opEndSingleDef
	opTabEntry	PREDEL,opStEndDef
	opTabEntry	PREDEL,opStConst
	opTabEntry	PREDEL,opStCommon
	opTabEntry	PREDEL,opAVtRf	
	opTabEntry	PREDEL,opStReDimTo
	opTabEntry	PREDEL,opShared
	opTabEntry	PREDEL,opStShared
	opTabEntry	PREDEL,op_Static  
	opTabEntry	PREDEL,op_Dynamic 
	opTabEntry	PREDEL,opStStatic
	opTabEntry	PREDEL,opStType
	opTabEntry	PREDEL,opStEndType
	opTabEntry	PREDEL,opAsType
	opTabEntry	PREDEL,opAsTypeExp
	opTabEntry	PREDEL,opAsTypeFixed 
	opTabEntry	PREDEL,opNoList1
	;Scanner inserts opNoList1 in a statement whenever the stack
	; contains a return address into that statement.  Deleting
	; an opNoList1 means we're deleting a return address - Cant Continue.
	; opNoList1 could just be AskCantCont instead of AskRudeEdit,
	; but its not worth the extra code to let users print variables
	; after deleting a return address, and other than that,
	; AskCantCont is identical to AskRudeEdit

	opTabEntry	PREDEL,opStOptionBase0	
	opTabEntry	PREDEL,opStOptionBase1	
	opTabEntry	PREDEL,opEot

;These opcodes are of special interest AFTER they have been deleted:
;
tOpDel	LABEL WORD
	opTabStart	DEL
	opTabEntry	DEL,opLab
	opTabEntry	DEL,opLabSp
	opTabEntry	DEL,opBolLab
		DEL_bolMin EQU DEL_opBolLab
	opTabEntry	DEL,opBolLabSp
		DEL_labMax EQU DEL_opBolLabSp
	opTabEntry	DEL,opBol
	opTabEntry	DEL,opBolSp
	opTabEntry	DEL,opBolInclude
	opTabEntry	DEL,opBolIncludeSp
		DEL_bolInclMin EQU DEL_opBolInclude
		DEL_bolMax EQU DEL_opBolIncludeSp
	opTabEntry	DEL,opStFor
	opTabEntry	DEL,opStForStep
		DEL_forMax EQU DEL_opStForStep
	opTabEntry	DEL,opWatchExp
	opTabEntry	DEL,opWatchStop
		DEL_watchMax EQU DEL_opWatchStop
	opTabEntry	DEL,opAsType
	opTabEntry	DEL,opStEndProc
	opTabEntry	DEL,opStCommon
	opTabEntry	DEL,opAVtRf	
	opTabEntry	DEL,opBreakPoint
		DEL_NonSubRefMax EQU DEL_opBreakPoint 
;Remaining entries in table are all the opcodes that could contain references
; to SUBs.  We need to look for these in order to correctly reset the SUB
; name space bit.
	opTabEntry	DEL,opStDeclare 	
	opTabEntry	DEL,opStSub		
	opTabEntry	DEL,opStCall		
	opTabEntry	DEL,opStCallS		
	opTabEntry	DEL,opStCallLess	
	opTabEntry	DEL,opEot


;These opcodes are of special interest BEFORE they are inserted
; NOTE: if any entries in this table change, update PiDispatch
;
tOpPreIns LABEL WORD
	opTabStart	PI
	opTabEntry	PI,op_Static
	opTabEntry	PI,op_Dynamic
	opTabEntry	PI,op_Include
	opTabEntry	PI,opStSub
	opTabEntry	PI,opStFunction
	opTabEntry	PI,opStEndProc
	opTabEntry	PI,opEndSingleDef
	opTabEntry	PI,opStEndDef
	opTabEntry	PI,opStData
	opTabEntry	PI,opStShared
	opTabEntry	PI,opStDefType
	opTabEntry	PI,opStCommon
	opTabEntry	PI,opStEndType
	opTabEntry	PI,opStFor
	opTabEntry	PI,opStForStep
	opTabEntry	PI,opStConst
	opTabEntry	PI,opShared
	opTabEntry	PI,opStOptionBase0	
	opTabEntry	PI,opStOptionBase1	

	opTabEntry	PI,opElemRef
	opTabEntry	PI,opEot

;These opcodes are of special interest AFTER they are inserted
; NOTE: if any entries in this table change, update AiDispatch
;
tOpAftins LABEL WORD
	opTabStart	AFTINS
	opTabEntry	AFTINS,opBolInclude
	opTabEntry	AFTINS,opBolIncludeSp
		AFTINS_bolInclMax EQU AFTINS_opBolIncludeSp
	opTabEntry	AFTINS,opBol
	opTabEntry	AFTINS,opBolSp
	opTabEntry	AFTINS,opBolLab
		AFTINS_dispMin EQU AFTINS_opBolLab
	opTabEntry	AFTINS,opBolLabSp
		AFTINS_bolMax EQU AFTINS_opBolLabSp
	opTabEntry	AFTINS,opLab
	opTabEntry	AFTINS,opLabSp
	opTabEntry	AFTINS,opStFunction
	opTabEntry	AFTINS,opStSub
	opTabEntry	AFTINS,opStDeclare
	opTabEntry	AFTINS,opStCall
	opTabEntry	AFTINS,opStCallS
	opTabEntry	AFTINS,opStCallLess
	opTabEntry	AFTINS,opStEndProc
	opTabEntry	AFTINS,opEndSingleDef
	opTabEntry	AFTINS,opStEndDef
	opTabEntry	AFTINS,opStData
	opTabEntry	AFTINS,opStRestore1
	opTabEntry	AFTINS,opEot

;List of opcodes which are legal in SUB/FUNCTION window before
;the procedure's definition
;
tOpPreProc LABEL WORD
	opTabStart	PREPROC
	opTabEntry	PREPROC,opBol
	opTabEntry	PREPROC,opBolSp
	opTabEntry	PREPROC,opBolInclude
	opTabEntry	PREPROC,opBolIncludeSp
		PREPROC_bolMax EQU PREPROC_opBolIncludeSp
	opTabEntry	PREPROC,opStDefType
	opTabEntry	PREPROC,opStRem
	opTabEntry	PREPROC,opQuoteRem
	opTabEntry	PREPROC,op_Static
	opTabEntry	PREPROC,op_Dynamic
	opTabEntry	PREPROC,opNoType	;for SUB x.y
	opTabEntry	PREPROC,opReParse
	opTabEntry	PREPROC,opStEndProc	;only if SUB opStSub or
						; opStFunction precedes it.
	opTabEntry	PREPROC,opStSub
		PREPROC_SubOrFuncMin EQU PREPROC_opStSub
	opTabEntry	PREPROC,opStFunction
	opTabEntry	PREPROC,opEot

tOpEndProc LABEL WORD
	opTabStart	ENDPROC
	opTabEntry	ENDPROC,opStEndProc
	opTabEntry	ENDPROC,opEot

sEnd	CODE



;--------------------------------------------------------------------
; Functions which keep track of where the current "defining" reference
; to a Prs is.  If there are any references to a prs in any loaded pcode,
; we keep track of the "most powerful" or "defining" reference in
; prs.oRsDef, prs.otxDef.
;
; A SUB/FUNCTION/DEF FN statement is the "most powerful" possible
;   definition for a prs entry.
; If no SUB/FUNCTION/DEF FN statements refer to a prs, the next most
;   powerful definition is a DECLARE statement.
; If no DECLARE statements refer to a prs, the only remaining possible
;   definition is a CALL statement.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -