| 100 | | LibraryIF should have methods getConstants() and getFunctions() that return the constants and (regular, not system-level) functions associated with those libraries. ModelIF should contain a method addLibrary(String name) that calls loadLibrary(), then uses getConstants() and getFunctions() to add the library's constants and functions to the model. |
| | 100 | public class LibraryLoader { |
| | 101 | LibraryIF loadLibrary(String name); |
| | 102 | } |
| | 103 | |
| | 104 | public interface LibraryIF { |
| | 105 | String name(); |
| | 106 | |
| | 107 | Map<String, SharedVariableIF> getConstants(); |
| | 108 | |
| | 109 | /* Returns the regular (non-system) functions */[[BR]] |
| | 110 | List<FunctionDeclaration> getFunctions(); |
| | 111 | |
| | 112 | /* Gives the syntax for system functions */[[BR]] |
| | 113 | Map<String, FunctionDeclaration> getSystemFunctions(); |
| | 114 | } |
| | 115 | |
| | 116 | A Program should have information on its included libraries, and have a method to get that information. |
| | 117 | |
| | 118 | List<String> libraries(); |
| | 119 | |
| | 120 | ModelBuilder will need to process libraries by loading each and adding the appropriate components to the model. |
| | 121 | |
| | 122 | void processLibraries(ModelIF model, List<String> libraries); |
| | 123 | |
| | 124 | We also need to keep track of system functions vs regular functions, and which libraries the system functions come from. |
| | 125 | |
| | 126 | public interface SystemFunctionIF extends FunctionIF { |
| | 127 | String libraryName(); |
| | 128 | |
| | 129 | } |
| 104 | | LibraryIF should also have a method getSystemFunctions() that returns the IDs of system-level functions in the library. These IDs would then be used by the executor to execute the system-level function. Maybe have a lib folder in the semantics package as well, with a library semantic interface for the executor to pass an environment and function ID to the appropriate library? This would be like having an executor for each library that contains system-level functions, and the current executor would call the appropriate library executor. |
| | 133 | If all system functions are part of a library, the execute() method in the executor should be: |
| | 134 | |
| | 135 | void execute(EnvironmentIF environment, InvocationStatementIF statement); |
| | 136 | |
| | 137 | This method will instantiate the appropriate LibraryExecutor for the SystemFunctionIF, then call a method in that library executor to execute the appropriate function. |
| | 138 | |
| | 139 | public interface LibraryExecutorIF { |
| | 140 | void execute(EnvironmentIF environment, InvocationStatementIF invocation); |
| | 141 | |
| | 142 | boolean containsFunction(String name); |
| | 143 | } |