--- a/Parser.st Thu Aug 01 14:07:09 2019 +0200
+++ b/Parser.st Fri Aug 09 11:55:58 2019 +0200
@@ -1,3 +1,5 @@
+"{ Encoding: utf8 }"
+
"
COPYRIGHT (c) 1989 by Claus Gittinger
All Rights Reserved
@@ -2129,15 +2131,22 @@
genMakeArrayWith:elementExpressions
"return a node to generate an array at runtime.
Will generate:
- Array with:el1 ... with:elN (if N <= 5)
- or:
+ literal shallowCopy (if all elements are literals)
+ or else:
+ Array with:el1 ... with:elN (if N <= 8)
+ or else:
(Array new at:1 put:el1; ... at:N put:elN; yourself) (otherwise)
"
|numEl arrRec sel expr|
+ (elementExpressions conform:#isConstant) ifTrue:[
+ arrRec := ConstantNode type:#Array value:(elementExpressions collect:#value as:Array) from:-1 to:-1. "/ position -1 means artifitial node
+ ^ MessageNode receiver:arrRec selector:#shallowCopy.
+ ].
+
arrRec := VariableNode globalNamed:#Array.
- arrRec startPosition: -1 endPosition: -1. "/ -1 means artifitial node
+ arrRec startPosition:-1 endPosition:-1. "/ position -1 means artifitial node
numEl := elementExpressions size.
@@ -2163,7 +2172,7 @@
expr := MessageNode
receiver:arrRec
selector:#new:
- arg:(ConstantNode type:#Integer value:numEl from: -1 to: -1). "/ -1 means artifitial node
+ arg:(ConstantNode type:#Integer value:numEl from:-1 to:-1). "/ position -1 means artifitial node
numEl == 0 ifTrue:[
^ expr.
@@ -2173,7 +2182,7 @@
expr := (idx == 1 ifTrue:[MessageNode] ifFalse:[CascadeNode])
receiver:expr
selector:#at:put:
- arg1:(ConstantNode type:#Integer value:idx from: -1 to:-1)"/ -1 means artifitial node
+ arg1:(ConstantNode type:#Integer value:idx from:-1 to:-1)"/ position -1 means artifitial node
arg2:e
fold:false.
].
@@ -6829,8 +6838,8 @@
].
parserFlags warnAboutPossibleSTCCompilationProblems ifTrue:[
self
- warning:'stc will not compile this'
- line:lineNr.
+ warning:('stc will not compile this (non-Standard Squeak/Pharo array elements: "." or ";")\\Hint last token''s value was "',tokenValue?'','"') withCRs
+ position:tokenPosition. "/ line:lineNr.
].
self warnPossibleIncompatibility:'non-Standard Squeak/Pharo array elements: "." or ";"' position:tokenPosition to:tokenPosition+token size - 1.
tokenValue := tokenType asSymbol.
@@ -7434,43 +7443,44 @@
|existingClass class inlineObjectsAreReadonly protoClass|
inlineObjectsAreReadonly := parserFlags arraysAreImmutable.
-
- existingClass := InlineObjectClassDescription subclasses
- detect:[:cls | cls instVarNames = slotNames]
- ifNone:[nil].
- existingClass notNil ifTrue:[ ^ existingClass].
-
- class := InlineObjectClassDescription new.
- class setSuperclass: InlineObject.
- class setInstVarNames:slotNames.
- class instSize: slotNames size.
-
- protoClass := InlineObject prototype.
- slotNames keysAndValuesDo:[:idx :instVarName |
- |protoMethod|
-
- idx <= protoClass instSize ifTrue:[
- protoMethod := protoClass compiledMethodAt:('i%1' bindWith:idx) asSymbol.
- class basicAddSelector:instVarName withMethod:protoMethod.
- "/ fixup: undo side effect of adding selector (mclass changed)
- protoMethod mclass:protoClass.
-
- inlineObjectsAreReadonly ifFalse:[
- protoMethod := protoClass compiledMethodAt:('i%1:' bindWith:idx) asSymbol.
- class basicAddSelector:(instVarName asMutator) withMethod:protoMethod.
- "/ fixup: undo side effect of adding selector (mclass changed)
- protoMethod mclass:protoClass.
- ].
- ] ifFalse:[
- Class withoutUpdatingChangesDo:[
- Compiler compile:('%1 ^%1' bindWith:instVarName) forClass:class.
- inlineObjectsAreReadonly ifFalse:[
- Compiler compile:('%1:something %1 := something' bindWith:instVarName) forClass:class.
- ].
- ].
- ].
- ].
- ^ class
+ ^ InlineObject classForSlotNames:slotNames mutable:(inlineObjectsAreReadonly not).
+
+"/ existingClass := InlineObjectClassDescription subclasses
+"/ detect:[:cls | cls instVarNames = slotNames]
+"/ ifNone:[nil].
+"/ existingClass notNil ifTrue:[ ^ existingClass].
+"/
+"/ class := InlineObjectClassDescription new.
+"/ class setSuperclass: InlineObject.
+"/ class setInstVarNames:slotNames.
+"/ class instSize: slotNames size.
+"/
+"/ protoClass := InlineObject prototype.
+"/ slotNames keysAndValuesDo:[:idx :instVarName |
+"/ |protoMethod|
+"/
+"/ idx <= protoClass instSize ifTrue:[
+"/ protoMethod := protoClass compiledMethodAt:('i%1' bindWith:idx) asSymbol.
+"/ class basicAddSelector:instVarName withMethod:protoMethod.
+"/ "/ fixup: undo side effect of adding selector (mclass changed)
+"/ protoMethod mclass:protoClass.
+"/
+"/ inlineObjectsAreReadonly ifFalse:[
+"/ protoMethod := protoClass compiledMethodAt:('i%1:' bindWith:idx) asSymbol.
+"/ class basicAddSelector:(instVarName asMutator) withMethod:protoMethod.
+"/ "/ fixup: undo side effect of adding selector (mclass changed)
+"/ protoMethod mclass:protoClass.
+"/ ].
+"/ ] ifFalse:[
+"/ Class withoutUpdatingChangesDo:[
+"/ Compiler compile:('%1 ^%1' bindWith:instVarName) forClass:class.
+"/ inlineObjectsAreReadonly ifFalse:[
+"/ Compiler compile:('%1:something %1 := something' bindWith:instVarName) forClass:class.
+"/ ].
+"/ ].
+"/ ].
+"/ ].
+"/ ^ class
"Created: / 30-05-2019 / 12:00:59 / Claus Gittinger"
!
@@ -10619,8 +10629,10 @@
genMakeArrayWith:elementExpressions
"return a node to generate an array at runtime.
Will generate:
- Array with:el1 ... with:elN (if N <= 5)
- or:
+ literal shallowCopy (if all elements are literals)
+ or else:
+ Array with:el1 ... with:elN (if N <= 8)
+ or else:
(Array new at:1 put:el1; ... at:N put:elN; yourself) (otherwise)
"