On Mon, 2007-07-16 at 12:27 +0300, Paolo Bonzini wrote: > Would you mind preparing a patch to rename all compileString: keywords > to primCompile: (it is tangential to this one)? It has been able to do > streams too since 2.3.
patch-50
rename #compileString:* to #primCompile:*
Also includes some changes to the evaluation methods on Behavior.
--
;;; Stephen Compall ** http://scompall.nocandysw.com/blog **
"Peta" is Greek for fifth; a petabyte is 10 to the fifth power, as
well as fifth in line after kilo, mega, giga, and tera.
-- Lee Gomes, performing every Wednesday in his tech column
"Portals" on page B1 of The Wall Street Journal
2007-07-17 Stephen Compall <[EMAIL PROTECTED]>
* packages/stinst/compiler/STCompiler.st: Rename #compileString:
et al to #primCompile:, and change uses accordingly.
* kernel/Behavior.st: Rename #compileString: to #primCompile: and
document; similarly with #compileString:ifError:. In evaluation
methods, remove vacuous "code isMemberOf: String" cases in
evaluation methods, remove some inlining, and fix the WriteStream
cases.
(#compile:, #compile:ifError:): Use #primCompile:.
(#evalString:to:, #evalString:to:ifError:): Use #compile: and
#compile:ifError:.
* kernel/Metaclass.st: Mention #primCompile:.
* unsupported/er2.st: Use #primCompile:.
* unsupported/IfError.st: Likewise.
* packages/httpd/STT.st: Use #compile:.
* libgst/prims.def: Rename compileString primitives to
primCompile.
* libgst/xlat.c: Mention #primCompile:.
--- orig/kernel/Behavior.st
+++ mod/kernel/Behavior.st
@@ -215,11 +215,11 @@
"Compile method source. If there are parsing errors, answer nil.
Else, return a CompiledMethod result of compilation"
(code isKindOf: WriteStream)
- ifTrue: [ ^self compileString: code readStream ].
+ ifTrue: [ ^self primCompile: code readStream ].
(code isKindOf: Stream)
- ifTrue: [ ^self compileString: code ].
+ ifTrue: [ ^self primCompile: code ].
- ^self compileString: code asString
+ ^self primCompile: code asString
!
compile: code ifError: block
@@ -227,11 +227,11 @@
exception block, 'block' passing file name, line number and
error. Return a CompiledMethod result of compilation"
(code isKindOf: WriteStream)
- ifTrue: [ ^self compileString: code readStream ifError: block ].
+ ifTrue: [ ^self primCompile: code readStream ifError: block ].
(code isKindOf: Stream)
- ifTrue: [ ^self compileString: code ifError: block ].
+ ifTrue: [ ^self primCompile: code ifError: block ].
- ^self compileString: code asString ifError: block
+ ^self primCompile: code asString ifError: block
!
compile: code notifying: requestor
@@ -378,7 +378,7 @@
[
next := self extractEvalChunk: s.
method := anObject class
- compileString: 'Doit ^ [
+ compile: 'Doit ^ [
', next, ' ] value ' ifError: [ :fname :line :error | nil ].
method isNil | (next allSatisfy: [ :each | each = Character space ])
@@ -393,14 +393,14 @@
evalString: aString to: anObject ifError: aBlock
"Answer the stack top at the end of the evaluation of the code in
aString. If aString cannot be parsed, evaluate aBlock (see
- compileString:ifError:). The code is executed as part of anObject"
+ compile:ifError:). The code is executed as part of anObject"
| s result next method |
s := ReadStream on: aString.
[
next := self extractEvalChunk: s.
method := anObject class
- compileString: 'Doit ^ [
+ compile: 'Doit ^ [
', next, ' ] value '
ifError: [:fname :lineNo :errorString |
aBlock value: fname value: lineNo - 1 value: errorString.
@@ -419,26 +419,14 @@
evaluate: code
"Evaluate Smalltalk expression in 'code' and return result."
- (code isKindOf: WriteStream)
- ifTrue: [ ^self compileString: code readStream ].
- (code isKindOf: Stream)
- ifTrue: [ ^self evalString: code contents to: nil ].
- (code isMemberOf: String)
- ifFalse: [ ^self evalString: code asString to: nil ].
- ^self evalString: code to: nil
+ ^self evaluate: code to: nil
!
evaluate: code ifError: block
"Evaluate 'code'. If a parsing error is detected, invoke 'block'"
- (code isKindOf: WriteStream)
- ifTrue: [ ^self compileString: code readStream ].
- (code isKindOf: Stream)
- ifTrue: [ ^self evalString: code contentsto: nil ifError: block ].
- (code isMemberOf: String)
- ifFalse: [ ^self evalString: code asString to: nil ifError: block ].
- ^self evalString: code to: nil ifError: block.
+ ^self evaluate: code to: nil ifError: block
!
evaluate: code to: anObject ifError: block
@@ -446,24 +434,16 @@
method is used to support Inspector expression evaluation. If a parsing error
is encountered, invoke error block, 'block'"
- (code isKindOf: WriteStream)
- ifTrue: [ ^self compileString: code readStream ].
- (code isKindOf: Stream)
+ (code isKindOf: Stream)
ifTrue: [ ^self evalString: code contents to: anObject ifError: block ].
- (code isMemberOf: String)
- ifFalse: [ ^self evalString: code asString to: anObject ifError: block ].
^self evalString: code to: anObject ifError: block.
!
evaluate: code to: anObject
"Evaluate Smalltalk expression as part of anObject's method definition"
- (code isKindOf: WriteStream)
- ifTrue: [ ^self compileString: code readStream ].
(code isKindOf: Stream)
ifTrue: [ ^self evalString: code contents to: anObject ].
- (code isMemberOf: String)
- ifFalse: [ ^self evalString: code asString to: anObject ].
^self evalString: code to: anObject.
!
@@ -1401,19 +1381,24 @@
^self primitiveFailed
!
-compileString: aString
- "Compile the code in aString, with no category. Fail if the code
- does not obey Smalltalk syntax. Answer the generated CompiledMethod
- if it does"
- <primitive: VMpr_Behavior_compileString>
+primCompile: code
+ "Compile the code, a string or readable stream, with no
+ category. Fail if the code does not obey Smalltalk syntax. Answer
+ the generated CompiledMethod if it does.
+
+ Do not send this in user code; use #compile: or related methods
+ instead."
+ <primitive: VMpr_Behavior_primCompile>
^self primitiveFailed
!
-compileString: aString ifError: aBlock
- "Compile the code in aString, with no category. Evaluate aBlock
- (passing the file name, line number and description of the error) if
- the code does not obey Smalltalk syntax. Answer the generated
- CompiledMethod if it does"
- <primitive: VMpr_Behavior_compileStringIfError>
+primCompile: code ifError: aBlock
+ "As with #primCompile:, but evaluate aBlock (passing the file
+ name, line number and description of the error) if the code does
+ not obey Smalltalk syntax.
+
+ Do not send this in user code; use #compile:ifError: or related
+ methods instead."
+ <primitive: VMpr_Behavior_primCompileIfError>
^self primitiveFailed
! !
--- orig/kernel/Metaclass.st
+++ mod/kernel/Metaclass.st
@@ -340,7 +340,7 @@
"Please note that I need to recompile the classes in this sequence;
otherwise, the same error is propagated to each selector which is compiled
after an error is detected even though there are no further compilation
- errors. Apparently, there is a bug in the primitive compileString. This
+ errors. Apparently, there is a bug in the primitive #primCompile:. This
can be cleaned up later"
(needToRecompileClasses | needToRecompileMetaclasses)
--- orig/libgst/prims.def
+++ mod/libgst/prims.def
@@ -4941,9 +4941,9 @@
PRIM_FAILED;
}
-/* Behavior compileString: aString */
+/* Behavior primCompile: aString */
-primitive VMpr_Behavior_compileString [succeed]
+primitive VMpr_Behavior_primCompile [succeed]
{
OOP oop1;
OOP oop2;
@@ -4964,8 +4964,8 @@
PRIM_SUCCEEDED;
}
-/* Behavior compileString: aString ifError: aBlock */
-primitive VMpr_Behavior_compileStringIfError [fail,succeed,reload_ip]
+/* Behavior primCompile: aString ifError: aBlock */
+primitive VMpr_Behavior_primCompileIfError [fail,succeed,reload_ip]
{
OOP oop1;
OOP oop2;
--- orig/libgst/xlat.c
+++ mod/libgst/xlat.c
@@ -3223,7 +3223,7 @@
/* If they don't, check if we came here because somebody called
send_block_value. In this case, the number of arguments is surely
valid and the inline cache's numArgs is bogus. This handles
- #valueWithArguments:, #compileString:ifError: and other primitives
+ #valueWithArguments:, #primCompile:ifError: and other primitives
in which send_block_value is used. */
jit_ldi_p (JIT_R2, &native_ip);
jit_bnei_p (do_send_code, JIT_R2, current->nativeCode);
--- orig/packages/httpd/STT.st
+++ mod/packages/httpd/STT.st
@@ -120,7 +120,7 @@
stream := String new writeStream.
self writeSmalltalkCodeOn: stream.
- method := anObject class compileString: stream contents.
+ method := anObject class compile: stream contents.
self cache: method.
anObject class removeSelector: method selector.
^method
--- orig/packages/stinst/compiler/StartCompiler.st
+++ mod/packages/stinst/compiler/StartCompiler.st
@@ -324,14 +324,14 @@
compile: code for: self
classified: nil parser: dummyParser].
(code isKindOf: WriteStream)
- ifTrue: [ ^self compileString: code readStream ifError: block ].
+ ifTrue: [ ^self primCompile: code readStream ifError: block ].
(code isKindOf: Stream)
- ifTrue: [ ^self compileString: code ifError: block ].
+ ifTrue: [ ^self primCompile: code ifError: block ].
- ^self compileString: code asString ifError: block
+ ^self primCompile: code asString ifError: block
!
-compileString: aString
+primCompile: aString
"Compile aString, which should be a string or stream, as a method
for my instances, installing it in my method dictionary. Signal
an error if parsing or compilation fail, otherwise answer the
@@ -350,7 +350,7 @@
parser: parser
!
-compileString: aString ifError: aBlock
+primCompile: aString ifError: aBlock
| parser source |
source := aString isString
ifTrue: [ aString ]
--- orig/unsupported/IfError.st
+++ mod/unsupported/IfError.st
@@ -1,5 +1,5 @@
-Object compileString: 'foo 3+'!
-Object compileString: 'foo 3+'
+Object primCompile: 'foo 3+'!
+Object primCompile: 'foo 3+'
ifError: [:a :b :c | a printNl.
b printNl.
c printNl]!
--- orig/unsupported/er2.st
+++ mod/unsupported/er2.st
@@ -2,7 +2,7 @@
testInternal: aString block: aBlock
' in test internal' printNl.
- self compileString: aString
+ self primCompile: aString
ifError: aBlock.
' leaving test internal' printNl
!
@@ -29,7 +29,7 @@
']]]' printNl.
! !
-Object compileString: 'foo 3+'!
+Object primCompile: 'foo 3+'!
Object testExternal: 'foo 3+'!
Object myTest: 'foo 3+'!
signature.asc
Description: This is a digitally signed message part
_______________________________________________ help-smalltalk mailing list [email protected] http://lists.gnu.org/mailman/listinfo/help-smalltalk
