SourceFileLoader.st
author Claus Gittinger <cg@exept.de>
Tue, 12 Nov 1996 13:18:57 +0100
changeset 441 fa5637faa969
parent 430 fbf6a7c19b86
child 452 466112d0d3fd
permissions -rw-r--r--
*** empty log message ***

"
 COPYRIGHT (c) 1995 by Claus Gittinger
	      All Rights Reserved

 This software is furnished under a license and may be used
 only in accordance with the terms of that license and with the
 inclusion of the above copyright notice.   This software may not
 be provided or otherwise made available to, or used by, any
 other person.  No title to or ownership of the software is
 hereby transferred.
"

Object subclass:#SourceFileLoader
	instanceVariableNames:'myStream currentSource package wantChangeLog currentNameSpace
		usedNameSpaces'
	classVariableNames:''
	poolDictionaries:''
	category:'System-Compiler'
!

!SourceFileLoader class methodsFor:'documentation'!

copyright
"
 COPYRIGHT (c) 1995 by Claus Gittinger
	      All Rights Reserved

 This software is furnished under a license and may be used
 only in accordance with the terms of that license and with the
 inclusion of the above copyright notice.   This software may not
 be provided or otherwise made available to, or used by, any
 other person.  No title to or ownership of the software is
 hereby transferred.
"
!

documentation
"
    Instances of this class are created temporary during fileIn.
    They get notified about any errors. Currently, all we
    do here is to output the error on the Transcript;
    eventually, we will open a box showing the position of the error.

    [author:]
        Claus Gittinger
"
! !

!SourceFileLoader class methodsFor:'instance creation'!

on:aStream
    ^ self new reader:aStream wantChangeLog:false
! !

!SourceFileLoader methodsFor:'accessing'!

source:aString
    currentSource := aString
! !

!SourceFileLoader methodsFor:'compiler queries'!

currentNameSpace
    "sent by the compiler to ask for the current nameSpace.
     This is still to be finished ..."

    currentNameSpace isNil ifTrue:[
	^ Smalltalk currentNameSpace
    ].
    ^ currentNameSpace

    "Created: 5.11.1996 / 22:05:19 / cg"
!

packageToInstall
    "sent by the compiler to ask in which package new methods/classes
     are to be installed.
     This is still to be finished ..."

    package isNil ifTrue:[
	^ Project currentPackageName
    ].
    ^ package

    "Created: 5.11.1996 / 19:56:03 / cg"
!

usedNameSpaces
    "sent by the compiler to ask for a list of used nameSpaces.
     This is still to be finished ..."

    ^ usedNameSpaces

    "Created: 5.11.1996 / 22:05:37 / cg"
!

wantChangeLog
    "sent by the compiler to ask if a changeLog entry should
     be written. Return false here, since SourceFileLaoders are
     used to read existing source files"

    ^ wantChangeLog
! !

!SourceFileLoader methodsFor:'directve processing'!

requirePackage:packageName
    'require package: ' print.
    packageName printCR

    "Modified: 20.5.1996 / 10:29:05 / cg"
!

setNameSpace:aNameSpaceName
    "set the namespace for further variable resolving"

    currentNameSpace := Namespace fullName:aNameSpaceName

    "Modified: 8.11.1996 / 13:42:54 / cg"
!

setPackage:packageName
    package := packageName asSymbol

    "Modified: 5.11.1996 / 20:24:33 / cg"
!

setUsedSpace:aNameSpace
    usedNameSpaces isNil ifTrue:[
        usedNameSpaces := OrderedCollection new.
    ].
    usedNameSpaces add:aNameSpace

    "Modified: 5.11.1996 / 22:03:53 / cg"
    "Created: 5.11.1996 / 22:04:39 / cg"
! !

!SourceFileLoader methodsFor:'error handling'!

correctableError:aMessage position:position to:endPos from:aCompiler
    "error notification during fileIn.
     This is sent by the compiler/evaluator if it detects errors."

    Transcript show:'**  '; showCR:aMessage.
    self showWherePosition:position to:endPos from:aCompiler.
    ^ false

    "Modified: 8.11.1996 / 18:53:17 / cg"
!

error:aMessage position:position to:endPos from:aCompiler
    "error notification during fileIn.
     This is sent by the compiler/evaluator if it detects errors."

    "
     will eventually open a TextBox here, showing the error ....
    "
    Transcript show:'===>  '; showCR:aMessage.
    self showWherePosition:position to:endPos from:aCompiler.
    ^ false

    "Modified: 8.11.1996 / 18:49:41 / cg"
!

insertAndSelect:aString at:aCharacterPosition
    "ST-80 compatible error notification during fileIn."

    "
     will eventually open a TextBox here, showing the error ....
    "
    Transcript show:'===>  '; showCR:aString.
    ^ false

    "Modified: 18.5.1996 / 15:44:54 / cg"
!

showWherePosition:position to:endPos from:aCompiler
    "show more details about the errors/warnings position."

    |cls sel where|

    "
     will eventually open a TextBox here, showing the error ....
    "
    (cls := aCompiler targetClass) notNil ifTrue:[
        (sel := aCompiler selector) notNil ifTrue:[
            Transcript show:'      when compiling '; show:cls name.
            Transcript show:'>>'; show:sel.
        ] ifFalse:[
            Transcript show:'      when compiling/evaluating for '; show:cls name.
        ].
        Transcript cr.
    ].
    myStream isFileStream ifTrue:[
        Transcript show:'      while reading '; show:myStream pathName.
        Transcript cr.
    ].
    (where := aCompiler lastTokenLineNumber) notNil ifTrue:[
        Transcript show:'      at or near line '; show:where.
        Transcript cr.
    ].

    "Created: 8.11.1996 / 18:49:08 / cg"
    "Modified: 8.11.1996 / 18:51:11 / cg"
!

warning:aMessage position:position to:endPos from:aCompiler
    "warning notification during fileIn - ignore it.
     This is sent by the compiler/evaluator if it detects errors."

    ^ self
! !

!SourceFileLoader methodsFor:'private access'!

reader:aStream wantChangeLog:aBoolean
    myStream := aStream.
    wantChangeLog := aBoolean
! !

!SourceFileLoader class methodsFor:'documentation'!

version
    ^ '$Header: /cvs/stx/stx/libcomp/SourceFileLoader.st,v 1.19 1996-11-08 17:55:22 cg Exp $'
! !