Changes between Version 33 and Version 34 of Things To Do


Ignore:
Timestamp:
06/04/10 12:39:18 (16 years ago)
Author:
Stephen Siegel
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • Things To Do

    v33 v34  
    6666New library wiki page: [wiki:Libraries Libraries]
    6767
    68 A reference to standard library files is here: http://www.utas.edu.au/infosys/info/documentation/C/CStdLib.html
    69 
    70 Special functions that are currently included in the grammar can instead be treated just like any other function and "linked in" at a later stage.   This will simplify the grammar and front-end. Functions that can be removed include {{{send}}}, {{{recv}}}, {{{allocate}}}, {{{deallocate}}}.
    71 
    72 When {{{ModelIF.complete}}} is invoked, it will look for functions which are called but not defined.   It will then look through a standard library for a function of the correct name, and add that function to the process containing the call.
    73 
    74 Note:  {{{allocate}}} takes a type argument, so we should also add to the grammar a new expression {{{sizeof(type)}}}.   The semantics module will associate a special symbolic constant to this expression, corresponding to the type (e.g., {{{SIZEOF_INT}}}).   We can then replace our {{{allocate}}} and {{{deallocate}}} with the standard C functions {{{malloc}}} and {{{free}}}
    75 
    76 
    77 Some libraries add state: shared state and process global state.  How do manage this?
    78 
    79 When a library is included into a model, it may add shared variables to the model.  When it is attached to a process it may add process-global variables.
    80 
    81 Define class Library, LibraryFunction.
    82 
    83 attachToModel(ModelIF);
    84 attachToProcess(ProcessIF);
    85 
    86 in ModelIF, ProcessIF, etc.: getFunctionWithName("fprintf") will return the function if it has been added.
    87 
    88 FunctionIF: boolean field: isSystemFunction.   If true, function does not have body (locations).  Instead, a special class will be loaded to execute this function's transformation of the state when it is invoked.
    89 
    90 add module library, submodule of model.
    91 
    92   In the library module, there should be a LibraryLoader class and a LibraryIF.  The LibraryLoader will have a method loadLibrary(String name) that returns a LibraryIF.  The loader should contain information about each of the implemented libraries.  The loadLibrary() method will check for a library with the matching name, return it if available, or throw an exception.
    93 
    94 {{{
    95    public class LibraryLoader {
    96     LibraryIF loadLibrary(String name);
    97    }
    98 
    99    public interface LibraryIF {
    100     String name();
    101 
    102     Map<String, SharedVariableIF> getConstants();
    103    
    104     /* Returns the regular (non-system) functions */[[BR]]
    105     List<FunctionDeclaration> getFunctions();
    106 
    107     /* Gives the syntax for system functions */[[BR]]
    108     Map<String, FunctionDeclaration> getSystemFunctions();
    109    }
    110 }}}
    111 
    112 A Program should have information on its included libraries, and have a method to get that information.
    113 
    114 {{{
    115     List<String> libraries();
    116 
    117    ModelBuilder will need to process libraries by loading each and adding the appropriate components to the model.
    118 
    119      void processLibraries(ModelIF model, List<String> libraries);
    120 
    121    We also need to keep track of system functions vs regular functions, and which libraries the system functions come from.
    122 
    123      public interface SystemFunctionIF extends FunctionIF {
    124       String libraryName();
    125 
    126      }
    127 }}}
    128 
    129 also add system level function definition in semantics, next to !Executor.
    130  
    131 If all system functions are part of a library, the `execute()` method in the executor should be:
    132 
    133 {{{
    134    void execute(EnvironmentIF environment, InvocationStatementIF statement);
    135 }}}
    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 {{{
    140    public interface LibraryExecutorIF {
    141     void execute(EnvironmentIF environment, InvocationStatementIF invocation);
    142 
    143     boolean containsFunction(String name);
    144    }
    145 }}}