Objective-C for Unix

David Stes
email: stes@pandora.be

Last updated: May 20, 2002

Abstract:

This text is about the Objective-C language and runtime environment, as described in [#!Cox86!#]. The approach is that of a case study, devoting most of the text to the study of the architecture of a (free) Objective-C compiler for Unix. The compiler is written itself in Objective-C and Bourne shell, providing a realistic example of how Objective-C is used on Unix in combination with other software development tools, such as the Unix shell language or the makeútility, or other typical Unix compiler tools, such as lex and yacc.

Compiler Driver

Introduction

A compiler driver is a script that controls the different steps in a compilation process for an Objective-C program. Ultimately, an Objective-C program is compiled into machine instructions for some specific microprocessor, such as instructions from a Sparc, MIPS or PA-RISC processor instruction set. However, there are several compilation phases, and the compiler driver is the top-level control program that keeps track of the various compilation phases.

At first, the compiler driver will execute the C preprocessor so that macro definitions and file inclusion directives are expanded, and so that comments are removed from the source files. Next, the compiler driver will tell the stage 1 compiler to translate the output of the previous step into plain C. Finally, the compiler driver will ask a C compiler to compile the generated C code into machine instructions.

Compiling .m into .P

The file extension for Objective-C source code files is .m.

Compiling .P into .i

Compiling .i into .o

Translation Units

Nodes

Expressions

Selectors

Messages

Blocks

Statements

2


David Stes
2002-05-20