ResourcePack.st
changeset 3567 f85c170f14e8
parent 3549 8c924bf310ed
child 3678 d180d63dc7ca
--- a/ResourcePack.st	Tue Dec 04 14:21:55 2001 +0100
+++ b/ResourcePack.st	Tue Dec 04 14:22:49 2001 +0100
@@ -598,8 +598,8 @@
             (value isNil) ifTrue:[
                 hasError := true.
                 ('ResourcePack [warning]: bad (nil-valued) macro: ' , macroName) errorPrintCR.
-		('ResourcePack [warning]: in line: ' , lineString) errorPrintCR.
-		('ResourcePack [warning]: in file: ' , fileName) errorPrintCR.
+                ('ResourcePack [warning]: in line: ' , lineString) errorPrintCR.
+                ('ResourcePack [warning]: in file: ' , fileName) errorPrintCR.
             ].
             value isBlock ifTrue:[
                 value := value value
@@ -611,14 +611,14 @@
             (value == #Error) ifTrue:[
                 hasError := true.
                 ('ResourcePack [warning]: error in line: "self ' , rest , '"') errorPrintCR.
-		('ResourcePack [warning]: in file: ' , fileName) errorPrintCR.
+                ('ResourcePack [warning]: in file: ' , fileName) errorPrintCR.
             ]
         ] ifFalse:[
             value := Compiler evaluate:rest compile:false.
             (value == #Error) ifTrue:[
                 hasError := true.
                 ('ResourcePack [warning]: error in line: "' , rest , '"') errorPrintCR.
-		('ResourcePack [warning]: in file: ' , fileName) errorPrintCR.
+                ('ResourcePack [warning]: in file: ' , fileName) errorPrintCR.
             ] ifFalse:[
                 encoding notNil ifTrue:[
                     value isString ifTrue:[
@@ -677,7 +677,7 @@
      specify where #include files are searched for.
      Return true, if the style sheet could be read without errors, false otherwise."
 
-    |lineString l lNo rest value ifLevel skipping first ok encoding pack|
+    |lineString l lNo rest value ifLevel skipping first ok encoding pack errorHandler|
 
     encoding := nil.
 
@@ -685,6 +685,22 @@
     ifLevel := 0.
     skipping := false.
     lNo := 0.
+
+    errorHandler := [:ex | 
+                        |con|
+
+                        ('ResourcePack [warning]: ''' , ex errorString , '''') errorPrintCR.
+                        ('ResourcePack [info]: file: ' , inStream pathName printString , ' line: ' , lNo printString , ': ''' , lineString , '''') errorPrintCR.
+                        con := ex suspendedContext.
+                        ('ResourcePack [info]: in: ' , con fullPrintString) errorPrintCR.
+                        con := con sender.
+                        ('ResourcePack [info]:   : ' , con fullPrintString) errorPrintCR.
+                        con := con sender.
+                        ('ResourcePack [info]:   : ' , con fullPrintString) errorPrintCR.
+                        value := nil.
+                        ok := false.
+                    ].
+
     [inStream atEnd] whileFalse:[
         lineString := inStream nextLine. lNo := lNo + 1.
         [lineString notNil and:[lineString endsWith:$\]] whileTrue:[
@@ -702,21 +718,16 @@
             "/
             ((first == $;) or:[lineString startsWith:'"/']) ifFalse:[
                 first == $# ifTrue:[
+                    "/ a directive
                     lineString := (lineString copyFrom:2) withoutSpaces.
 
                     (lineString startsWith:'if') ifTrue:[
                         skipping ifFalse:[
                             rest := lineString copyFrom:3.
-                            ErrorSignal handle:[:ex |
-                                ('ResourcePack [warning]: ''' , ex errorString , '''') errorPrintCR.
-                                ('ResourcePack [info]: file: ' , inStream pathName printString , ' line: ' , lNo printString , ': ''' , lineString , '''') errorPrintCR.
-                                ('ResourcePack [info]: in: ' , ex suspendedContext fullPrintString) errorPrintCR.
-                                ('ResourcePack [info]:   : ' , ex suspendedContext sender fullPrintString) errorPrintCR.
-                                ('ResourcePack [info]:   : ' , ex suspendedContext sender sender fullPrintString) errorPrintCR.
-                                value := nil.
-                            ] do:[
-                                value := Compiler evaluate:rest compile:false.
-                            ].
+                            ErrorSignal 
+                                handle:errorHandler 
+                                do:[
+                                    value := Compiler evaluate:rest compile:false].
                             (value == #Error) ifTrue:[
                                 ('ResourcePack [warning]: error in resource:' , lineString) errorPrintCR.
                             ].
@@ -769,21 +780,24 @@
                     ].
                 ] ifFalse:[
                     skipping ifFalse:[
-                        ErrorSignal handle:[:ex |
-                            ('ResourcePack [warning]: ''' , ex errorString , '''') errorPrintCR.
-                            ('ResourcePack [info]: file: ' , inStream pathName printString , ' line: ' , lNo printString , ': ''' , lineString , '''') errorPrintCR.
-                            ('ResourcePack [info]: in: ' , ex suspendedContext fullPrintString) errorPrintCR.
-                            ('ResourcePack [info]:   : ' , ex suspendedContext sender fullPrintString) errorPrintCR.
-                            ('ResourcePack [info]:   : ' , ex suspendedContext sender sender fullPrintString) errorPrintCR.
-                            ok := false.
-                        ] do:[
-                            self 
-                                processLine:lineString 
-                                encoding:encoding 
-                                file:(inStream isFileStream 
-                                        ifTrue:[inStream pathName]
-                                        ifFalse:['---'])
-                        ]
+                        ErrorSignal 
+                            handle:errorHandler 
+                            do:[
+                                (lineString at:1) == $!! ifTrue:[
+                                    "/ evaluate the rest
+                                    Compiler evaluate:(lineString copyFrom:2)
+                                                      receiver:nil
+                                                      notifying:nil
+                                                      compile:false.
+                                ] ifFalse:[
+                                    "/ process as resource
+                                    self 
+                                        processLine:lineString 
+                                        encoding:encoding 
+                                        file:(inStream isFileStream 
+                                                ifTrue:[inStream pathName]
+                                                ifFalse:['---'])
+                                ]]
                     ]
                 ]
             ]
@@ -798,6 +812,6 @@
 !ResourcePack class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libview/ResourcePack.st,v 1.69 2001-11-16 11:32:27 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libview/ResourcePack.st,v 1.70 2001-12-04 13:22:49 cg Exp $'
 ! !
 ResourcePack initialize!