Skip to content
Snippets Groups Projects
Commit 91b54556 authored by Rodrigo Raya's avatar Rodrigo Raya
Browse files

Update labs_01.md

parent 4e9751eb
No related branches found
No related tags found
No related merge requests found
......@@ -65,7 +65,7 @@ A few final notes:
* To find constructors and functions in the program, you have to search in the ''SymbolTable'' passed along with the program. To do this, use the three helper methods provided in the interpreter:
* ''isConstrutor'' will return whether the ''Identifier'' argument is a type constructor in the program
* ''findFunctionOwner'' will return the module which contains the given ''Identifier'', which has to be a function in the program. E.g. if you give it the ''printInt'' function of the ''Std'' module, you will get the string ''"Std"''.
* ''findFunction'' will return the function definition given a pair of Strings representing the module containing the function, and the function name. The return value is of type ''FunDef'' (see [the AST definitions](https://gitlab.epfl.ch/lara/cs320/-/blob/main/labs/labs01_material/SymbolicTreeModule.scala).
* ''findFunction'' will return the function definition given a pair of Strings representing the module containing the function, and the function name. The return value is of type ''FunDef'' (see [the AST definitions](https://gitlab.epfl.ch/lara/cs320/-/blob/main/labs/labs01_material/SymbolicTreeModule.scala)).
* When comparing Strings by reference, compare the two ''StringValue''s directly and not the underlying Strings. The reason is that the JVM may return true when comparing Strings by equality when it is not expected (it has to do with JVM constant pools).
* Some functions contained in the ''Std'' module are built-in in the language, i.e. they are hard-coded in the interpreter because they cannot be implemented in Amy otherwise. An example of a built-in function is ''printString''. When you implement the interpreter for function calls, you should first check if the function is built-in, and if so, use the implementation provided in the ''builtIns'' map in the interpreter.
* When a program fails (e.g. due to a call to ''error'' or a match fail), you should call the dedicated method in the Context: ''ctx.reporter.fatal''.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment