110 likes | 337 Views
Compiler Design. PROJECT PRESENTATION : COMPILER FOR OBJECTIVE C Harshal Waghmare Jeet Kumar Nandan Kumar Vishal A grawal. Objective C: An Introduction.
E N D
Compiler Design PROJECT PRESENTATION : COMPILER FOR OBJECTIVE C Harshal Waghmare Jeet Kumar Nandan Kumar Vishal Agrawal
Objective C: An Introduction The Objective-C language is defined as a small but powerful set of extensions to the standard C language., designed to give C full object-oriented programming capabilities. The Objective-C model of object-oriented programming is based on sending messages to sovereign objects. An object with method "method" is said to "respond" to the message method. [objmethod:parameter]; Objective-C messages do not need to execute because they are dynamically bound.
Interfaces and implementations Objective-C requires the interface and implementation of a class be in separately declared code blocks. The interface is put in a header file: @interface classname : superclassname{ // instance variables } //class methods //instance methods @end The actual code is written in implementation: @implementation classname +classMethod { // implementation } -instanceMethod { // implementation } @end
Instantiation This is done by first allocating the memory for a new object and then by initializing it. MyObject * o = [[MyObjectalloc] init] • Protocols An informal protocol is a list of methods which a class can implement. • Dynamic typing An object can be sent a message that is not specified in its interface. • Forwarding If message is sent to a object which might not respond to it, it forward the message on to an object which can respond to it. • Posing Objective-C permits a class to wholly replace another class within a program
History & Evolution • Hybrid between smalltalk and c. • Created primarily by Brad Cox and Tom Love who began by modifying the C compiler to add some of the capabilities of Smalltalk. • In 1988, Next released their own Objective-C compiler and libraries. • The GNU Objective-C runtime which has been in use since 1993 is the one developed by KrestenKrabThorup. • Most of Apple's present-day Cocoa API is based on OpenStep interface objects, and is the most significant Objective-C environment being used for active development.
Why better than others? • Objective-C messages do not need to execute because they are dynamically bound. If message is not implemented the code will still compile and run, unlike statically typed languages like C++. • The Objective-C protocols is better than Java or C# concept of interfaces in that a class may implement a protocol without being declared to implement that protocol. • Delegating methods to other objects and remote invocation can be easily implemented using categories and message forwarding. • Instead of using an Enumerator object to iterate through a collection, Objective-C offers the fast enumeration syntax
Since ObjC is C plus Objects, it's very compatible with C (and now C++) code bases. • Categories allow addition of methods to classes after the class's initial definition. We can redefine an existing method's implementation. • Objective-C has a dynamic run-time. It allows crafting messages at run-time, dynamically creating classes, dynamically adding methods to existing classes, changing method implementations and so on. • ObjC has real, fast, runtime message sending. • #import appends a file only if it has not been already appended, unlike #include.
Progress till now • Lexical Analysis : Completed Tool used : Lex • Syntax Analysis : Completed Tool used : Yacc • All implementations till now are in C , except that symbol table is implemented in C++.
Deadlines • 28th February : Syntax Analysis • 15th March : Semantic Analysis • 30th March : Intermediate Code Generation • 10th April : Final code Generation