Changeset 16412
- Timestamp:
- 05/18/07 00:13:01 (18 months ago)
- Files:
-
- 1 modified
-
src/Pugs/AST/Internals.hs (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Pugs/AST/Internals.hs
r16391 r16412 11 11 SubAssoc(..), TraitBlocks(..), emptyTraitBlocks, 12 12 13 MPad , Pad(..), PadEntry(..), EntryFlags(..), PadMutator, -- uses Var, TVar, VRef13 MPad(..), LexPad(..), LexPads, Pad(..), PadEntry(..), EntryFlags(..), PadMutator, -- uses Var, TVar, VRef 14 14 Param(..), -- uses Cxt, Exp 15 15 Params, -- uses Param … … 1036 1036 -- | Represents a sub, method, closure etc. -- basically anything callable. 1037 1037 data VCode = MkCode 1038 { isMulti :: !Bool -- ^ Is this a multi sub\/method?1039 , subName :: !ByteString -- ^ Name of the closure1040 , subType :: !SubType -- ^ Type of the closure1041 , sub LexPads :: !LexPads -- ^ Lexical pads for thiescope1042 , sub Lexical :: !Pad -- ^ Cached merged pads1043 , subEntered :: !(TVar Bool) -- ^ Whether this pad has been entered before (for runtime) 1044 , subPackage :: !Pkg -- ^ Package of the subroutine1045 , subAssoc :: !SubAssoc -- ^ Associativity1046 , subParams :: !Params -- ^ Parameters list1047 , subBindings :: !Bindings -- ^ Currently assumed bindings1048 , subSlurpLimit :: !SlurpLimit -- ^ Max. number of slurpy arguments1049 , subReturns :: !Type -- ^ Return type1050 , subLValue :: !Bool -- ^ Is this a lvalue sub?1051 , subBody :: !Exp -- ^ Body of the closure1038 { isMulti :: !Bool -- ^ Is this a multi sub\/method? 1039 , subName :: !ByteString -- ^ Name of the closure 1040 , subType :: !SubType -- ^ Type of the closure 1041 , subOuterPads :: !LexPads -- ^ Lexical pads for this scope 1042 , subInnerPad :: !Pad -- ^ Inner lexical pad (immutable) 1043 -- , subLexical :: !Pad -- ^ Cached merged pads 1044 , subPackage :: !Pkg -- ^ Package of the subroutine 1045 , subAssoc :: !SubAssoc -- ^ Associativity 1046 , subParams :: !Params -- ^ Parameters list 1047 , subBindings :: !Bindings -- ^ Currently assumed bindings 1048 , subSlurpLimit :: !SlurpLimit -- ^ Max. number of slurpy arguments 1049 , subReturns :: !Type -- ^ Return type 1050 , subLValue :: !Bool -- ^ Is this a lvalue sub? 1051 , subBody :: !Exp -- ^ Body of the closure 1052 1052 , subCont :: !(Maybe (TVar VThunk)) -- ^ Coroutine re-entry point 1053 1053 , subStarted :: !(Maybe (TVar Bool)) -- ^ Whether START was run … … 1081 1081 mkPrim :: VCode 1082 1082 mkPrim = MkCode 1083 { isMulti = True 1084 , subName = cast "&" 1085 , subType = SubPrim 1086 , subLexPads = [] 1087 , subPackage = emptyPkg 1088 , subAssoc = ANil 1089 , subParams = [] 1090 , subBindings = [] 1091 , subSlurpLimit = [] 1092 , subReturns = anyType 1093 , subBody = emptyExp 1094 , subLValue = False 1095 , subCont = Nothing 1083 { isMulti = True 1084 , subName = cast "&" 1085 , subType = SubPrim 1086 , subOuterPads = [] 1087 , subInnerPad = emptyPad 1088 -- , subLexical = emptyPad 1089 , subPackage = emptyPkg 1090 , subAssoc = ANil 1091 , subParams = [] 1092 , subBindings = [] 1093 , subSlurpLimit = [] 1094 , subReturns = anyType 1095 , subBody = emptyExp 1096 , subLValue = False 1097 , subCont = Nothing 1098 , subStarted = Nothing 1096 1099 , subTraitBlocks = emptyTraitBlocks 1097 1100 } … … 1099 1102 mkSub :: VCode 1100 1103 mkSub = MkCode 1101 { isMulti = False 1102 , subName = cast "&" 1103 , subType = SubBlock 1104 , subLexPads = [] 1105 , subPackage = emptyPkg 1106 , subAssoc = ANil 1107 , subParams = [] 1108 , subBindings = [] 1109 , subSlurpLimit = [] 1110 , subReturns = anyType 1111 , subBody = emptyExp 1112 , subLValue = False 1113 , subCont = Nothing 1104 { isMulti = False 1105 , subName = cast "&" 1106 , subType = SubBlock 1107 , subOuterPads = [] 1108 , subInnerPad = emptyPad 1109 -- , subLexical = emptyPad 1110 , subPackage = emptyPkg 1111 , subAssoc = ANil 1112 , subParams = [] 1113 , subBindings = [] 1114 , subSlurpLimit = [] 1115 , subReturns = anyType 1116 , subBody = emptyExp 1117 , subLValue = False 1118 , subCont = Nothing 1119 , subStarted = Nothing 1114 1120 , subTraitBlocks = emptyTraitBlocks 1115 1121 } … … 1117 1123 mkCode :: VCode 1118 1124 mkCode = MkCode 1119 { isMulti = False 1120 , subName = cast "&" 1121 , subType = SubBlock 1122 , subLexPads = [] 1123 , subPackage = emptyPkg 1124 , subAssoc = ANil 1125 , subParams = [] 1126 , subBindings = [] 1127 , subSlurpLimit = [] 1128 , subReturns = anyType 1129 , subBody = emptyExp 1130 , subLValue = False 1131 , subCont = Nothing 1125 { isMulti = False 1126 , subName = cast "&" 1127 , subType = SubBlock 1128 , subOuterPads = [] 1129 , subInnerPad = emptyPad 1130 -- , subLexical = emptyPad 1131 , subPackage = emptyPkg 1132 , subAssoc = ANil 1133 , subParams = [] 1134 , subBindings = [] 1135 , subSlurpLimit = [] 1136 , subReturns = anyType 1137 , subBody = emptyExp 1138 , subLValue = False 1139 , subCont = Nothing 1140 , subStarted = Nothing 1132 1141 , subTraitBlocks = emptyTraitBlocks 1133 1142 } … … 1326 1335 type DebugInfo = Maybe (TVar (Map ID String)) 1327 1336 1328 data LexPads 1329 = PCompiling { pc_pads :: !([MPad]) } 1330 | PRuntime 1331 { pr_pads :: !([Pad]) 1332 , pr_merged :: !Pad 1333 -- , pr_fresh :: !(TVar Bool) 1334 } 1335 1336 1337 data LexPads 1338 = PRuntime ![Pad] 1339 | PCompiling ![MPad] 1337 type LexPads = [LexPad] 1338 data LexPad 1339 = PRuntime { pr_pad :: !Pad } 1340 | PCompiling { pc_pad :: !MPad } 1340 1341 deriving (Show, Eq, Ord, Typeable) 1341 1342 … … 1348 1349 -} 1349 1350 data Env = MkEnv 1350 { envContext :: !Cxt -- ^ Current context1351 -- ('CxtVoid', 'CxtItem' or 'CxtSlurpy')1352 , envLValue :: !Bool -- ^ Are we in an LValue context?1353 , envLexical :: !Pad -- ^ Cached lexical pad for variable lookup1354 , envLexPads :: ! [TVar Pad]-- ^ Current lexical pads; MY is leftmost, OUTER is next, etc1355 , env DynPads :: ![Pad] -- ^ CONTEXT pads; CALLER is leftmost (CALLER::OUTER is not there)1356 , envCompPad :: !(Maybe (TVar Pad))-- ^ Current COMPILING pad1357 , envGlobal :: ! (TVar Pad)-- ^ Global pad for variable lookup1358 , envPackage :: !Pkg -- ^ Current package1359 , envEval :: !(Exp -> Eval Val) -- ^ Active evaluator1360 , envBody :: !Exp -- ^ Current AST expression1361 , envFrames :: !(Set Frame) -- ^ Special-markers in the dynamic path1362 , envDebug :: !DebugInfo -- ^ Debug info map1363 , envPos :: !Pos -- ^ Source position range1364 , envPragmas :: ![Pragma] -- ^ List of pragmas in effect1365 , envInitDat :: !(TVar InitDat) -- ^ BEGIN result information1366 , envMaxId :: !(TVar ObjectId) -- ^ Current max object id1367 , envAtomic :: !Bool -- ^ Are we in an atomic transaction?1351 { envContext :: !Cxt -- ^ Current context 1352 -- ('CxtVoid', 'CxtItem' or 'CxtSlurpy') 1353 , envLValue :: !Bool -- ^ Are we in an LValue context? 1354 , envLexical :: !Pad -- ^ Cached lexical pad for variable lookup 1355 , envLexPads :: !LexPads -- ^ Current lexical pads; MY is leftmost, OUTER is next, etc 1356 , envCaller :: !(Maybe Env) -- ^ CALLER pads 1357 , envCompPad :: !(Maybe MPad) -- ^ Current COMPILING pad 1358 , envGlobal :: !MPad -- ^ Global pad for variable lookup 1359 , envPackage :: !Pkg -- ^ Current package 1360 , envEval :: !(Exp -> Eval Val) -- ^ Active evaluator 1361 , envBody :: !Exp -- ^ Current AST expression 1362 , envFrames :: !(Set Frame) -- ^ Special-markers in the dynamic path 1363 , envDebug :: !DebugInfo -- ^ Debug info map 1364 , envPos :: !Pos -- ^ Source position range 1365 , envPragmas :: ![Pragma] -- ^ List of pragmas in effect 1366 , envInitDat :: !(TVar InitDat) -- ^ BEGIN result information 1367 , envMaxId :: !(TVar ObjectId) -- ^ Current max object id 1368 , envAtomic :: !Bool -- ^ Are we in an atomic transaction? 1368 1369 } 1369 1370 deriving (Show, Eq, Ord, Typeable) -- don't derive YAML for now … … 2026 2027 return $ MkEnv 2027 2028 { envContext = CxtVoid 2028 , envLexical = MkPad Map.empty2029 , envLexical = emptyPad 2029 2030 , envLexPads = [] 2030 , env DynPads = []2031 , envCaller = Nothing 2031 2032 , envCompPad = Nothing 2032 2033 , envLValue = False
