Local Variables Working: Onward to AST Listeners
This week I added an "available methods" section to custom array creation. It now lists the custom user methods that all of the members of the array have in common. The type section is also now being updated to contain the lowest common ancestor type of the array. (Biped for alien and Yeti, or Flyer for falcon and bluebird e.g.)
This should help the user know ahead of time what methods they'll be able to use on the array variable. I also changed the name of my custom variable to "InferredType" instead of "ArrayVar".
I also began work on storing local variables. Now local variables are also considered InferredTypes. I also implemented a more robust "isCompatibleWith" method for inferred types which determines if an object could be assigned to a variable of this type. Part of getting this to work was giving an InferredType the knowledge of what methods have been called on it. As soon as you call a method on an InferredType, any value you assign to the variable in the future must also have that method. Similarly, if you delete all the calls to the method, this requirement is dropped. Currently, it only checks UserMethods, and I will need to extend this to handle things like getting wings and things like that. I also need to make some kind of affordance to indicate why certain models can be assigned and others cannot.
For next steps, I need the inferred type to be notified when the methods available to its members changes. This is going to most likely involve some listeners on the AST to update what's available to the method. This will also require an error dialog for trying to delete a method off a member when it's being invoked elsewhere.