<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://xinu.cs.mu.edu/index.php?action=history&amp;feed=atom&amp;title=Assignment%3A_Translation</id>
	<title>Assignment: Translation - Revision history</title>
	<link rel="self" type="application/atom+xml" href="https://xinu.cs.mu.edu/index.php?action=history&amp;feed=atom&amp;title=Assignment%3A_Translation"/>
	<link rel="alternate" type="text/html" href="https://xinu.cs.mu.edu/index.php?title=Assignment:_Translation&amp;action=history"/>
	<updated>2026-06-15T16:29:15Z</updated>
	<subtitle>Revision history for this page on the wiki</subtitle>
	<generator>MediaWiki 1.34.2</generator>
	<entry>
		<id>https://xinu.cs.mu.edu/index.php?title=Assignment:_Translation&amp;diff=3650&amp;oldid=prev</id>
		<title>Amallen: /* Notes */</title>
		<link rel="alternate" type="text/html" href="https://xinu.cs.mu.edu/index.php?title=Assignment:_Translation&amp;diff=3650&amp;oldid=prev"/>
		<updated>2010-07-30T01:53:51Z</updated>

		<summary type="html">&lt;p&gt;&lt;span dir=&quot;auto&quot;&gt;&lt;span class=&quot;autocomment&quot;&gt;Notes&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;table class=&quot;diff diff-contentalign-left&quot; data-mw=&quot;interface&quot;&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;col class=&quot;diff-marker&quot; /&gt;
				&lt;col class=&quot;diff-content&quot; /&gt;
				&lt;tr class=&quot;diff-title&quot; lang=&quot;en&quot;&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;← Older revision&lt;/td&gt;
				&lt;td colspan=&quot;2&quot; style=&quot;background-color: #fff; color: #222; text-align: center;&quot;&gt;Revision as of 01:53, 30 July 2010&lt;/td&gt;
				&lt;/tr&gt;&lt;tr&gt;&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot; id=&quot;mw-diff-left-l8&quot; &gt;Line 8:&lt;/td&gt;
&lt;td colspan=&quot;2&quot; class=&quot;diff-lineno&quot;&gt;Line 8:&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Changes must also be made to support the ''synchronized'' key word. First [[Adding Monitors To Xinu|monitors]] must be added to Xinu. The ''new'' function in the compatibility layer must acquire a monitor from the O/S and associate it with the new object. Also, ''_lock'' and ''_unlock'' functions must be added to the compatibility layer which map to the monitor ''lock'' and ''unlock'' functions added to Xinu. To achieve Java-like thread synchronization the compiler must wrap synchronized method bodies with calls to the compatibility functions ''_lock'' and ''_unlock''. It is important that the compiler ensures that the ''lock'' action precedes the evaluation of ''any'' part of the method body including evaluation of the right hand side of local variable declarations. Similarly, the ''unlock'' action must come after ''any'' part of the method body including the evaluation of the return expression.&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;Changes must also be made to support the ''synchronized'' key word. First [[Adding Monitors To Xinu|monitors]] must be added to Xinu. The ''new'' function in the compatibility layer must acquire a monitor from the O/S and associate it with the new object. Also, ''_lock'' and ''_unlock'' functions must be added to the compatibility layer which map to the monitor ''lock'' and ''unlock'' functions added to Xinu. To achieve Java-like thread synchronization the compiler must wrap synchronized method bodies with calls to the compatibility functions ''_lock'' and ''_unlock''. It is important that the compiler ensures that the ''lock'' action precedes the evaluation of ''any'' part of the method body including evaluation of the right hand side of local variable declarations. Similarly, the ''unlock'' action must come after ''any'' part of the method body including the evaluation of the return expression.&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;td class='diff-marker'&gt;+&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;ins style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/ins&gt;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;MiniJava to Xinu Compatibility Layer&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;MiniJava to Xinu Compatibility Layer&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt;−&lt;/td&gt;&lt;td style=&quot;color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;&lt;del style=&quot;font-weight: bold; text-decoration: none;&quot;&gt;&lt;/del&gt;&lt;/div&gt;&lt;/td&gt;&lt;td colspan=&quot;2&quot;&gt; &lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{| border=&amp;quot;1&amp;quot;&lt;/div&gt;&lt;/td&gt;&lt;td class='diff-marker'&gt; &lt;/td&gt;&lt;td style=&quot;background-color: #f8f9fa; color: #222; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #eaecf0; vertical-align: top; white-space: pre-wrap;&quot;&gt;&lt;div&gt;{| border=&amp;quot;1&amp;quot;&lt;/div&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</summary>
		<author><name>Amallen</name></author>
		
	</entry>
	<entry>
		<id>https://xinu.cs.mu.edu/index.php?title=Assignment:_Translation&amp;diff=3649&amp;oldid=prev</id>
		<title>Amallen: created page!</title>
		<link rel="alternate" type="text/html" href="https://xinu.cs.mu.edu/index.php?title=Assignment:_Translation&amp;diff=3649&amp;oldid=prev"/>
		<updated>2010-07-30T01:53:37Z</updated>

		<summary type="html">&lt;p&gt;created page!&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;= Overview =&lt;br /&gt;
&lt;br /&gt;
In this project students implement a translator that takes the Abstract Syntax Tree (AST) output from the semantic analysis pass in [[Assignment: Semantic Analysis|Project 4]] and converts it into an Intermediate Representation (IR) tree.&lt;br /&gt;
&lt;br /&gt;
== Notes ==&lt;br /&gt;
&lt;br /&gt;
The AST representations of the Xinu external calls must be mapped to IR nodes that reference the corresponding underlying runtime functions. Care must be taken at this point to choose runtime function names that will not conflict with legitimate source language method names; we follow longstanding tradition and append an underscore to the runtime function names. The mapping of I/O and threading functions is self-explanatory, but also at this point we need to add in a dynamic memory allocation function to support the source language ''new'' operator for instantiating new objects and arrays. In addition, if the compiler is to support Java-like runtime checking for null pointers and array bounds, corresponding runtime error handlers must be mapped. The figure below gives a brief description of each part of the MiniJava to Xinu Compatability Layer, but the full [[Xinu Compatability Layer|&amp;lt;code&amp;gt;'''c'''&amp;lt;/code&amp;gt; file]] is also available.&lt;br /&gt;
&lt;br /&gt;
Changes must also be made to support the ''synchronized'' key word. First [[Adding Monitors To Xinu|monitors]] must be added to Xinu. The ''new'' function in the compatibility layer must acquire a monitor from the O/S and associate it with the new object. Also, ''_lock'' and ''_unlock'' functions must be added to the compatibility layer which map to the monitor ''lock'' and ''unlock'' functions added to Xinu. To achieve Java-like thread synchronization the compiler must wrap synchronized method bodies with calls to the compatibility functions ''_lock'' and ''_unlock''. It is important that the compiler ensures that the ''lock'' action precedes the evaluation of ''any'' part of the method body including evaluation of the right hand side of local variable declarations. Similarly, the ''unlock'' action must come after ''any'' part of the method body including the evaluation of the return expression.&lt;br /&gt;
&lt;br /&gt;
MiniJava to Xinu Compatibility Layer&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| border=&amp;quot;1&amp;quot;&lt;br /&gt;
| Xinu function || Purpose&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;int _readint(void)&amp;lt;/code&amp;gt; || Parse in integer input&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;syscall _printint(int i)&amp;lt;/code&amp;gt; || Print an integer&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;syscall _print(char *s)&amp;lt;/code&amp;gt; || Print a string literal&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;syscall _println(void)&amp;lt;/code&amp;gt; || Print a carriage return&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;syscall _threadCreate(int *t)&amp;lt;/code&amp;gt; || Spawn a new thread of execution, running t's &amp;lt;code&amp;gt;run&amp;lt;/code&amp;gt; method  &lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;syscall _yield(void)&amp;lt;/code&amp;gt; || Yield the processor&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;syscall _sleep(int time)&amp;lt;/code&amp;gt; || Sleep &amp;lt;code&amp;gt;time&amp;lt;/code&amp;gt; number of milliseconds&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;syscall _lock(int *obj)&amp;lt;/code&amp;gt; || Lock the monitor associated with object &amp;lt;code&amp;gt;obj&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;syscall _unlock(int *obj)&amp;lt;/code&amp;gt; || Unlock the monitor associated with object &amp;lt;code&amp;gt;obj&amp;lt;/code&amp;gt;&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;int *_new(int n, int f)&amp;lt;/code&amp;gt; || Allocate array or allocate object and associate a monitor with that object&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;void _BADPTR(void)&amp;lt;/code&amp;gt; || Null pointer exception&lt;br /&gt;
|-&lt;br /&gt;
| &amp;lt;code&amp;gt;void _BADSUB(void)&amp;lt;/code&amp;gt; || Bounds exception&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Amallen</name></author>
		
	</entry>
</feed>