Table Of Content
It turns outthat these concepts are quite interesting and provide a useful introductionto more sophisticated uses of functions, so we will discuss them here. This was completely sufficient infrastructure for implementing objectconstruction and field access. We left the (I claim trivial) additions offield update and initialization as exercises to the reader. Founded in 1930 and located in Pasadena, California, ArtCenter College of Design is a global leader in art and design education. With a current enrollment of approximately 2,423 students (57% female and 43% male, representing more than 50 countries), the College has a student/faculty ratio of 8 to 1. A key consequence of dynamic dispatch is that object values must containinformation about their class, because the class of an object cannot bedetermined statically.
PROJECTS
Our rescue cat, Snoop, brings just the right level of mayhem to our lives. ArtCenter is a private nonprofit fully accredited by the WASC Senior College and University Commission (WSCUC). Renowned for both its ties to industry and social impact initiatives, the College is the first design school to receive the United Nations’ Non-Governmental Organization (NGO) status. Ability to implement a lexer without using Flex or any other lexer generation tools.
UCSD CSE231 S22
Ability to implement semantic rules into a parser that performs attribution while parsing. Ability to implement a parser such as a bottom-up SLR parser without using Yacc/Bison or any other compiler-generation tools. In the case of no inheritance, where we have our decorated AST, let’sconsider the c.inc() expressions in this program.
Functions as Values (in WASM, Function References and Tables)
Here we have a classic case in compiler design – for different kinds ofcomplexity in a program, we can use different compilation techniques tocompile the “same” programming language feature (in this case nestedfunctions). Another view is that adding references around variables alwaysworks as a fully general solution, but if the variable is never updated it’ssafe to remove the references as an optimization, and if the function issufficiently small, we could inline instead. All three of these strategies—inlining, adding extra arguments, and creatingreferences for variables variables—are useful. Inlining can actually reducethe number of instructions run by a program. Adding extra arguments causesmore work (extra pushing of arguments) in exchange for working on recursivefunctions and functions that might be too costly to inline.
This gives us some constraints that allow usmore freedom with compilation than we have with other functions. Inparticular, we know g cannot be exported and called from another REPLentry, so if we wanted to, say, change its signature to add or removearguments, we could also find all of the places that call g and update themappropriately. And in fact, Python with nonlocal declarations is closer to theinteresting-case behavior of most programming languages – multiple functionscan perform updates on, and see the value of, a shared variable. Advanced material in programming languages and translator systems. Adding inheritance now means that we need to track the table layout of theclass environment across REPL entries as well, and each new REPL module needsaccess to a running table of function references.
Computer Science *: Programming
We will also assign weekly readings from around the Web highlighting toolsand techniques we need, and research papers that explore the space ofcompiler design. This project will allow us to explore a number of interesting features ofcompilation and build deployable, user-facing programming environments. The main course project is building an in-browser, interactive compiler from(typed) Python programs to WebAssembly.
Then, you will have significant choice inthe project you decide to work on, though generally we expect that projectswill be extensions of the running compiler we develop in the first part ofthe course. Group work will be allowed (optionally) on the projects, withdetails to come. Alfred Barcarse brings over 40 years of graphic design experience to AS Design. Starting in publication & advertising design in the ‘80s, he spent over 20 years specializing in movie advertising design and prepress, working on projects for Disney International, New Line Cinema, Fine Line Features, IMAX, Showtime Video, and many others. And, if you love wine, Fred often shares his wine discoveries on Delectable.
Since WASM doesn’t permit access to the stackoutside of the current function, such a cross-call variable reference isprohibited. We need another strategy to implement nested functions atop WASM.Our approach to this could be multi-faceted, depending on the particularconstraints of g and f. These techniques may come in handy, no matter what field of CS you end up working in. For nested functions with ChocoPy’s restrictions (we’ll revisit thisrestriction later), we know that all calls to g must occur within the bodyof f. Generally, all calls to a nested function appear within the body ofthe function it is declared in.
Aside from modifying theREPL/runner to consume and produce this new information there’s no newinfrastructure required. The WASM tool is tables and the call_indirectinstruction,which allow us to refer to a function by a numeric (i32) index into a tablerather than by a name that needs to be known at compile-time. WASM currentlysupports a single table per module, so we will need to organize all methodreferences within the same module-level table.
Fluency in describing the theory and practice of compilation, in particular, the lexical analysis, syntax, and semantic analysis, code generation and optimization phases of compilation. So adding an extra parameter works, but not if we want to support use casesthat share updateable variables between functions. That is, the classes appear in order as they are declared in the file.
Another attempt could be to store, update, and access shared variables on theheap (in WASM, the linear memory). This is promising, because the memorypersists across all function calls, and indeed, in our setup, across otherboundaries like modules. Our approach will be to give special treatment andattention to variables that both updated at some point, and used withina nested function, like x in our f-g-h example above. One straightforward option, if g is not recursive, and not too large, andnot used too many times, is inlining. In many programs, nested functions aresmall helpers, and their code can be easily copied to the point where theyare called. In this case, that would mean replacing the expressions g(10)with x + 10, and g(7) with x + 7.
However, due to recursion, it is not ageneral solution, and due to code size concerns, it is not a pragmaticsolution for all cases. If we were compiling to traditional assembly, we could have the stack framefor g refer to the stack frame for f, since all stack memory in atraditional process is part of the same address space. We could compile gto do a specific memory-offset lookup for x in order to find it in itscaller’s frame, which is reminiscent the infrastructure for getting theaddress of variables in C/C++ (the & operator). These use cases help us understand some of the necessary information we needto track across REPL entries, and for separate compilation of programs thatuse classes in general. It is now our task to figure outhow to represent this in our compiler and at runtime. A single call expression in the source program may select from one ofseveral method definitions at runtime.
Acritical decision we had to make for Link is making sure that sum camebefore new, because any List-typed object that is used to call sumneeds to use the same index for that method. Running the type-checker would leave us with an expression decorated with thereturn type (in this case ), and with the obj field decorated withthe object’s class type. These first three assignments are designed to get us all to a basic level offunctionality and understanding.
Creatingreferences for variables makes yet more work at runtime, in the form ofallocations and memory access, which is less efficient than stack accessalone. An optimizing compiler for Python ought to do the analysis described above,and choose which one of the compilation strategies to use based on thecomplexity of the nested functions. The questions of when to inline, and inhow many cases we can avoid wrapping variables in references, become new,fruitful areas of measurement and exploration for the compiler author.
Students are required to extend a context-free language and design and implement a lexer and bottom-up (SLR) parser for the language in the first programming project. In the second project, students are required to extend a context-free language and design and implement a compiler using compiler construction tools such as Bison and Yacc. Midterm test has five questions, and the final examination has nine questions. I track the performance of the students on each homework assignment, each programming project assignment, and each question on the midterm and final examination.
No comments:
Post a Comment