{ History ------- 12/09/85 - include file eput.pf, simplify procedure Assign. 07/10/85 - simplify procedure Assign. 18/10/85 - tidy history. (agh) 18/10/85 - AssignTag simplified. (agh) 25/10/85 - Ensure empty-set constants are expanded to the correct word-size. Delet outdated documentation. (agh) 07/11/85 - Refine above modification using AdjustSet. Adjust expression size if LHS is packed. (agh) 03/12/85 - Further modifications to Assign to handle bit packing. (agh) 04/12/85 - Further modifications to Assign to improve CAP assignment. (agh) ------------------------------------------------------------------- 04/02/86 - Call ConvertInteger if LHS size <> RHS size for scalars. This covers cases such as pf := i (compression), and i :+ pf (expansion) when pf is packed and i is unpacked. } { MODULE 20 Assignment Code Generation } program AssignmentCode; #include "globals.x" #include "datareps.pf" #include "varref.pf" #include "expeval.pf" #include "codeutils.pf" #include "pfcalls.pf" #include "eput.pf" procedure Assign(VarRep: TypeRepresentation); visible; var Expression, Variable: StackEntry; ExpnSize, VarSize: ByteRange; begin if CodeIsToBeGenerated then begin Pop(Expression); Pop(Variable); if VarRep.Kind <= ForSet then case VarRep.Kind of ForScalar, ForChar, ForWord : begin with Variable^ do case AccessKind of Bits : VarSize := MCBytesPerWord; Bytes : VarSize := ByteSize; Words : VarSize := DataSize(VarRep) end; with Expression^ do if Kind = Reference then case AccessKind of Bits : ExpnSize := MCBytesPerWord; Bytes : ExpnSize := ByteSize; Words : ExpnSize := DataSize(DataRep) end else ExpnSize := MCBytesPerWord; if VarSize <> ExpnSize then ConvertInteger(VarSize, Expression) end; ForSet : if Expression^.Kind = AConstant then AdjustSet(VarRep.WordSize, Expression) end; Load(Expression); LoadAddress(Variable); if VarRep.Kind = ForCAP then Epasop(CAPMOVE) else Eop(ESTORE); FreeEntry(Expression); FreeEntry(Variable) end end { assign }; procedure AssignTag(SelectorRep: TypeRepresentation); visible; begin if CodeIsToBeGenerated then Assign(SelectorRep) end { assigntag }; begin { end of module } end.