Closed Tkrauss closed 11 years ago
There are two different use cases in the AST.
I will use the example struct Point { x: Double, y: Double}
Type point = new StructType("Point", new MemberType("x", new DoubleType()), new MemberType("y", new DoubleType());
print somepoint.x
This would become the following tree in the AST
PrintStatementNode
|
| rightValue
|
StructIdentifierNode
| |
| fieldName |
| | IdentifierNode
"x" |
|
BasicIdentifier
| identifier = "somepoint"
I hope that answers your question / clarifies the problem
Thanks, it's clarified:). The constructor was the answer. Anyway, that's not the matter of the interface. From my point of view, the current design achieve our requirements.
No problem.
Type is already implemented and not just an interface. This was part of the SymbolTable definition. You can check it out over here: https://github.com/swp-uebersetzerbau-ss13/common/tree/master/interfaces/src/swp_compiler_ss13/common/types
Since a struct consists of n fields, one must be able to identify the m-th field with a class ( extending Identifiernode). I think the following methods will be appropriate ( this can be easily implemented by delegating a Map): void AddField (String identifier, IdentifierNode node) IdentifierNode getFieldForIdentifier( String identifier ) ( for debugging purpose ) Set getAllIdentifiers()
correct me if i get the design wrong... rgds