While pragmas are compiled properly, they require additional support provided
by the Seaside framework to be fully functional. Attempts to retrieve
pragmas using only the base product will always return nil.
The following code provides basic support for pragmas. Read the comments
for details. File-in as SystemUser and commit.
! Special code for compiling and accessing Pragmas ! until feature request 43541 is implemented. ! ! Note that this establishes an IdentityDictionary in Globals ! for holding the pragmas. The eventual implementation of pragmas ! in the product is likely to use a different mechanism requiring ! that all code with pragmas be recompiled. ! ! Install the PragmaDictionary. ! ! This dictionary contains classes as keys and IdentityDictionaries ! as values. The secondary IdentityDictionaries contain method selector ! symbols as keys and the associated pragmas as values. ! run Globals at: #PragmaDictionary put: IdentityDictionary new. % category: 'Updating the Method Dictionary' method: Behavior compileMethodWithPragmas: sourceString category: categoryString "Compiles sourceString and records any pragmas in PragmaDictionary." | pragmas meth pclass | pragmas := Array new. meth := self compileMethod: sourceString dictionaries: System myUserProfile symbolList category: categoryString asSymbol intoMethodDict: nil intoCategories: nil intoPragmas: pragmas environmentId: 0. (pragmas size) > 0 ifTrue: [ pclass := PragmaDictionary at: self ifAbsent: [ nil ]. pclass ifNil: [ pclass := IdentityDictionary new. PragmaDictionary at: self put: pclass ]. pclass at: meth selector put: pragmas ]. ^ meth % category: 'Pragmas' method: GsNMethod myPragmas "Returns the pragmas associated with this method." | pclass | pclass := PragmaDictionary at: self inClass ifAbsent: [ ^nil ]. ^pclass at: self selector ifAbsent: [ nil ]. % category: 'Pragmas' method: GsMethod myPragmas "Returns the pragmas associated with this method." | pclass | pclass := PragmaDictionary at: self inClass ifAbsent: [ ^nil ]. ^pclass at: self selector ifAbsent: [ nil ]. %
Last updated: 4/9/14