Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

2. This question is about code generation. The first two parts make reference to the following program fragment in a Java-like language: class MyInt {

image text in transcribedimage text in transcribed

2. This question is about code generation. The first two parts make reference to the following program fragment in a Java-like language: class MyInt { private int n; public MyInt (int j) { n=j; } public int f (int x) { n=n+1; return n*x; } public MyInt g (int x) { x+n; MyInt r = new MyInt(j); return r; } } int j (b) Explain how the compilation of methods and method invocation in object-oriented languages, can be reduced to the compilation of procedures and procedure calls. Your answer should suppose an approach involving method tables. i. Write pseudocode representing how MyInt::f would be realised as a procedure, and how an invocation a.f(x) would be realised as a procedure invocation for an object a of class MyInt. [6 marks] ii. Explain briefly how method bodies are stored in memory, and how these memory locations may be found at run-time in a method invocation. [10 marks] iii. Explain briefly what advantage there is to perform such a conversion, e.g., in a compiler accepting multiple source languages. [6 marks]

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals Of Database Systems

Authors: Ramez Elmasri, Sham Navathe

4th Edition

0321122267, 978-0321122261

More Books

Students also viewed these Databases questions

Question

=+j What rules will apply to the process of negotiations?

Answered: 1 week ago