ORCA-C/CC.pas

1 line
6.3 KiB
ObjectPascal
Raw Normal View History

{$optimize 7} {---------------------------------------------------------------} { } { ORCA/C } { } { A C compiler for the Apple IIGS. } { } { Copyright 1989,1990 } { Byte Works, Inc. } { } { Mike Westerfield } { } {---------------------------------------------------------------} {$stacksize $1800} program cc(output); {$LibPrefix '0/obj/'} uses CCommon, CGI, Scanner, Header, Symbol, MM, Expression, Parser, Asm; {$segment 'cc'} var i: 1..maxPath; {loop/index variable} vDCBGS: versionDCBGS; {for checking the version number} procedure DisposeAll (userID: integer); tool($02, $11); procedure SystemQuitFlags (flags: integer); extern; begin {cc} {make sure we quit with restart set} SystemQuitFlags($4000); {get the command line info} includeFileGS.maxSize := maxPath+4; includeFileGS.theString.size := 0; for i := 1 to maxPath do includeFileGS.theString.theString[i] := chr(0); outFileGS := includeFileGS; partialFileGS := includeFileGS; infoStringGS := includeFileGS; with liDCBGS do begin pCount := 11; sFile := @includeFileGS; dFile := @outFileGS; namesList := @partialFileGS; iString := @infoStringGS; end; {with} GetLInfoGS(liDCBGS); sourceFileGS := includeFileGS; doingPartial := partialFileGS.theString.size <> 0; with liDCBGS do begin enterEditor := pFlags & flag_e <> 0; {enter editor on terminal errors?} ignoreSymbols := mFlags & flag_i <> 0; {ignore symbol file?} list := pFlags & flag_l <> 0; {list the source file?} memoryCompile := pflags & flag_m <> 0; {memory based compile?} progress := mflags & flag_p = 0; {write progress info?} rebuildSymbols := mflags & flag_r <> 0; {rebuild symbol file?} printSymbols := pflags & flag_s <> 0; {print the symbol table?} terminalErrors := pFlags & flag_t <> 0; {all errors terminal?} wait := pFlags & flag_w <> 0; {wait when an error is found?} cLineOptimize := pFlags & flag_o <> 0; {turn optimizations on?} end; {liDCB} if list then {we don't need both...} progress := false; {check the version number} vDCBGS.pCount := 1; VersionGS(vDCBGS); if vDCBGS.version[1] < '2' then TermError(10); {write the header} if list or progress then begin writeln('ORCA/C ', versionStr); writeln; end; {if} {read the source file} ReadFile; languageNumber := long(ffDCBGS.auxType).lsw; {set the default language number} {initialize the various modules} LInit; {initialize the memory pools} GInit; useGlobalPool := true; InitCCommon; {initialize the common module} {initialize the scanner} InitScanner(bofPtr,pointer(ord4(bofPtr)+ffDCBGS.fileLength)); InitParser; {initialize the parser} InitExpression; {initialize the expression evaluator} InitSymbol; {initialize the symbol table handler} InitAsm; {initialize the assembler} CodeGenScalarInit; {initialize the code generator} with liDCBGS do {generate debug code?} if pFlags & flag_d <> 0 then begin debugFlag := true; profileFlag := true; end; {if} {compile the program} InitHeader(includeFileGS); {read any precompiled headers} NextToken; {get the first token in the program} while token.kind <> eofsy do begin {compile the program} if doingFunction then DoStatement else if (token.kind in [autosy,externsy,registersy,staticsy,typedefsy,