Structures and DotOperations

I have a struct-like construct in my concepts. I want to be able to make references to user-specified fields in the static struct. I am aware of the DotExpressions and IOperations tutorial, but those create pre-specified constraints, and I want them to be dynamic. It must be possible, since it's done in BaseLanguage, but I just don't know what the right combination of Constraints or Type rules are to get the effect I want - which is, to be clear, putting a dot at the end of a variable or field reference, and providing autocomplete with a finite list of fields which depends on the type.

1 comment
Comment actions Permalink

You need a smart reference concept to refer to a field. The concept should extend IOperation. In the constraints aspect you compute the scope for the contained reference: use the type of the DotExpression's operand to find that type's members and build the scope out of them.

For example, check out FieldReferenceOperation_Constraints (the code may look a bit complicated but that's basically what it does).

0

Please sign in to leave a comment.