You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+53-3Lines changed: 53 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -127,14 +127,64 @@ If you are a team member of the project, please follow the [Working Standard](./
127
127
-[x] non-static Methods
128
128
---
129
129
130
-
### Second part: The typer and the execution support
130
+
### Second part: The Type-checking and the Execution
131
131
132
132
*Deadline 25/02/2018*
133
133
134
-
#### Type
134
+
#### Type-checking
135
135
136
-
-[] The construction of the class definition environment. This environment contains the type of methods for each class. This phase ignores the attributes (which are not visible outside the class) and the method bodies.
136
+
-[x] The construction of the class definition environment. This environment contains the type of methods for each class. This phase ignores the attributes (which are not visible outside the class) and the method bodies.
137
+
-[x] create a class definition environment type called `class_env`, it contains 4 fields as follows
138
+
- methods: a `Hashtbl` that maps from methode name to methode return type and argument type
139
+
- constructors: a `Hashtbl` that maps from constructor name to class reference type and argument type
140
+
- attributes: a `Hashtbl` that maps from attribute name to attribute type (declared type)
141
+
- parent: a class reference type that refers to its class
142
+
-[x] create a `Hashtbl` that maps from class
137
143
-[] The second phase is concerned with verifying that the inside of classes is correct (mainly the body of methods). She will also make sure of the correction of the higher level expression.
144
+
-[x] create 3 verification methode that verifies the following aspects of the program
145
+
- [x]`verify_methods` that checks the type of methods
146
+
- [x] create a local definition environment type called `current_env` it contains 3 fields as follows
147
+
- returntype: the declared return type of the methode
148
+
- variables: a `Hashtbl` that maps from local variable name to local variable declared type
149
+
- this_class: the id of the class
150
+
- env_type: a string that identifies the type of the local definition environment, it could be `constructor`, `methode` or `attribute`, in this case, the `env_type` is `methode`
151
+
- [x] write a verification methode (`verify_declared_args`) that checks the declared type of variables in the methode arguments
152
+
- [x] check if there exists Duplicate Local Variable
153
+
- [] write a verification methode (`verify_statement`) that checks the body of the methode
154
+
- [x] check declared variables
155
+
- [x] check block of statement
156
+
- [x] check expression
157
+
- [x] check return statement when it's none, ex: `return;`
158
+
- [] check return statement when it's not none, ex: `return x;`
159
+
- [] check throw statement
160
+
- [] check while statement
161
+
- [] check if statement when it doesn't have `else`
162
+
- [] check if statement when it has `else`
163
+
- [] check for statement
164
+
- [] check try statement
165
+
- [x]`verify_constructors` that checks the type of constructors
166
+
- [x]`verify_attributes` that checks the type of attributes
167
+
168
+
##### Errors that can be found during Type-checking
169
+
170
+
- ArgumentAlreadyExists
171
+
- AttributeAlreadyExists
172
+
- ClassAlreadyExists
173
+
- ConstructorAlreadyExists
174
+
- DuplicateLocalVariable
175
+
- IncompatibleTypes
176
+
- when constructor try to return a variable -> IncompatibleTypes("unexpected return value")
177
+
- when methode return does not contain variable -> IncompatibleTypes("missing return value")
178
+
- when methode return type does not corresponds with the declared one -> IncompatibleTypes("missing return value")
179
+
- MethodAlreadyExists
180
+
- UnknowVariable
181
+
- WrongTypesAssignOperation
182
+
- WrongTypesOperation
183
+
184
+
##### Errors that can not yet be found during Type-checking
0 commit comments