ORCA-Pascal/call.pas

1 line
69 KiB
ObjectPascal
Raw Normal View History

{$optimize 15} {------------------------------------------------------------} { } { ORCA/Pascal Call Procedure } { } { The call procedure handles parsing, semantic analysis } { and code generation for all procedure and function calls. } { This includes both user-defined and predeclared } { routines. } { } { By Mike Westerfield } { } { Copyright March 1988 } { By the Byte Works, Inc. } { } {------------------------------------------------------------} unit Call; interface {$segment 'Pascal2'} {$LibPrefix '0/obj/'} uses pcommon, scanner, cgi, symbols; {-- Externally available variables --------------------------------------------} type {subroutine calls} {----------------} callKinds = (cStandard, cMethod, cInherited); {temporary variable allocation} {-----------------------------} tempPtr = ^tempRecord; tempRecord = record last,next: tempPtr; {doubly linked list} labelNum: integer; {label number} size: integer; {size of the variable} end; var psize: integer; {size of the parameter space for the current stack frame} lc: addrrange; {current stack frame size} {temporary variable allocation} {-----------------------------} tempList: tempPtr; {list of temp work variables} {-- Externally available subroutines ------------------------------------------} procedure Call (fsys: setofsys; fcp,fprocp: ctp); { generate a call to a procedure or function } { } { parameters: } { fsys - } { fcp - } { fprocp - } procedure CallNonStandard (fsys: setofsys; fcp,fprocp: ctp; odisp: longint; callKind: callKinds); { Handle a call to a user defined procedure/function } { } { parameters: } { fsys - } { fcp - } { fprocp - } { odisp - disp in object for method calls; else 0 } { callKind - type of this call } procedure CheckBool; {load a value, insuring that it is boolean} procedure CheckBnds(fsp: stp); {generate range checking code (if needed)} procedure FreeTemp (labelNum, size: integer); { place a temporary label in the available label list } { } { parameters: } { labelNum - number of the label to free } { size - size of the variable } { } { variables: } { tempList - list of free labels } function GetTemp (size: integer): integer; { find a temporary work variable } { } { parameters: } { size - size of the variable } { } { variables: } { tempList - list of free labels } { } { Returns the label number. } procedure Load; {load a value onto the evaluation stack} procedure LoadAddress; {load the address of a variable onto the top of the stack} procedure LoadStringAddress; {load the address and length of a string} procedure LoadString(kind: stringKind); {load the address of a string constant} function ParmSize(lsp: stp; vkind: idkind): integer; {find the length of a parameter} procedure ResetTemp; { forget all of the temporary work variables } procedure Store(var fattr: attr); {store the value on top of stack} {-- Private declarations ------------------------------------------------------} implementation const realfw = 16; {field width for reals & doubles} longfw = 16; {field width for long integers} intfw = 8; {field width for integers} boolfw = 8; {field width for booleans} var lkey: keyrange; {proc/func key for std proc compilation} {-- Imported subroutines ------------------------------------------------------} procedure DoConstant(fsys: setofsys; var fsp: stp; var fvalu: valu); extern; {compile a constant term} procedure Expression(fsys: setofsys; fprocp: ctp); extern; {compile an expression} procedure Selector (fsys: setofsys; fcp,fprocp: ctp; var isMethod: boolean); extern; { handle indexing arrays, field selection, dereferencing o