On Fri, Sep 3, 2010 at 12:33 PM, David Matthews <david.matth...@prolingua.co.uk> wrote: > Yue Li wrote: >> >> Are signatures preserved only until type checking phase before the >> code generation phase? > > Any declaration will involve a name, a description of some sort and some > code. The description might be the type of a value or in the case of a > structure or signature a data-structure representing the signature. The > code may involve evaluating some expression or, in the case of signature, > infix and simple type bindings it may be zero. The resulting of compiling > anything is a unit->unit function which when called executes the code and > also side-effects the name-space to put the declared value into the > name-space. >
I see, I think now I fully understand that the generated IR of a signature contains only zero because of no evaluation. >> Could you introduce a little bit on how CR CL and LOCALS are >> determined in the later phase of code generation? Thanks again! > > LOCALS is used as a high-water mark to indicate the maximum number of local > bindings in the function. Not all the bindings may be present because often > they are created as part of the inline function expansion process and then > removed if they are not actually referenced. > Ok. No wonder for some function definition whose body involves constant expressions, the value of LOCALS is not what I expect due to this kind of optimization, which removes local references. > CL is false if the function has non-local references but does not require a > closure. This may happen if it is declared as local to another function but > is only ever called and not, for example, returned as a result. Creating a > closure requires heap allocation so it's better if it can be avoided. > > CR has to do with when the register that contains the address of the closure > is no longer required and can be reused. > > All these are computed within later phases of the code-generator. > I'm much clearer now, many thanks!! Best, Yue _______________________________________________ polyml mailing list polyml@inf.ed.ac.uk http://lists.inf.ed.ac.uk/mailman/listinfo/polyml