renamed jump_xxxward_if_xxx to jumpop_xxxward_if_xxx because it does pop the stack top.

added jump_forward_if_true, jump_forward_if_fase, jump2_forward_if_true, jump2_forward_if_false to use with the and and or logical operation keywords
This commit is contained in:
hyunghwan.chung
2018-05-30 15:32:09 +00:00
parent 8965720926
commit e074607a00
11 changed files with 252 additions and 201 deletions

View File

@ -332,7 +332,7 @@ class OrderedCollection(SequenceableCollection)
{
| i |
i := index + self.firstIndex.
if (i >= self.firstIndex and: [i < self.lastIndex]) { ^self.buffer at: index }.
if ((i >= self.firstIndex) and (i < self.lastIndex)) { ^self.buffer at: index }.
Exception signal: ('index ' & index asString & ' out of range').
}
@ -341,7 +341,7 @@ class OrderedCollection(SequenceableCollection)
## replace an existing element. it doesn't grow the buffer.
| i |
i := index + self.firstIndex.
if (i >= self.firstIndex and: [i < self.lastIndex]) { ^self.buffer at: index put: obj }.
if ((i >= self.firstIndex) and (i < self.lastIndex)) { ^self.buffer at: index put: obj }.
Exception signal: ('index ' & index asString & ' out of range').
}
@ -433,7 +433,7 @@ class OrderedCollection(SequenceableCollection)
method removeFirst: count
{
| r i |
if (count > self size or: [count < 0]) { Exception signal: 'removal count too big/small' }.
if ((count > self size) or (count < 0)) { Exception signal: 'removal count too big/small' }.
r := Array new: count.
i := 0.
while (i < count)
@ -449,7 +449,7 @@ class OrderedCollection(SequenceableCollection)
method removeLast: count
{
| r i li |
if (count > self size or: [count < 0]) { Exception signal: 'removal count too big/small' }.
if ((count > self size) or (count < 0)) { Exception signal: 'removal count too big/small' }.
r := Array new: count.
i := 0.
while (i < count)
@ -468,7 +468,7 @@ class OrderedCollection(SequenceableCollection)
## remove the element at the given position.
| obj |
obj := self at: index. ## the range is checed by the at: method.
self __remove_Index(index + self.firstIndex).
self __remove_index(index + self.firstIndex).
^obj
}
@ -580,7 +580,7 @@ class OrderedCollection(SequenceableCollection)
else
{
cursize := self size.
if (self.firstIndex > 0 and: [index <= (cursize bitShift: -1)])
if ((self.firstIndex > 0) and (index <= (cursize bitShift: -1)))
{
start := self.firstIndex - 1.
self.buffer replaceFrom: start to: (start + index - 1) with: self.buffer startingAt: self.firstIndex.
@ -778,7 +778,7 @@ class Set(Collection)
{
| ass |
ass := self __find: key or_upsert: false with: nil.
^ass key = key and: [ass value = value]
^(ass key = key) and (ass value = value)
}
method __find_index: key
@ -818,7 +818,7 @@ class Set(Collection)
z := (ass key hash) rem: bs.
(* move an element if necessary *)
if ((y > x and: [(z <= x) or: [z > y]]) or: [(y < x) and: [(z <= x) and: [z > y]]])
if (((y > x) and ((z <= x) or (z > y))) or ((y < x) and ((z <= x) and (z > y))))
{
self.bucket at: x put: (self.bucket at: y).
x := y.

View File

@ -51,7 +51,8 @@ TODO: can i convert 'thisProcess primError' to a relevant exception?
while (exctx notNil)
{
exblk := exctx findExceptionHandlerFor: (self class).
if (exblk notNil and: [actpos := exctx basicSize - 1. exctx basicAt: actpos])
##if (exblk notNil and: [actpos := exctx basicSize - 1. exctx basicAt: actpos])
if ((exblk notNil) and (exctx basicAt: (actpos := exctx basicSize - 1)))
{
self.handlerContext := exctx.
exctx basicAt: actpos put: false.
@ -119,7 +120,7 @@ System logNl: '== END OF BACKTRACE =='.
## TODO: verify if return:to: causes unnecessary stack growth.
## is this correct???
| ctx |
if (self.signalContext notNil and: [self.handlerContext notNil])
if ((self.signalContext notNil) and (self.handlerContext notNil))
{
ctx := self.signalContext sender.
self.signalContext := nil.
@ -272,7 +273,7 @@ extend MethodContext
while (i < size)
{
exc := self basicAt: i.
if ((exception_class == exc) or: [exception_class inheritsFrom: exc])
if ((exception_class == exc) or (exception_class inheritsFrom: exc))
{
^self basicAt: (i + 1).
}.
@ -301,7 +302,7 @@ extend MethodContext
actpos := (self basicSize) - 1.
excblk := self findExceptionHandlerFor: (exception class).
if (excblk isNil or: [(self basicAt: actpos) not])
if ((excblk isNil) or ((self basicAt: actpos) not))
{
## self is an exception context but doesn't have a matching
## exception handler or the exception context is already

View File

@ -7,17 +7,20 @@ class Magnitude(Object)
method between: min and: max
{
^self >= min and: [self <= max]
^self >= min and self <= max
}
method min: aMagnitude
{
^self < aMagnitude ifTrue: [self] ifFalse: [aMagnitude]
##^self < aMagnitude ifTrue: [self] ifFalse: [aMagnitude]
^if (self < aMagnitude) { self } else { aMagnitude }.
}
method max: aMagnitude
{
^self > aMagnitude ifTrue: [self] ifFalse: [aMagnitude]
##^self > aMagnitude ifTrue: [self] ifFalse: [aMagnitude]
^if (self > aMagnitude) { self } else { aMagnitude }.
}
}
@ -53,7 +56,7 @@ class Association(Magnitude)
method = ass
{
^(self.key = ass key) and: [ self.value = ass value ]
^(self.key = ass key) and (self.value = ass value)
}
method hash
@ -85,15 +88,15 @@ class(#limited) Character(Magnitude)
{
##<primitive: #Character_digitValue>
if (self >= $0 and: [self <= $9])
if ((self >= $0) and (self <= $9))
{
^self asInteger - $0 asInteger
}
elsif (self >= $A and: [self <= $Z])
elsif ((self >= $A) and (self <= $Z))
{
^self asInteger - $A asInteger + 10
}
elsif (self >= $a and: [self <= $z])
elsif ((self >= $a) and (self <= $z))
{
^self asInteger - $a asInteger + 10
}.

View File

@ -395,7 +395,7 @@ class SemaphoreHeap(Object)
left := self leftChildIndex: cindex.
right := self rightChildIndex: cindex.
younger := if ((right < self.size) and: [(self.arr at: right) youngerThan: (self.arr at: left)]) { right } else { left }.
younger := if ((right < self.size) and ((self.arr at: right) youngerThan: (self.arr at: left))) { right } else { left }.
xitem := self.arr at: younger.
if (item youngerThan: xitem) { break }.

View File

@ -54,13 +54,13 @@ class(#byte(4)) IP4Address(IPAddress)
c := str at: pos.
pos := pos + 1.
if (c >= $0 and: [c <= $9])
if ((c >= $0) and (c <= $9))
{
acc := acc * 10 + (c asInteger - $0 asInteger).
if (acc > 255) { Exception signal: ('invalid IPv4 address B ' & str). }.
digits := digits + 1.
}
elsif (c = $.)
elsif (c == $.)
{
if (dots >= 3 or: [digits == 0]) { ^Error.Code.EINVAL }.
self basicAt: (dots + address_offset) put: acc.
@ -113,7 +113,7 @@ class(#byte(16)) IP6Address(IP4Address)
mysize := self basicSize.
## handle leading :: specially
if (size > 0 and: [(str at: pos) == $:])
if ((size > 0) and ((str at: pos) == $:))
{
pos := pos + 1.
if (pos >= size or: [ (str at: pos) ~~ $:]) { ^Error.Code.EINVAL }.
@ -131,7 +131,7 @@ class(#byte(16)) IP6Address(IP4Address)
pos := pos + 1.
v1 := ch digitValue.
if (v1 >= 0 and: [v1 <= 15])
if ((v1 >= 0) and (v1 <= 15))
{
val := (val bitShift: 4) bitOr: v1.
if (val > 16rFFFF) { ^Error.Code.EINVAL }.
@ -168,7 +168,7 @@ class(#byte(16)) IP6Address(IP4Address)
continue.
}.
if (ch == $. and: [tgpos + 4 <= mysize])
if ((ch == $.) and (tgpos + 4 <= mysize))
{
##if ((super __fromString: (str copyFrom: curseg) offset:0 offset: tgpos) isError) { ^Error.Code.EINVAL }.
if ((super __fromString: str offset: curseg offset: tgpos) isError) { ^Error.Code.EINVAL }.

View File

@ -164,7 +164,7 @@ class MyObject(Object)
0 to: c do: [:i |
| ch |
ch := s at: i.
if (ch == $\ or: [ch == $"])
if ((ch == $\) or (ch == $"))
{
f putc($', $\, (s at: i), $').
}