QualifiedName.st
author Jan Vrany <jan.vrany@fit.cvut.cz>
Mon, 15 Jun 2009 20:55:05 +0100
branchjv
changeset 17711 39faaaf888b4
parent 5366 82060eed5886
child 17845 7e0cfaac936d
permissions -rw-r--r--
Added branch jv

Object subclass:#QualifiedName
	instanceVariableNames:'pathString'
	classVariableNames:''
	poolDictionaries:''
	category:'Kernel-Support'
!


!QualifiedName class methodsFor:'instance creation'!

for:aStringOrSymbol
    ^ self new name:aStringOrSymbol


!

makeUnambiguous
    ^ self
!

pathString:aPathString
    ^ self new pathString:aPathString
! !

!QualifiedName methodsFor:'accessing'!

asString
    ^ pathString


!

comment:aString
    "empty for now"
!

name:aStringOrSymbol
    pathString := aStringOrSymbol asSymbol

!

pathString
    "return the value of the instance variable 'pathString' (automatically generated)"

    ^ pathString!

pathString:something
    "set the value of the instance variable 'pathString' (automatically generated)"

    pathString := something.! !

!QualifiedName methodsFor:'conditional execution'!

value
    "return my binding value, if unbound, return nil"

    ^ self valueOrDo:[]
!

valueOrDo:aBlock
    "return my binding value, if unbound, return the result from evaluating aBlock"

    |ns path|

    path := pathString asCollectionOfSubstringsSeparatedBy:$..
    ((path size > 0) and:[path first = 'Core']) ifTrue:[
        path := path copyFrom:2
    ].
    ns := Smalltalk.
    path do:[:component |
        ns := ns at:component asSymbol ifAbsent:[ ^ aBlock value ].
    ].
    ^ ns
! !

!QualifiedName methodsFor:'defining'!

defineClass: name superclass: superclass
                indexedType: indexed
                private: private
                instanceVariableNames: instVars
                classInstanceVariableNames: classInstVars
                imports: imports
                category: category
                attributes: annotations

    |sc|

    sc := superclass value.
    sc isNil ifTrue:[
self halt.
    ].
self halt.

!

defineNameSpace: name private: private imports: imports category: category attributes: annotations
    "klduge for now"

    pathString = 'Smalltalk' ifTrue:[
        NameSpace name:name asSymbol.
    ] ifFalse:[
    self halt.
    ].

! !

!QualifiedName methodsFor:'dummy for now'!

makeUnambiguous
    ^ self


! !

!QualifiedName class methodsFor:'documentation'!

version
    ^ '$Id: QualifiedName.st 10447 2009-06-14 13:09:55Z vranyj1 $'
! !