theodore-norvell / PLAAY

Senior Design Project PLAAY (Programming Language for Adults And Youth)
2 stars 0 forks source link

Object and select nodes. #103

Open theodore-norvell opened 6 years ago

theodore-norvell commented 6 years ago

Object nodes are a lot like ExpSeq nodes in that they contain a mixture of sequence of expressions and variable declarations. Unlike ExpSeq nodes, Object nodes are expressions nodes. The evaluation of a Object node is mostly the same as the evaluation of ExpSeq nodes except that the value of an ExpSeq node is the value of the last expression evaluated, whereas the value of an Object node is the the object value on the top var stack. Thus a class can be represented by a function that returns an object. Private fields of the object are the variables of the function.

(Note it is not clear how one would do inheritance with this approach to objects and classes.)

We also need a Select node. A Select node has one child and a string value in its label. The child should evaluate to an object. The string value of the label is then used to look up a field of the object.

theodore-norvell commented 6 years ago

Dot operator is yet to be done.