author | Patrik Svestka <patrik.svestka@gmail.com> |
Tue, 09 Apr 2019 11:34:04 +0200 | |
branch | jv |
changeset 24093 | 0f94f6c8c9d4 |
parent 18105 | 3a3a3e0ac47f |
permissions | -rw-r--r-- |
18105
3a3a3e0ac47f
Merged 619b61aee9e4 and 09837dc5030d (branch default - CVS HEAD)
Jan Vrany <jan.vrany@fit.cvut.cz>
diff
changeset
|
1 |
"{ Package: '__NoProject__' }" |
15793 | 2 |
|
5311 | 3 |
Object subclass:#QualifiedName |
4 |
instanceVariableNames:'pathString' |
|
5 |
classVariableNames:'' |
|
6 |
poolDictionaries:'' |
|
7 |
category:'Kernel-Support' |
|
8 |
! |
|
9 |
||
15793 | 10 |
!QualifiedName class methodsFor:'documentation'! |
11 |
||
12 |
documentation |
|
13 |
" |
|
14 |
some mimicri, to allow filein of visualWorks code which uses qualified names |
|
15 |
" |
|
16 |
! ! |
|
5311 | 17 |
|
18 |
!QualifiedName class methodsFor:'instance creation'! |
|
19 |
||
20 |
for:aStringOrSymbol |
|
21 |
^ self new name:aStringOrSymbol |
|
22 |
||
23 |
||
24 |
! |
|
25 |
||
26 |
makeUnambiguous |
|
27 |
^ self |
|
28 |
! |
|
29 |
||
30 |
pathString:aPathString |
|
31 |
^ self new pathString:aPathString |
|
32 |
! ! |
|
33 |
||
34 |
!QualifiedName methodsFor:'accessing'! |
|
35 |
||
36 |
asString |
|
37 |
^ pathString |
|
38 |
||
39 |
||
40 |
! |
|
41 |
||
42 |
comment:aString |
|
43 |
"empty for now" |
|
44 |
! |
|
45 |
||
46 |
name:aStringOrSymbol |
|
47 |
pathString := aStringOrSymbol asSymbol |
|
48 |
||
49 |
! |
|
50 |
||
51 |
pathString |
|
52 |
"return the value of the instance variable 'pathString' (automatically generated)" |
|
53 |
||
15793 | 54 |
^ pathString |
55 |
! |
|
5311 | 56 |
|
57 |
pathString:something |
|
58 |
"set the value of the instance variable 'pathString' (automatically generated)" |
|
59 |
||
15793 | 60 |
pathString := something. |
61 |
! ! |
|
5311 | 62 |
|
63 |
!QualifiedName methodsFor:'conditional execution'! |
|
64 |
||
65 |
value |
|
66 |
"return my binding value, if unbound, return nil" |
|
67 |
||
68 |
^ self valueOrDo:[] |
|
69 |
! |
|
70 |
||
71 |
valueOrDo:aBlock |
|
72 |
"return my binding value, if unbound, return the result from evaluating aBlock" |
|
73 |
||
74 |
|ns path| |
|
75 |
||
76 |
path := pathString asCollectionOfSubstringsSeparatedBy:$.. |
|
77 |
((path size > 0) and:[path first = 'Core']) ifTrue:[ |
|
78 |
path := path copyFrom:2 |
|
79 |
]. |
|
80 |
ns := Smalltalk. |
|
81 |
path do:[:component | |
|
82 |
ns := ns at:component asSymbol ifAbsent:[ ^ aBlock value ]. |
|
83 |
]. |
|
84 |
^ ns |
|
85 |
! ! |
|
86 |
||
87 |
!QualifiedName methodsFor:'defining'! |
|
88 |
||
89 |
defineClass: name superclass: superclass |
|
90 |
indexedType: indexed |
|
91 |
private: private |
|
92 |
instanceVariableNames: instVars |
|
93 |
classInstanceVariableNames: classInstVars |
|
94 |
imports: imports |
|
95 |
category: category |
|
96 |
attributes: annotations |
|
97 |
||
98 |
|sc| |
|
99 |
||
100 |
sc := superclass value. |
|
101 |
sc isNil ifTrue:[ |
|
102 |
self halt. |
|
103 |
]. |
|
104 |
self halt. |
|
105 |
||
106 |
! |
|
107 |
||
108 |
defineNameSpace: name private: private imports: imports category: category attributes: annotations |
|
109 |
"klduge for now" |
|
110 |
||
111 |
pathString = 'Smalltalk' ifTrue:[ |
|
5366 | 112 |
NameSpace name:name asSymbol. |
5311 | 113 |
] ifFalse:[ |
114 |
self halt. |
|
115 |
]. |
|
116 |
||
117 |
! ! |
|
118 |
||
119 |
!QualifiedName methodsFor:'dummy for now'! |
|
120 |
||
121 |
makeUnambiguous |
|
122 |
^ self |
|
123 |
||
124 |
||
125 |
! ! |
|
126 |
||
127 |
!QualifiedName class methodsFor:'documentation'! |
|
128 |
||
129 |
version |
|
15793 | 130 |
^ '$Header: /cvs/stx/stx/libbasic/QualifiedName.st,v 1.3 2013-10-27 10:14:09 cg Exp $' |
131 |
! |
|
132 |
||
133 |
version_CVS |
|
134 |
^ '$Header: /cvs/stx/stx/libbasic/QualifiedName.st,v 1.3 2013-10-27 10:14:09 cg Exp $' |
|
5311 | 135 |
! ! |
15793 | 136 |