From owner-g22_3130_001_sp00@cs.nyu.edu Fri Jan 21 10:30 EST 2000 Date: Fri, 21 Jan 2000 10:30:37 -0500 (EST) X-Authentication-Warning: griffin.cs.nyu.edu: goldberg set sender to goldberg@griffin.cs.nyu.edu using -f From: Benjamin Goldberg To: g22_3130_001_sp00@cs.nyu.edu Subject: Course web page Reply-to: goldberg@cs.nyu.edu Sender: owner-g22_3130_001_sp00@cs.nyu.edu Precedence: bulk Content-Type: text Content-Length: 148 Please check the course web page frequently. Some new documents have been added this morning, along with corrections to existing ones. -Ben From owner-g22_3130_001_sp00@cs.nyu.edu Fri Jan 21 10:50 EST 2000 Date: Fri, 21 Jan 2000 10:50:04 -0500 (EST) X-Authentication-Warning: griffin.cs.nyu.edu: goldberg set sender to goldberg@griffin.cs.nyu.edu using -f From: Benjamin Goldberg To: g22_3130_001_sp00@cs.nyu.edu Subject: Notification when the course web page changes Reply-to: goldberg@cs.nyu.edu Sender: owner-g22_3130_001_sp00@cs.nyu.edu Precedence: bulk Content-Type: text Content-Length: 454 It occurs to me that you might consider being notified automatically when the course web page changes. NetMind is a service that does such a thing. If you are interested, go to www.netmind.com, click on "quick add", and then follow the directions to specify that you want to be notified by email when the web page, http://cs.nyu.edu/courses/spring00/G22.3130-001/index.htm changes. There's no charge for the service. Just a thought... -Ben From owner-g22_3130_001_sp00@cs.nyu.edu Tue Jan 25 14:05 EST 2000 Date: Tue, 25 Jan 2000 14:04:59 -0500 (EST) X-Authentication-Warning: griffin.cs.nyu.edu: goldberg set sender to goldberg@griffin.cs.nyu.edu using -f From: Benjamin Goldberg To: g22_3130_001_sp00@cs.nyu.edu Subject: Class today Reply-to: goldberg@cs.nyu.edu Sender: owner-g22_3130_001_sp00@cs.nyu.edu Precedence: bulk Content-Type: text Content-Length: 248 The honors compilers class will be held as usual today. However, if you are unable to attend due to the snowstorm, please contact me and I will be happy to schedule an appointment with you where I go over the material from the class. -Ben From owner-g22_3130_001_sp00@cs.nyu.edu Tue Jan 25 14:24 EST 2000 Date: Tue, 25 Jan 2000 14:24:42 -0500 (EST) X-Authentication-Warning: griffin.cs.nyu.edu: goldberg set sender to goldberg@griffin.cs.nyu.edu using -f From: Benjamin Goldberg To: g22_3130_001_sp00@cs.nyu.edu Subject: Submitting assignments Reply-to: goldberg@cs.nyu.edu Sender: owner-g22_3130_001_sp00@cs.nyu.edu Precedence: bulk Content-Type: text Content-Length: 107 Please submit your assignments directly to Emily (emily@cs), you do not need to send them to me. -Ben From owner-g22_3130_001_sp00@cs.nyu.edu Tue Jan 25 19:24 EST 2000 Date: Tue, 25 Jan 2000 19:24:12 -0500 (EST) X-Authentication-Warning: griffin.cs.nyu.edu: goldberg set sender to goldberg@griffin.cs.nyu.edu using -f From: Benjamin Goldberg To: g22_3130_001_sp00@cs.nyu.edu Subject: JavaCC Reply-to: goldberg@cs.nyu.edu Sender: owner-g22_3130_001_sp00@cs.nyu.edu Precedence: bulk Content-Type: text Content-Length: 563 ------- Start of forwarded message ------- Walter williams writes: > From: Walter Williams > I looked at the JavaCC web site, www.metamata.com/JavaCC/features.html > It says that it doesn't generate a table driven parser, it generates a > Recursive Descent parser (top-down, LL, etc). I don't think it matters > for Pointless, though. That's interesting. I would have expected JavaCC to be equal in power to the popular parser generators, YACC and BISON, which generate LALR parsers (bottom up, rightmost-derivation, etc). -Ben From owner-g22_3130_001_sp00@cs.nyu.edu Thu Jan 27 08:42 EST 2000 Date: Thu, 27 Jan 2000 08:42:04 -0500 (EST) X-Authentication-Warning: griffin.cs.nyu.edu: goldberg set sender to goldberg@griffin.cs.nyu.edu using -f From: Benjamin Goldberg To: g22_3130_001_sp00@cs.nyu.edu Subject: Files Reply-to: goldberg@cs.nyu.edu Sender: owner-g22_3130_001_sp00@cs.nyu.edu Precedence: bulk Content-Type: text Content-Length: 189 Folks, Emily has fixed some typos in the Pointless language specification and in the Java classes for the intermediate representation. Please reload them from the web page. -Ben From goldberg@griffin.cs.nyu.edu Tue Feb 15 00:14:47 2000 Date: 11 Feb 2000 15:59:13 -0500 From: Benjamin Goldberg To: g22_3130_001_sp00@cs.nyu.edu Subject: Type Checking Assignment - you have 11 days! Reply-to: goldberg@cs.nyu.edu The assignment for the next phase of your compiler - the type checker - is on the web. Please read it carefully and make sure you understand it. Emily has also put an updated version of the Java class definitions on the web, which adds the necessary stuff for type checking. Please look that over soon and let Emily know if you have questions. Please consider this a beta version of the Java code, which might be updated shortly. Get to work! :-) -Ben From goldberg@griffin.cs.nyu.edu Tue Feb 15 00:14:52 2000 Date: 14 Feb 2000 20:06:26 -0500 From: Benjamin Goldberg To: g22_3130_001_sp00@cs.nyu.edu Subject: Java IR classes updated Reply-to: goldberg@cs.nyu.edu Folks, The file containing the Java class definitions for the intermediate representation has been updated (Mon. eve.) -Ben From owner-g22_3130_001_sp00@cs.nyu.edu Mon Feb 14 21:12 EST 2000 MIME-Version: 1.0 X-Authentication-Warning: cs.nyu.edu: majordom set sender to owner-g22_3130_001_sp00@cs.nyu.edu using -f Date: Mon, 14 Feb 2000 21:12:08 -0500 (EST) From: Emily Chapman To: g22_3130_001_sp00@cs.nyu.edu Subject: type checker Sender: owner-g22_3130_001_sp00@cs.nyu.edu Precedence: bulk Content-Type: TEXT/PLAIN; charset=US-ASCII Content-Length: 1386 Dear class, The revised skeleton is now on the web. Any questions/ comments/suggestions are welcome. I am more then happy to help. Now, the reason the skeleton has been provided is two-fold: The first is that if you plan to work with other people during the optimization phase of the project, having very similar implementations makes collaboration much easier! The second is that if you are unsure about how to proceed, this skeleton has been designed to guide you through a relatively easy implementation, so the time it takes to program the type checker should be reduced. So if you do not want to collaborate later on and feel confident about how to implement the type checker on your own, feel free to do so. Though if you do, make sure you modify the printme of the VarDeclNode to display the variable's offset so that I can tell if its right. Again to grade this assignment, I will send a message to the list (this time as pine attachments to avoid line wrapping problems) containing test files. (As I assume that your program halts when encountering the first type error, I need separate tests to test for each type of type error) I ask that you then send me your type checkers as attachments to the pine message, and all of the output from all the tests in the BODY of the message:-). Good luck! Emily From owner-g22_3130_001_sp00@cs.nyu.edu Fri Feb 18 18:55 EST 2000 MIME-Version: 1.0 X-Authentication-Warning: cs.nyu.edu: majordom set sender to owner-g22_3130_001_sp00@cs.nyu.edu using -f Date: Fri, 18 Feb 2000 18:55:32 -0500 (EST) From: Emily Chapman To: g22_3130_001_sp00@cs.nyu.edu Subject: type checker clarification: In-Reply-To: Sender: owner-g22_3130_001_sp00@cs.nyu.edu Precedence: bulk Content-Type: TEXT/PLAIN; charset=US-ASCII Content-Length: 695 Dear class, I hope this will help clarify what you are being asked to do: a) You are required to have records such that Record A{B x;} Record B{...} Typechecks. Any function or global variable that uses type A must occur after both A and B have been defined. (Its not that hard to do it all the way but that's not what is being asked). b) You are allowed to loop if Records are mutually recursive. c) f() can call g() even if g() is declaired after f. d) One thing that was misdocumented in the code skeleton, is that that RecordEnv.init() does NOT add itself to the RecordEnv, that must be done before init is called. (It's one line if you add it to the parser) Good luck! Emily From owner-g22_3130_001_sp00@cs.nyu.edu Sun Feb 20 14:12 EST 2000 MIME-Version: 1.0 X-Authentication-Warning: cs.nyu.edu: majordom set sender to owner-g22_3130_001_sp00@cs.nyu.edu using -f Date: Sun, 20 Feb 2000 14:11:51 -0500 (EST) From: Emily Chapman To: g22_3130_001_sp00@cs.nyu.edu Subject: type checker clarification, the second Sender: owner-g22_3130_001_sp00@cs.nyu.edu Precedence: bulk Content-Type: TEXT/PLAIN; charset=US-ASCII Content-Length: 1003 Dear class, Just to clarify my previous message: >a) >You are required to have records such that > Record A{B x;} > Record B{...} >Typechecks. > >Any function or global variable that uses type A must occur after >both A and B have been defined. (Its not that hard to do it all the >way but that's not what is being asked). What I meant here was that although you could easily implement your type checker so that a function or global variable declaratation appears before the declaration of a type used in the function or variable declaration, your compiler should not permit it. >b) You are allowed to loop if Records are mutually recursive. What I meant here is that a valid program cannot contain mutually recursive records, since they would be of infinite size. However, I'm not requiring that you test for this case (so your compiler might loop indefinitely by trying to type check these records). Good luck and feel free to e-mail me if you have any questions! Emily From owner-g22_3130_001_sp00@cs.nyu.edu Fri Feb 25 08:57 EST 2000 X-Authentication-Warning: cs.nyu.edu: majordom set sender to owner-g22_3130_001_sp00@cs.nyu.edu using -f Date: Fri, 25 Feb 2000 08:57:51 -0500 (EST) From: Benjamin Goldberg To: g22_3130_001_sp00@cs.nyu.edu Subject: Intermediate Code Generation Assignment, due March 10 Reply-to: goldberg@cs.nyu.edu Sender: owner-g22_3130_001_sp00@cs.nyu.edu Precedence: bulk Content-Type: text Content-Length: 286 Folks, The assignment for the next phase of the compiler, intermdiate code generation, is on the course web page. It is due two weeks from today. Please get started immediately. I will be out of email contact for a few days. Please direct questions to Emily. Good luck! -Ben From owner-g22_3130_001_sp00@cs.nyu.edu Mon Mar 6 21:24 EST 2000 MIME-Version: 1.0 X-Authentication-Warning: cs.nyu.edu: majordom set sender to owner-g22_3130_001_sp00@cs.nyu.edu using -f Date: Mon, 6 Mar 2000 21:24:35 -0500 (EST) From: Emily Chapman To: g22_3130_001_sp00@cs.nyu.edu Subject: common questions Sender: owner-g22_3130_001_sp00@cs.nyu.edu Precedence: bulk Content-Type: TEXT/PLAIN; charset=US-ASCII Content-Length: 497 Dear class, A couple of students have asked about for loops, so I thought it might be of general interest to the list. a) In the loop "for i = 1 to 20", is the body executed for the i=20 case? answer:yes b) Do for loops evaluate their starting and ending condition once or every time through the loop? answer: once, use a while loop to evaluate conditions every time. c) If a for loop's begining condition is greater then its ending one, is the loop body evaluated once? answer: no. From owner-g22_3130_001_sp00@cs.nyu.edu Fri Mar 10 14:31 EST 2000 MIME-Version: 1.0 X-Authentication-Warning: cs.nyu.edu: majordom set sender to owner-g22_3130_001_sp00@cs.nyu.edu using -f Date: Fri, 10 Mar 2000 14:31:35 -0500 (EST) From: Emily Chapman To: g22_3130_001_sp00@cs.nyu.edu Subject: Here's the intermediate code generation test Sender: owner-g22_3130_001_sp00@cs.nyu.edu Precedence: bulk Content-Type: TEXT/PLAIN; charset=US-ASCII Content-Length: 1601 function parenTest() { String s; s := ((("hello"))); } record Date { Int day; Int month; Int year; } record Action { Date date; String info; } function newDate(Int nday, Int nmonth, Int nyear) : Date { Date out; out.day := nday; out.month := nmonth; out.year := nyear; return out; } function date():Date { return newDate(2,4,7); } function newAction(Date d, String s):Action { Action out; out.date := d; out.info := s; return out; } function action():Action { return newAction(date(), ""); } record Trade { Date date; Int cost; Int shares; Int numActions; Action [100 ] actions; } function newTrade(Date d, Int c, Int s, Int na, Action [100 ] as):Trade { Trade out; out.date:=d; out.cost:=c; out.shares:= s; out.numActions:= na; out.actions := as; return out; } function trade():Trade { Action [100 ] actions; for i = 1 to 100 do actions[i] := action(); return newTrade(date(), 0, 0, 0, actions); } record Position { String name; Int numTrades; Trade [100 ] trades; } Position blankPosition; function newPosition(String n, Int nt, Trade [100 ] ntrades):Position { Position out; out.name := n; out.numTrades := nt; out.trades := ntrades; return out; } record Account { Date begin; Int numPositions; String person; Position [100 ] assets; } Account blankAccount; function even(Int num):Bool { if num = 0 then return true; else return odd(num - 1); fi; return false; } function odd(Int num):Bool { if num = 1 then return true; else return even(num - 1); fi; return false; } From owner-g22_3130_001_sp00@cs.nyu.edu Mon Mar 13 11:58 EST 2000 X-Authentication-Warning: cs.nyu.edu: majordom set sender to owner-g22_3130_001_sp00@cs.nyu.edu using -f Date: Mon, 13 Mar 2000 11:58:06 -0500 (EST) From: Benjamin Goldberg To: g22_3130_001_sp00@cs.nyu.edu Subject: Assignment 5: Assembly Code generation Reply-to: goldberg@cs.nyu.edu Sender: owner-g22_3130_001_sp00@cs.nyu.edu Precedence: bulk Content-Type: text Content-Length: 146 The next assignment, assembly code generation, is on the course web page. It is due two weeks from today, please get started ASAP! -Ben From owner-g22_3130_001_sp00@cs.nyu.edu Mon Mar 27 23:56 EST 2000 MIME-Version: 1.0 X-Authentication-Warning: cs.nyu.edu: majordom set sender to owner-g22_3130_001_sp00@cs.nyu.edu using -f Date: Mon, 27 Mar 2000 23:56:03 -0500 (EST) From: Emily Chapman To: g22_3130_001_sp00@cs.nyu.edu Subject: test-file. Sender: owner-g22_3130_001_sp00@cs.nyu.edu Precedence: bulk Content-Type: MULTIPART/MIXED; BOUNDARY="-559023410-1804928587-954219348=:1591" Content-Length: 6367 Dear class, Here is a test file, complete with bugs :-). Don't worry if it takes you a day or so to get your assembly to run. When you send in your results make sure you include explicit and EASY instructions on how to run your compiler, as I may well be doing some additional tests as well. Print the results of running your assembled program in the body of the message and attatch the assembly program to the message. If your assembly does not work on the standard linux gcc platform, let me know or you will have a very confused TA. Good luck, Emily ------- Test goes here and is attached ------- record Vector { Int length; Int [100] items; } function fillVector(Vector v, Int offset, Int length) : Vector { v.length := length; for i = 1 to length do v.items[i] := i+offset; return v; } record Mesh { Int length; Vector [100] vectors; } function fillMesh(Mesh m, Int offset, Int rowoffset, Int length, Int width) : Mesh { for i = 1 to 100 do if i < length + 1 then m.vectors[i].length := width; else m.vectors[i].length := 0; fi; for i = 1 to length do for j = 1 to width do m.vectors[i].items[j] := i+offset+i*rowoffset; return m; } function wierd1(Int x) : Int { if (x/12)*12 = x then return x; else_if x < 10 then return wierd1(x+120); else return wierd1(x/3); fi; return 0; } function averageVector(Vector v):Int { Int i; i := 1; Int sum; sum := 0; while(i < v.length + 1) do { sum := sum + v.items[i]; i := i + 1; } return sum / (i-1); } function averageMesh(Mesh m):Int { Int i; i := 1; Int sum; sum := 0; Int count; count := 0; while(i < m.length + 1) do { sum := sum + averageVector(m.vectors[i]); count := count + m.vectors[i].length; i := i + 1; } return sum / count; } function and(Bool a, Bool b) : Bool { if a then return b; fi; return false; } function or(Bool a, Bool b) : Bool { if a then return true; fi; return b; } function is(Bool b) { if b then $printf("true\n"):Int; else $printf("false\n"):Int; fi; } function main():Int { Bool happy; Bool sad; happy := true; sad := false; is(and(happy, sad)); is(or(happy,sad)); is(or(sad,sad)); is(and(happy, happy)); Mesh m; m := fillMesh(m, 0, 100, 100,100); Int bigAverage; bigAverage := averageMesh(m); $printf("big average: %d\n", bigAverage):Int; m := fillMesh(m, 0, 50, 50,50); Int smallAverage; bigAverage := averageMesh(m); $printf("small average: %d\n", bigAverage):Int; $printf("Wierd values: %d %d %d %d %d %d\n", wierd1(1), wierd1(12), wierd1(50), wierd1(110), wierd1(100000), wierd1(1200)):Int; return 0; } record Vector { Int length; Int [100] items; } function fillVector(Vector v, Int offset, Int length) : Vector { v.length := length; for i = 1 to length do v.items[i] := i+offset; return v; } record Mesh { Int length; Vector [100] vectors; } function fillMesh(Mesh m, Int offset, Int rowoffset, Int length, Int width) : Mesh { for i = 1 to 100 do if i < length + 1 then m.vectors[i].length := width; else m.vectors[i].length := 0; fi; for i = 1 to length do for j = 1 to width do m.vectors[i].items[j] := i+offset+i*rowoffset; return m; } function wierd1(Int x) : Int { if (x/12)*12 = x then return x; else_if x < 10 then return wierd1(x+120); else return wierd1(x/3); fi; return 0; } function averageVector(Vector v):Int { Int i; i := 1; Int sum; sum := 0; while(i < v.length + 1) do { sum := sum + v.items[i]; i := i + 1; } return sum / (i-1); } function averageMesh(Mesh m):Int { Int i; i := 1; Int sum; sum := 0; Int count; count := 0; while(i < m.length + 1) do { sum := sum + averageVector(m.vectors[i]); count := count + m.vectors[i].length; i := i + 1; } return sum / count; } function and(Bool a, Bool b) : Bool { if a then return b; fi; return false; } function or(Bool a, Bool b) : Bool { if a then return true; fi; return b; } function is(Bool b) { if b then $printf("true\n"):Int; else $printf("false\n"):Int; fi; } function main():Int { Bool happy; Bool sad; happy := true; sad := false; is(and(happy, sad)); is(or(happy,sad)); is(or(sad,sad)); is(and(happy, happy)); Mesh m; m := fillMesh(m, 0, 100, 100,100); Int bigAverage; bigAverage := averageMesh(m); $printf("big average: %d\n", bigAverage):Int; m := fillMesh(m, 0, 50, 50,50); Int smallAverage; bigAverage := averageMesh(m); $printf("small average: %d\n", bigAverage):Int; $printf("Wierd values: %d %d %d %d %d %d\n", wierd1(1), wierd1(12), wierd1(50), wierd1(110), wierd1(100000), wierd1(1200)):Int; return 0; }  -=- MIME -=-  This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. Send mail to mime@docserver.cac.washington.edu for more info. ---559023410-1804928587-954219348=:1591 Content-Type: TEXT/PLAIN; charset=US-ASCII Dear class, Here is a test file, complete with bugs :-). Don't worry if it takes you a day or so to get your assembly to run. When you send in your results make sure you include explicit and EASY instructions on how to run your compiler, as I may well be doing some additional tests as well. Print the results of running your assembled program in the body of the message and attatch the assembly program to the message. If your assembly does not work on the standard linux gcc platform, let me know or you will have a very confused TA. Good luck, Emily ------- Test goes here and is attached ------- record Vector { Int length; Int [100] items; } function fillVector(Vector v, Int offset, Int length) : Vector { v.length := length; for i = 1 to length do v.items[i] := i+offset; return v; } record Mesh { Int length; Vector [100] vectors; } function fillMesh(Mesh m, Int offset, Int rowoffset, Int length, Int width) : Mesh { for i = 1 to 100 do if i < length + 1 then m.vectors[i].length := width; else m.vectors[i].length := 0; fi; for i = 1 to length do for j = 1 to width do m.vectors[i].items[j] := i+offset+i*rowoffset; return m; } function wierd1(Int x) : Int { if (x/12)*12 = x then return x; else_if x < 10 then return wierd1(x+120); else return wierd1(x/3); fi; return 0; } function averageVector(Vector v):Int { Int i; i := 1; Int sum; sum := 0; while(i < v.length + 1) do { sum := sum + v.items[i]; i := i + 1; } return sum / (i-1); } function averageMesh(Mesh m):Int { Int i; i := 1; Int sum; sum := 0; Int count; count := 0; while(i < m.length + 1) do { sum := sum + averageVector(m.vectors[i]); count := count + m.vectors[i].length; i := i + 1; } return sum / count; } function and(Bool a, Bool b) : Bool { if a then return b; fi; return false; } function or(Bool a, Bool b) : Bool { if a then return true; fi; return b; } function is(Bool b) { if b then $printf("true\n"):Int; else $printf("false\n"):Int; fi; } function main():Int { Bool happy; Bool sad; happy := true; sad := false; is(and(happy, sad)); is(or(happy,sad)); is(or(sad,sad)); is(and(happy, happy)); Mesh m; m := fillMesh(m, 0, 100, 100,100); Int bigAverage; bigAverage := averageMesh(m); $printf("big average: %d\n", bigAverage):Int; m := fillMesh(m, 0, 50, 50,50); Int smallAverage; bigAverage := averageMesh(m); $printf("small average: %d\n", bigAverage):Int; $printf("Wierd values: %d %d %d %d %d %d\n", wierd1(1), wierd1(12), wierd1(50), wierd1(110), wierd1(100000), wierd1(1200)):Int; return 0; } ---559023410-1804928587-954219348=:1591 Content-Type: TEXT/PLAIN; charset=US-ASCII; name="AssemblyTest2.ptls" Content-Transfer-Encoding: BASE64 Content-ID: Content-Description: Content-Disposition: attachment; filename="AssemblyTest2.ptls" cmVjb3JkIFZlY3RvciB7DQogIEludCBsZW5ndGg7DQogIEludCBbMTAwXSBp dGVtczsgfQ0KDQpmdW5jdGlvbiBmaWxsVmVjdG9yKFZlY3RvciB2LCBJbnQg b2Zmc2V0LCBJbnQgbGVuZ3RoKSA6IFZlY3RvciB7DQogIHYubGVuZ3RoIDo9 IGxlbmd0aDsNCiAgZm9yIGkgPSAxIHRvIGxlbmd0aCBkbw0KICAgIHYuaXRl bXNbaV0gOj0gaStvZmZzZXQ7IA0KICByZXR1cm4gdjsNCn0NCg0KcmVjb3Jk IE1lc2ggew0KICBJbnQgbGVuZ3RoOw0KICBWZWN0b3IgWzEwMF0gdmVjdG9y czsgfQ0KDQpmdW5jdGlvbiBmaWxsTWVzaChNZXNoIG0sIEludCBvZmZzZXQs IEludCByb3dvZmZzZXQsIEludCBsZW5ndGgsIEludCB3aWR0aCkgOiBNZXNo IHsNCiAgZm9yIGkgPSAxIHRvIDEwMCBkbw0KICAgIGlmIGkgPCBsZW5ndGgg KyAxIHRoZW4NCiAgICAgIG0udmVjdG9yc1tpXS5sZW5ndGggOj0gd2lkdGg7 DQogICAgZWxzZQ0KICAgICAgbS52ZWN0b3JzW2ldLmxlbmd0aCA6PSAwOw0K ICAgIGZpOw0KICBmb3IgaSA9IDEgdG8gbGVuZ3RoIGRvDQogICAgZm9yIGog PSAxIHRvIHdpZHRoIGRvDQogICAgICBtLnZlY3RvcnNbaV0uaXRlbXNbal0g Oj0gaStvZmZzZXQraSpyb3dvZmZzZXQ7IA0KICByZXR1cm4gbTsg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3130_001_sp00@cs.nyu.edu Tue Mar 28 15:28 EST 2000 MIME-Version: 1.0 X-Authentication-Warning: cs.nyu.edu: majordom set sender to owner-g22_3130_001_sp00@cs.nyu.edu using -f Date: Tue, 28 Mar 2000 15:28:13 -0500 (EST) From: Emily Chapman To: g22_3130_001_sp00@cs.nyu.edu Subject: new, improved test file Sender: owner-g22_3130_001_sp00@cs.nyu.edu Precedence: bulk Content-Type: MULTIPART/MIXED; BOUNDARY="-559023410-851401618-954275293=:21400" Content-Length: 5963 Hi! The previous test file had the problem that wierd1 had an infinite loop on the inputs it was given. This problem has been fixed (as far as I know). The new, fixed code is below, and attached ---------------------below is the test file record Vector { Int length; Int [100] items; } function fillVector(Vector v, Int offset, Int length) : Vector { v.length := length; for i = 1 to length do v.items[i] := i+offset; return v; } record Mesh { Int length; Vector [100] vectors; } function fillMesh(Mesh m, Int offset, Int rowoffset, Int length, Int width) : Mesh { for i = 1 to 100 do if i < length + 1 then m.vectors[i].length := width; else m.vectors[i].length := 0; fi; for i = 1 to length do for j = 1 to width do m.vectors[i].items[j] := i+offset+i*rowoffset; return m; } function wierd1(Int x) : Int { if (x/12)*12 = x then return x; else_if x < 10 then return wierd1(x+100); else return wierd1(x/2); fi; return 0; } function averageVector(Vector v):Int { Int i; i := 1; Int sum; sum := 0; while(i < v.length + 1) do { sum := sum + v.items[i]; i := i + 1; } return sum / (i-1); } function averageMesh(Mesh m):Int { Int i; i := 1; Int sum; sum := 0; Int count; count := 0; while(i < m.length + 1) do { sum := sum + averageVector(m.vectors[i]); count := count + m.vectors[i].length; i := i + 1; } return sum / count; } function and(Bool a, Bool b) : Bool { if a then return b; fi; return false; } function or(Bool a, Bool b) : Bool { if a then return true; fi; return b; } function is(Bool b) { if b then $printf("true\n"):Int; else $printf("false\n"):Int; fi; } function main():Int { Bool happy; Bool sad; happy := true; sad := false; is(and(happy, sad)); is(or(happy,sad)); is(or(sad,sad)); is(and(happy, happy)); Mesh m; m := fillMesh(m, 0, 100, 100,100); Int bigAverage; bigAverage := averageMesh(m); $printf("big average: %d\n", bigAverage):Int; m := fillMesh(m, 0, 50, 50,50); Int smallAverage; bigAverage := averageMesh(m); $printf("small average: %d\n", bigAverage):Int; $printf("Wierd values: %d %d %d %d %d\n", wierd1(1), wierd1(12), wierd1(50), wierd1(100000), wierd1(1200)):Int; return 0; } record Vector { Int length; Int [100] items; } function fillVector(Vector v, Int offset, Int length) : Vector { v.length := length; for i = 1 to length do v.items[i] := i+offset; return v; } record Mesh { Int length; Vector [100] vectors; } function fillMesh(Mesh m, Int offset, Int rowoffset, Int length, Int width) : Mesh { for i = 1 to 100 do if i < length + 1 then m.vectors[i].length := width; else m.vectors[i].length := 0; fi; for i = 1 to length do for j = 1 to width do m.vectors[i].items[j] := i+offset+i*rowoffset; return m; } function wierd1(Int x) : Int { if (x/12)*12 = x then return x; else_if x < 10 then return wierd1(x+100); else return wierd1(x/2); fi; return 0; } function averageVector(Vector v):Int { Int i; i := 1; Int sum; sum := 0; while(i < v.length + 1) do { sum := sum + v.items[i]; i := i + 1; } return sum / (i-1); } function averageMesh(Mesh m):Int { Int i; i := 1; Int sum; sum := 0; Int count; count := 0; while(i < m.length + 1) do { sum := sum + averageVector(m.vectors[i]); count := count + m.vectors[i].length; i := i + 1; } return sum / count; } function and(Bool a, Bool b) : Bool { if a then return b; fi; return false; } function or(Bool a, Bool b) : Bool { if a then return true; fi; return b; } function is(Bool b) { if b then $printf("true\n"):Int; else $printf("false\n"):Int; fi; } function main():Int { Bool happy; Bool sad; happy := true; sad := false; is(and(happy, sad)); is(or(happy,sad)); is(or(sad,sad)); is(and(happy, happy)); Mesh m; m := fillMesh(m, 0, 100, 100,100); Int bigAverage; bigAverage := averageMesh(m); $printf("big average: %d\n", bigAverage):Int; m := fillMesh(m, 0, 50, 50,50); Int smallAverage; bigAverage := averageMesh(m); $printf("small average: %d\n", bigAverage):Int; $printf("Wierd values: %d %d %d %d %d\n", wierd1(1), wierd1(12), wierd1(50), wierd1(100000), wierd1(1200)):Int; return 0; }  -=- MIME -=-  This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. Send mail to mime@docserver.cac.washington.edu for more info. ---559023410-851401618-954275293=:21400 Content-Type: TEXT/PLAIN; charset=US-ASCII Hi! The previous test file had the problem that wierd1 had an infinite loop on the inputs it was given. This problem has been fixed (as far as I know). The new, fixed code is below, and attached ---------------------below is the test file record Vector { Int length; Int [100] items; } function fillVector(Vector v, Int offset, Int length) : Vector { v.length := length; for i = 1 to length do v.items[i] := i+offset; return v; } record Mesh { Int length; Vector [100] vectors; } function fillMesh(Mesh m, Int offset, Int rowoffset, Int length, Int width) : Mesh { for i = 1 to 100 do if i < length + 1 then m.vectors[i].length := width; else m.vectors[i].length := 0; fi; for i = 1 to length do for j = 1 to width do m.vectors[i].items[j] := i+offset+i*rowoffset; return m; } function wierd1(Int x) : Int { if (x/12)*12 = x then return x; else_if x < 10 then return wierd1(x+100); else return wierd1(x/2); fi; return 0; } function averageVector(Vector v):Int { Int i; i := 1; Int sum; sum := 0; while(i < v.length + 1) do { sum := sum + v.items[i]; i := i + 1; } return sum / (i-1); } function averageMesh(Mesh m):Int { Int i; i := 1; Int sum; sum := 0; Int count; count := 0; while(i < m.length + 1) do { sum := sum + averageVector(m.vectors[i]); count := count + m.vectors[i].length; i := i + 1; } return sum / count; } function and(Bool a, Bool b) : Bool { if a then return b; fi; return false; } function or(Bool a, Bool b) : Bool { if a then return true; fi; return b; } function is(Bool b) { if b then $printf("true\n"):Int; else $printf("false\n"):Int; fi; } function main():Int { Bool happy; Bool sad; happy := true; sad := false; is(and(happy, sad)); is(or(happy,sad)); is(or(sad,sad)); is(and(happy, happy)); Mesh m; m := fillMesh(m, 0, 100, 100,100); Int bigAverage; bigAverage := averageMesh(m); $printf("big average: %d\n", bigAverage):Int; m := fillMesh(m, 0, 50, 50,50); Int smallAverage; bigAverage := averageMesh(m); $printf("small average: %d\n", bigAverage):Int; $printf("Wierd values: %d %d %d %d %d\n", wierd1(1), wierd1(12), wierd1(50), wierd1(100000), wierd1(1200)):Int; return 0; } ---559023410-851401618-954275293=:21400 Content-Type: TEXT/PLAIN; charset=US-ASCII; name="AssemblyTest2.ptls" Content-Transfer-Encoding: BASE64 Content-ID: Content-Description: Content-Disposition: attachment; filename="AssemblyTest2.ptls" cmVjb3JkIFZlY3RvciB7DQogIEludCBsZW5ndGg7DQogIEludCBbMTAwXSBp dGVtczsgfQ0KDQpmdW5jdGlvbiBmaWxsVmVjdG9yKFZlY3RvciB2LCBJbnQg b2Zmc2V0LCBJbnQgbGVuZ3RoKSA6IFZlY3RvciB7DQogIHYubGVuZ3RoIDo9 IGxlbmd0aDsNCiAgZm9yIGkgPSAxIHRvIGxlbmd0aCBkbw0KICAgIHYuaXRl bXNbaV0gOj0gaStvZmZzZXQ7IA0KICByZXR1cm4gdjsNCn0NCg0KcmVjb3Jk IE1lc2ggew0KICBJbnQgbGVuZ3RoOw0KICBWZWN0b3IgWzEwMF0gdmVjdG9y czsgfQ0KDQpmdW5jdGlvbiBmaWxsTWVzaChNZXNoIG0sIEludCBvZmZzZXQs IEludCByb3dvZmZzZXQsIEludCBsZW5ndGgsIEludCB3aWR0aCkgOiBNZXNo IHsNCiAgZm9yIGkgPSAxIHRvIDEwMCBkbw0KICAgIGlmIGkgPCBsZW5ndGgg KyAxIHRoZW4NCiAgICAgIG0udmVjdG9yc1tpXS5sZW5ndGggOj0gd2lkdGg7 DQogICAgZWxzZQ0KICAgICAgbS52ZWN0b3JzW2ldLmxlbmd0aCA6PSAwOw0K ICAgIGZpOw0KICBmb3IgaSA9IDEgdG8gbGVuZ3RoIGRvDQogICAgZm9yIGog PSAxIHRvIHdpZHRoIGRvDQogICAgICBtLnZlY3RvcnNbaV0uaXRlbXNbal0g Oj0gaStvZmZzZXQraSpyb3dvZmZzZXQ7IA0KICByZXR1cm4gbTsgfQ0KDQpm dW5jdGlvbiB3aWVyZDEoSW50IHgpIDogSW50IHsNCiAgaWYgKHgvMTIpKjEy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b24gaXMoQm9vbCBiKSB7DQogIGlmIGIgdGhlbg0KICAgICRwcmludGYo InRydWVcbiIpOkludDsNCiAgZWxzZQ0KICAgICRwcmludGYoImZhbHNlXG4i KTpJbnQ7IA0KICBmaTsgfQ0KDQpmdW5jdGlvbiBtYWluKCk6SW50IHsNCiAg Qm9vbCBoYXBweTsNCiAgQm9vbCBzYWQ7DQogIGhhcHB5IDo9IHRydWU7DQog IHNhZCA6PSBmYWxzZTsNCiAgaXMoYW5kKGhhcHB5LCBzYWQpKTsNCiAgaXMo b3IoaGFwcHksc2FkKSk7DQogIGlzKG9yKHNhZCxzYWQpKTsNCiAgaXMoYW5k KGhhcHB5LCBoYXBweSkpOw0KICBNZXNoIG07DQogIG0gOj0gZmlsbE1lc2go bSwgMCwgMTAwLCAxMDAsMTAwKTsNCiAgSW50IGJpZ0F2ZXJhZ2U7DQogIGJp Z0F2ZXJhZ2UgOj0gYXZlcmFnZU1lc2gobSk7DQogICRwcmludGYoImJpZyBh dmVyYWdlOiAlZFxuIiwgYmlnQXZlcmFnZSk6SW50Ow0KICBtIDo9IGZpbGxN ZXNoKG0sIDAsIDUwLCA1MCw1MCk7DQogIEludCBzbWFsbEF2ZXJhZ2U7DQog IGJpZ0F2ZXJhZ2UgOj0gYXZlcmFnZU1lc2gobSk7DQogICRwcmludGYoInNt YWxsIGF2ZXJhZ2U6ICVkXG4iLCBiaWdBdmVyYWdlKTpJbnQ7DQogICRwcmlu dGYoIldpZXJkIHZhbHVlczogJWQgJWQgJWQgJWQgJWRcbiIsIHdpZXJkMSgx KSwgd2llcmQxKDEyKSwgd2llcmQxKDUwKSwgd2llcmQxKDEwMDAwMCksIHdp ZXJkMSgxMjAwKSk6SW50Ow0KICByZXR1cm4gMDsNCiB9DQogIA0KDQo= ---559023410-851401618-954275293=:21400-- From owner-g22_3130_001_sp00@cs.nyu.edu Wed Mar 29 01:13 EST 2000 MIME-Version: 1.0 X-Authentication-Warning: cs.nyu.edu: majordom set sender to owner-g22_3130_001_sp00@cs.nyu.edu using -f Date: Wed, 29 Mar 2000 01:13:18 -0500 (EST) From: Emily Chapman To: g22_3130_001_sp00@cs.nyu.edu Subject: new new improved test file :-) Sender: owner-g22_3130_001_sp00@cs.nyu.edu Precedence: bulk Content-Type: MULTIPART/MIXED; BOUNDARY="-559023410-851401618-954310398=:7502" Content-Length: 5904 Hi! This test file has actually been compiled by several people (Thank you!) and has test results I like ... -------------------- record Vector { Int length; Int [100] items; } function fillVector(Vector v, Int offset, Int length) : Vector { v.length := length; for i = 1 to length do v.items[i] := i+offset; return v; } record Mesh { Int length; Vector [100] vectors; } function fillMesh(Mesh m, Int offset, Int rowoffset, Int length, Int width) : Mesh { m.length := length; for i = 1 to 100 do if i < length + 1 then m.vectors[i].length := width; else m.vectors[i].length := 0; fi; for i = 1 to length do for j = 1 to width do m.vectors[i].items[j] := i+offset+i*rowoffset; return m; } function wierd1(Int x) : Int { if (x/12)*12 = x then return x; else_if x < 10 then return wierd1(x+100); else return wierd1(x/2); fi; return 0; } function averageVector(Vector v):Int { Int i; i := 1; Int sum; sum := 0; while(i < v.length + 1) do { sum := sum + v.items[i]; i := i + 1; } return sum / (i-1); } function averageMesh(Mesh m):Int { Int i; i := 1; Int sum; sum := 0; Int count; count := 0; while(i < m.length + 1) do { sum := sum + averageVector(m.vectors[i]); count := count + m.vectors[i].length; i := i + 1; } return sum / count; } function and(Bool a, Bool b) : Bool { if a then return b; fi; return false; } function or(Bool a, Bool b) : Bool { if a then return true; fi; return b; } function is(Bool b) { if b then $printf("true\n"):Int; else $printf("false\n"):Int; fi; } function main():Int { Bool happy; Bool sad; happy := true; sad := false; is(and(happy, sad)); is(or(happy,sad)); is(or(sad,sad)); is(and(happy, happy)); Mesh m; m := fillMesh(m, 0, 100, 100,100); Int bigAverage; bigAverage := averageMesh(m); $printf("big average: %d\n", bigAverage):Int; m := fillMesh(m, 0, 50, 50,50); Int smallAverage; bigAverage := averageMesh(m); $printf("small average: %d\n", bigAverage):Int; $printf("Wierd values: %d %d %d %d %d\n", wierd1(1), wierd1(12), wierd1(50), wierd1(100000), wierd1(1200)):Int; return 0; } record Vector { Int length; Int [100] items; } function fillVector(Vector v, Int offset, Int length) : Vector { v.length := length; for i = 1 to length do v.items[i] := i+offset; return v; } record Mesh { Int length; Vector [100] vectors; } function fillMesh(Mesh m, Int offset, Int rowoffset, Int length, Int width) : Mesh { m.length := length; for i = 1 to 100 do if i < length + 1 then m.vectors[i].length := width; else m.vectors[i].length := 0; fi; for i = 1 to length do for j = 1 to width do m.vectors[i].items[j] := i+offset+i*rowoffset; return m; } function wierd1(Int x) : Int { if (x/12)*12 = x then return x; else_if x < 10 then return wierd1(x+100); else return wierd1(x/2); fi; return 0; } function averageVector(Vector v):Int { Int i; i := 1; Int sum; sum := 0; while(i < v.length + 1) do { sum := sum + v.items[i]; i := i + 1; } return sum / (i-1); } function averageMesh(Mesh m):Int { Int i; i := 1; Int sum; sum := 0; Int count; count := 0; while(i < m.length + 1) do { sum := sum + averageVector(m.vectors[i]); count := count + m.vectors[i].length; i := i + 1; } return sum / count; } function and(Bool a, Bool b) : Bool { if a then return b; fi; return false; } function or(Bool a, Bool b) : Bool { if a then return true; fi; return b; } function is(Bool b) { if b then $printf("true\n"):Int; else $printf("false\n"):Int; fi; } function main():Int { Bool happy; Bool sad; happy := true; sad := false; is(and(happy, sad)); is(or(happy,sad)); is(or(sad,sad)); is(and(happy, happy)); Mesh m; m := fillMesh(m, 0, 100, 100,100); Int bigAverage; bigAverage := averageMesh(m); $printf("big average: %d\n", bigAverage):Int; m := fillMesh(m, 0, 50, 50,50); Int smallAverage; bigAverage := averageMesh(m); $printf("small average: %d\n", bigAverage):Int; $printf("Wierd values: %d %d %d %d %d\n", wierd1(1), wierd1(12), wierd1(50), wierd1(100000), wierd1(1200)):Int; return 0; }  -=- MIME -=-  This message is in MIME format. The first part should be readable text, while the remaining parts are likely unreadable without MIME-aware tools. Send mail to mime@docserver.cac.washington.edu for more info. ---559023410-851401618-954310398=:7502 Content-Type: TEXT/PLAIN; charset=US-ASCII Hi! This test file has actually been compiled by several people (Thank you!) and has test results I like ... -------------------- record Vector { Int length; Int [100] items; } function fillVector(Vector v, Int offset, Int length) : Vector { v.length := length; for i = 1 to length do v.items[i] := i+offset; return v; } record Mesh { Int length; Vector [100] vectors; } function fillMesh(Mesh m, Int offset, Int rowoffset, Int length, Int width) : Mesh { m.length := length; for i = 1 to 100 do if i < length + 1 then m.vectors[i].length := width; else m.vectors[i].length := 0; fi; for i = 1 to length do for j = 1 to width do m.vectors[i].items[j] := i+offset+i*rowoffset; return m; } function wierd1(Int x) : Int { if (x/12)*12 = x then return x; else_if x < 10 then return wierd1(x+100); else return wierd1(x/2); fi; return 0; } function averageVector(Vector v):Int { Int i; i := 1; Int sum; sum := 0; while(i < v.length + 1) do { sum := sum + v.items[i]; i := i + 1; } return sum / (i-1); } function averageMesh(Mesh m):Int { Int i; i := 1; Int sum; sum := 0; Int count; count := 0; while(i < m.length + 1) do { sum := sum + averageVector(m.vectors[i]); count := count + m.vectors[i].length; i := i + 1; } return sum / count; } function and(Bool a, Bool b) : Bool { if a then return b; fi; return false; } function or(Bool a, Bool b) : Bool { if a then return true; fi; return b; } function is(Bool b) { if b then $printf("true\n"):Int; else $printf("false\n"):Int; fi; } function main():Int { Bool happy; Bool sad; happy := true; sad := false; is(and(happy, sad)); is(or(happy,sad)); is(or(sad,sad)); is(and(happy, happy)); Mesh m; m := fillMesh(m, 0, 100, 100,100); Int bigAverage; bigAverage := averageMesh(m); $printf("big average: %d\n", bigAverage):Int; m := fillMesh(m, 0, 50, 50,50); Int smallAverage; bigAverage := averageMesh(m); $printf("small average: %d\n", bigAverage):Int; $printf("Wierd values: %d %d %d %d %d\n", wierd1(1), wierd1(12), wierd1(50), wierd1(100000), wierd1(1200)):Int; return 0; } ---559023410-851401618-954310398=:7502 Content-Type: TEXT/PLAIN; charset=US-ASCII; name="AssemblyTest2.ptls" Content-Transfer-Encoding: BASE64 Content-ID: Content-Description: Content-Disposition: attachment; filename="AssemblyTest2.ptls" cmVjb3JkIFZlY3RvciB7DQogIEludCBsZW5ndGg7DQogIEludCBbMTAwXSBp dGVtczsgfQ0KDQpmdW5jdGlvbiBmaWxsVmVjdG9yKFZlY3RvciB2LCBJbnQg b2Zmc2V0LCBJbnQgbGVuZ3RoKSA6IFZlY3RvciB7DQogIHYubGVuZ3RoIDo9 IGxlbmd0aDsNCiAgZm9yIGkgPSAxIHRvIGxlbmd0aCBkbw0KICAgIHYuaXRl bXNbaV0gOj0gaStvZmZzZXQ7IA0KICByZXR1cm4gdjsNCn0NCg0KcmVjb3Jk IE1lc2ggew0KICBJbnQgbGVuZ3RoOw0KICBWZWN0b3IgWzEwMF0gdmVjdG9y czsgfQ0KDQpmdW5jdGlvbiBmaWxsTWVzaChNZXNoIG0sIEludCBvZmZzZXQs IEludCByb3dvZmZzZXQsIEludCBsZW5ndGgsIEludCB3aWR0aCkgOiBNZXNo IHsNCiAgbS5sZW5ndGggOj0gbGVuZ3RoOw0KICBmb3IgaSA9IDEgdG8gMTAw IGRvDQogICAgaWYgaSA8IGxlbmd0aCArIDEgdGhlbg0KICAgICAgbS52ZWN0 b3JzW2ldLmxlbmd0aCA6PSB3aWR0aDsNCiAgICBlbHNlDQogICAgICBtLnZl Y3RvcnNbaV0ubGVuZ3RoIDo9IDA7DQogICAgZmk7DQogIGZvciBpID0gMSB0 byBsZW5ndGggZG8NCiAgICBmb3IgaiA9IDEgdG8gd2lkdGggZG8NCiAgICAg IG0udmVjdG9yc1tpXS5pdGVtc1tqXSA6PSBpK29mZnNldCtpKnJvd29mZnNl dDsgDQogIHJldHVybiBtOyB9DQoNCmZ1bmN0aW9uIHdpZXJkMShJbnQgeCkg OiBJbnQgew0KICBpZiAoeC8xMikqMTIgPSB4IHRoZW4NCiAgICByZXR1cm4g eDsNCiAgZWxzZV9pZiB4IDwgMTAgdGhlbg0KICAgIHJldHVybiB3aWVyZDEo eCsxMDApOw0KICBlbHNlDQogICAgcmV0dX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IpOkludDsgDQogIGZpOyB9DQoNCmZ1 bmN0aW9uIG1haW4oKTpJbnQgew0KICBCb29sIGhhcHB5Ow0KICBCb29sIHNh ZDsNCiAgaGFwcHkgOj0gdHJ1ZTsNCiAgc2FkIDo9IGZhbHNlOw0KICBpcyhh bmQoaGFwcHksIHNhZCkpOw0KICBpcyhvcihoYXBweSxzYWQpKTsNCiAgaXMo b3Ioc2FkLHNhZCkpOw0KICBpcyhhbmQoaGFwcHksIGhhcHB5KSk7DQogIE1l c2ggbTsNCiAgbSA6PSBmaWxsTWVzaChtLCAwLCAxMDAsIDEwMCwxMDApOw0K ICBJbnQgYmlnQXZlcmFnZTsNCiAgYmlnQXZlcmFnZSA6PSBhdmVyYWdlTWVz aChtKTsNCiAgJHByaW50ZigiYmlnIGF2ZXJhZ2U6ICVkXG4iLCBiaWdBdmVy YWdlKTpJbnQ7DQogIG0gOj0gZmlsbE1lc2gobSwgMCwgNTAsIDUwLDUwKTsN CiAgSW50IHNtYWxsQXZlcmFnZTsNCiAgYmlnQXZlcmFnZSA6PSBhdmVyYWdl TWVzaChtKTsNCiAgJHByaW50Zigic21hbGwgYXZlcmFnZTogJWRcbiIsIGJp Z0F2ZXJhZ2UpOkludDsNCiAgJHByaW50ZigiV2llcmQgdmFsdWVzOiAlZCAl ZCAlZCAlZCAlZFxuIiwgd2llcmQxKDEpLCB3aWVyZDEoMTIpLCB3aWVyZDEo NTApLCB3aWVyZDEoMTAwMDAwKSwgd2llcmQxKDEyMDApKTpJbnQ7DQogIHJl dHVybiAwOw0KIH0NCiAgDQoNCg== ---559023410-851401618-954310398=:7502-- From owner-g22_3130_001_sp00@cs.nyu.edu Wed Apr 5 00:24 EDT 2000 X-Authentication-Warning: cs.nyu.edu: majordom set sender to owner-g22_3130_001_sp00@cs.nyu.edu using -f Date: Wed, 5 Apr 2000 00:24:24 -0400 (EDT) From: Benjamin Goldberg To: g22_3130_001_sp00@cs.nyu.edu Subject: Assignments 6 and 7 Reply-to: goldberg@cs.nyu.edu Sender: owner-g22_3130_001_sp00@cs.nyu.edu Precedence: bulk Content-Type: text Content-Length: 310 Folks, The next (and last) two assignments are on the web page. Assignment 6 is global dataflow analysis and assignment 7 is optimization. You'll first need to chose what optimization to implement for assignment 7, since it will determine what dataflow analysis you implement for assignment 6. -Ben From owner-g22_3130_001_sp00@cs.nyu.edu Tue Apr 11 22:19 EDT 2000 X-Authentication-Warning: cs.nyu.edu: majordom set sender to owner-g22_3130_001_sp00@cs.nyu.edu using -f Date: Tue, 11 Apr 2000 22:19:29 -0400 (EDT) From: Benjamin Goldberg To: g22_3130_001_sp00@cs.nyu.edu Subject: CLASS CHANGE ON THURSDAY Reply-to: goldberg@cs.nyu.edu Sender: owner-g22_3130_001_sp00@cs.nyu.edu Precedence: bulk Content-Type: text Content-Length: 220 As I mentioned in class today, Thursday's class will be held at 11:30am in the usual classroom. This is due to my having to fly to the west coast that afternoon. Again, class will be at 11:30am on Thursday. -Ben From owner-g22_3130_001_sp00@cs.nyu.edu Tue Apr 18 16:32 EDT 2000 MIME-Version: 1.0 X-Authentication-Warning: cs.nyu.edu: majordom set sender to owner-g22_3130_001_sp00@cs.nyu.edu using -f Date: Tue, 18 Apr 2000 16:32:47 -0400 (EDT) From: Emily Chapman To: g22_3130_001_sp00@cs.nyu.edu Subject: dataflow test Sender: owner-g22_3130_001_sp00@cs.nyu.edu Precedence: bulk Content-Type: TEXT/PLAIN; charset=US-ASCII Content-Length: 3289 Dear class, Below is the promised Pointless program to test your data flow engines. At the beginning of your response, please tell me which analysis you did and make sure that you clearly label your data flow graph with which procedure it came from as they are hard enough to read even with that information! :-) Also, tell me what optimizations you are planning to do in a separate message. The more information you have the better as at the very least I can be a sanity checker! Good luck, Emily Pointless Program: ------------------------------------------------------------------ function live_paths(Int x) { Int a; Int b; Int c; Int d; Int e; Int f; Int g; a := 123; b := 123; c := a + b; if(x > 5) then { d := c + a; e := b + c; } else { d := c + b; e := b + c; } fi; f := g; } function live(){ Int a; Int b; Int c; Int d; Int e; Int f; a := 0; f := 7; while(a < 10) do { a := a + 3; b := b+1; if(c>5) then {d:= 10;} else {e:=3;} fi; }} function fib(Int x) :Int { if x < 3 then return 1; fi; return fib(x-2) + fib(x-1); } function hot() { Int cold; Int cool; Int warm; Int hot; for i = 1 to 100 do { cold := i+5; for j = 1 to 100 do { cool := i+j+5; for k = 1 to 100 do { warm := i+k+j+5; for l = 1 to 100 do hot := i+k+j+l+5; } } } } function dead(Int impingedByIf, Int a) { Int inOut; Int beginIf; Int coverIf; Int maybeBeginIf; Int endedByAllIfs; Int use; use := 0; inOut := 7; endedByAllIfs := 1001; use := use + inOut; use := use + coverIf; use := use + impingedByIf; use := use + endedByAllIfs; if (a > 5) then { use := use + inOut; use := use + beginIf; use := use + coverIf; use := use + maybeBeginIf; use := use + impingedByIf; use := use + endedByAllIfs; coverIf := 1; beginIf := 10; maybeBeginIf := 100; endedByAllIfs := 9; } else { coverIf := 2; beginIf := 10; impingedByIf := 100; use := use + inOut; use := use + beginIf; use := use + coverIf; use := use + maybeBeginIf; use := use + impingedByIf; use := use + endedByAllIfs; if (a > 10) then { use := use + inOut; use := use + beginIf; use := use + coverIf; use := use + maybeBeginIf; use := use + impingedByIf; use := use + endedByAllIfs; endedByAllIfs := 10; } else { use := use + inOut; use := use + beginIf; use := use + coverIf; use := use + maybeBeginIf; use := use + impingedByIf; use := use + endedByAllIfs; endedByAllIfs := 11; } fi; } fi; use := use + inOut; use := use + beginIf; use := use + coverIf; use := use + maybeBeginIf; use := use + impingedByIf; use := use + endedByAllIfs; } function main() { $printf("before hot\n"):Int; hot(); $printf("after hot\n"):Int; live(); $printf("after live\n"):Int; dead(12,13); $printf("after dead\n"):Int; live_paths(8); $printf("after live paths\n"):Int; for i = 1 to 100 do $printf("fib(%i)= %i\n", i, fib(i)):Int; } From owner-g22_3130_001_sp00@cs.nyu.edu Wed Apr 26 11:42 EDT 2000 X-Authentication-Warning: cs.nyu.edu: majordom set sender to owner-g22_3130_001_sp00@cs.nyu.edu using -f Date: Wed, 26 Apr 2000 11:42:24 -0400 (EDT) From: Benjamin Goldberg To: g22_3130_001_sp00@cs.nyu.edu Subject: Final Exam Reply-to: goldberg@cs.nyu.edu Sender: owner-g22_3130_001_sp00@cs.nyu.edu Precedence: bulk Content-Type: text Content-Length: 185 Folks, The one-week take-home final exam for the Honors Compilers course will be sent to you by email on Tuesday, May 2. You will have until Tuesday, May 9 to turn it in. -Ben From owner-g22_3130_001_sp00@cs.nyu.edu Tue May 2 11:24 EDT 2000 X-Authentication-Warning: cs.nyu.edu: majordom set sender to owner-g22_3130_001_sp00@cs.nyu.edu using -f Date: Tue, 2 May 2000 11:24:22 -0400 (EDT) From: Benjamin Goldberg To: g22_3130_001_sp00@cs.nyu.edu Subject: Take home exam Reply-to: goldberg@cs.nyu.edu Sender: owner-g22_3130_001_sp00@cs.nyu.edu Precedence: bulk Content-Type: text Content-Length: 5637 Folks, Here is the exam. It's due at 5pm next Tuesday. -Ben ------------------------------------------------------------------- Honors Compilers Spring 2000 Take-Home Final Exam Due Tuesday, May 9 at 5:00 p.m. You may submit this exam via email or by placing it in my 715 Broadway (7th floor) mailbox. Notice however, that several questions require illustrations, so email submissions should probably be in postscript. 1. Parsing & Automata There is a relationship between LR parsing and finite automata. a. Give an informal description of that relationship. In particular, what does an LR parse table represent in terms of finite automata. Be sure to mention both the states and the transitions of a parse table. b. Give a very simple CFG (that is not simply a regular expression), construct an SLR parse table for it, and draw the transition diagrams associated with it. c. What do the LR0 items used to construct an SLR parse table correspond to, with respect to the finite automata mentioned above? 2. Run-time Storage Representation Non-local variable references in a procedure can be found via an external array called a display. For most imperative languages, it is sufficient for each procedure defined at static nesting level i to, when called, save the i'th element of the display and update the i'th element to point to the procedure's activation record. Then, when the procedure returns, it restores the old i'th element of the display. a. Some languages have a feature that renders the display method above insufficient. What is that feature, and why? b. For a language for which this display method is sufficient, prove formally (hint: using induction) that this is so. c. Modify the simple display method given above to address the problem presented by a language exhibiting the feature mentioned in part a. 3. Intermediate code generation Write the code, either as a syntax-directed definition or as a hand-written definition (as in your compiler), for generating three-address intermediate code for a for-loop in C of the form for(e1; e2; e3) stmt Assume that the code for generating expressions and statements has already been written. 4. Register allocation a. Construct a register interference graph for the program shown in figure 9.13 on page 544 of the dragon book. b. What is the minimum number of physical registers needed in order to avoid spilling? c. Assuming you have exactly the number of physical registers that you specified in part b, show how register allocation by graph simplification proceeds on the graph in part a. 5. An expression e is said to be very busy at point p if, on all paths in the flow graph from p to the final node, e is evaluated before any of its operands are assigned to. a. Give a dataflow method (i.e. the dataflow equations and the iterative algorithm) for finding all very busy expressions. b. One reason for finding very busy expressions at point p is to hoist (i.e. move up in the code) them up to p. This will save space, although possibly not time. Explain. c. What is the disadvantage of, at point p, evaluating all expressions that are very busy at p? 6. Loop Optimization a. Can loop distribution be performed on the following loop? for i = 2 to 99 do a[i] = a[i-1] + 1 b[i] = a[i+1] - 1 end Justify your answer by showing each dependence along with the dependence vector (either a distance vector or a direction vector) for that dependence. b. Consider the following code exhibiting a loop carried dependence. for i = 1 to 100 do for j = 1 to 100 do for k = 1 to 100 do a[i,j,k] = a[i-1,j+1,k] end end end i. Show the dependence vector for the dependence. ii. What permutations of the loop nestings preserve the dependence? Why? 7. Instruction Scheduling a. Consider the following assembly code: Assuming that R2 := load (R1) ; load the contents of the address specified by R1 R2 := add R2,1 store (R1), R2 ; store R2 into the address specified by R1 R3 := load (R4) R3 := add R3,3 store (R4), R3 where it is known that R1 and R4 point to distinct locations. Assume all instructions have a latency of 0 (i.e. the result is available on the next cycle) except for the load, which has a latency of 4 (i.e. the result is available 5 cycles later). i. Draw the dependence graph (i.e. where the nodes are instructions and the edges are dependences labelled by latencies) for this code. ii. Reorder the instructions to produce the shortest instruction schedule (i.e. least execution time). b. Now assume, given the same code as in part a, that the compiler cannot determine that R1 and R4 point to distinct locations. i. Draw the dependence graph for the code. ii. Give the shortest instruction schedule. iii. The HPL/PD architecture (described in the Trimaran slides) has special instructions that will, in most situations, reduce the execution time of the code you gave in in the part b.ii. Re-write the code using these special instructions, and indicate what the execution time will be in each possible situation. From owner-g22_3130_001_sp00@cs.nyu.edu Tue May 2 17:25 EDT 2000 MIME-Version: 1.0 X-Authentication-Warning: cs.nyu.edu: majordom set sender to owner-g22_3130_001_sp00@cs.nyu.edu using -f Date: Tue, 2 May 2000 17:24:50 -0400 (EDT) From: Emily Chapman To: g22_3130_001_sp00@cs.nyu.edu Subject: Wierd procedure this time :-) Sender: owner-g22_3130_001_sp00@cs.nyu.edu Precedence: bulk Content-Type: TEXT/PLAIN; charset=US-ASCII Content-Length: 420 Hi! Since everyone is doing their own optimizations, the procedure has changed slightly: just come up with tests that change speed under your optimizations (hopefully to become faster...), and send them, along with their running times before and after optimization to me. As i realize finals are upon us, sending it within the next few days is fine. Oh yeah, include the compiler as well :-). Thanks, Emily