Debugging Phase I
Last week I merged UserFunctionalityScript, CompiledScript, and PrecompiledScript into a new class called ActionScript. This week I merged Role, CompiledRole, and PrecompiledRole into the Role class. I also wrote the ActionScriptFactory class which provides a static method to create an ActionScript. ActionScriptFactory performs the entire workflow from the old PrecompiledScript inputs into a script compatible with the old CompiledScript. The code now implements remixing without first writing the script to a file. I tried to make the process as easy to follow as possible and broke some of the old larger helper methods into multiple smaller helper methods. For more information on the changes, please read the code comments when I push the changes to the server. I have not yet modified the code that reads and writes scripts, so it is not currently possible to save the script to a file.
I tried running the new remix process but encountered an error. The proximate cause is that the map from AbstractField to AbstractField that is supposed to be used to replace the original fields in the remixed AST with their replacement fields has an empty entry set. That is occurring because the ActionScript's map of declaration hashcodes to the corresponding AbstractDeclaration has an empty entry set. I am not completely sure why the declaration hashcode to AbstractDeclaration map is empty but I have a theory. While refactoring the code to avoid the need to write to a file during remixing, I changed how that map is filled. Previously, it was filled by the Decoder class while it decoded the AST. Since the Decoder only works if the AST has already been written to XML, I had to find a different approach. The ASTToScriptCopier creates a map from AbstractMembers to AbstractDeclarations, so I assumed that if I iterate over this map, I could get all of the AbstractDeclarations I needed to create the other map. After more closely examining the ASTToScriptCopier, it appears that it only places user defined types in the member to declaration map. In constrast, I believe the hashcode to declaration map is supposed to include all AbstractDeclarations in the AST. I could be mistaken since I am not an expert on the AST. If my theory is correct, the solution is to fill the declaration map in either the ReferencesCrawler or ASTToScriptCopier where it could get every declaration in the AST instead of just user defined declarations.