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:
parent
8965720926
commit
e074607a00
@ -332,7 +332,7 @@ class OrderedCollection(SequenceableCollection)
|
|||||||
{
|
{
|
||||||
| i |
|
| i |
|
||||||
i := index + self.firstIndex.
|
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').
|
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.
|
## replace an existing element. it doesn't grow the buffer.
|
||||||
| i |
|
| i |
|
||||||
i := index + self.firstIndex.
|
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').
|
Exception signal: ('index ' & index asString & ' out of range').
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -433,7 +433,7 @@ class OrderedCollection(SequenceableCollection)
|
|||||||
method removeFirst: count
|
method removeFirst: count
|
||||||
{
|
{
|
||||||
| r i |
|
| 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.
|
r := Array new: count.
|
||||||
i := 0.
|
i := 0.
|
||||||
while (i < count)
|
while (i < count)
|
||||||
@ -449,7 +449,7 @@ class OrderedCollection(SequenceableCollection)
|
|||||||
method removeLast: count
|
method removeLast: count
|
||||||
{
|
{
|
||||||
| r i li |
|
| 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.
|
r := Array new: count.
|
||||||
i := 0.
|
i := 0.
|
||||||
while (i < count)
|
while (i < count)
|
||||||
@ -468,7 +468,7 @@ class OrderedCollection(SequenceableCollection)
|
|||||||
## remove the element at the given position.
|
## remove the element at the given position.
|
||||||
| obj |
|
| obj |
|
||||||
obj := self at: index. ## the range is checed by the at: method.
|
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
|
^obj
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -580,7 +580,7 @@ class OrderedCollection(SequenceableCollection)
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
cursize := self size.
|
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.
|
start := self.firstIndex - 1.
|
||||||
self.buffer replaceFrom: start to: (start + index - 1) with: self.buffer startingAt: self.firstIndex.
|
self.buffer replaceFrom: start to: (start + index - 1) with: self.buffer startingAt: self.firstIndex.
|
||||||
@ -778,7 +778,7 @@ class Set(Collection)
|
|||||||
{
|
{
|
||||||
| ass |
|
| ass |
|
||||||
ass := self __find: key or_upsert: false with: nil.
|
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
|
method __find_index: key
|
||||||
@ -818,7 +818,7 @@ class Set(Collection)
|
|||||||
z := (ass key hash) rem: bs.
|
z := (ass key hash) rem: bs.
|
||||||
|
|
||||||
(* move an element if necessary *)
|
(* 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).
|
self.bucket at: x put: (self.bucket at: y).
|
||||||
x := y.
|
x := y.
|
||||||
|
@ -51,7 +51,8 @@ TODO: can i convert 'thisProcess primError' to a relevant exception?
|
|||||||
while (exctx notNil)
|
while (exctx notNil)
|
||||||
{
|
{
|
||||||
exblk := exctx findExceptionHandlerFor: (self class).
|
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.
|
self.handlerContext := exctx.
|
||||||
exctx basicAt: actpos put: false.
|
exctx basicAt: actpos put: false.
|
||||||
@ -119,7 +120,7 @@ System logNl: '== END OF BACKTRACE =='.
|
|||||||
## TODO: verify if return:to: causes unnecessary stack growth.
|
## TODO: verify if return:to: causes unnecessary stack growth.
|
||||||
## is this correct???
|
## is this correct???
|
||||||
| ctx |
|
| ctx |
|
||||||
if (self.signalContext notNil and: [self.handlerContext notNil])
|
if ((self.signalContext notNil) and (self.handlerContext notNil))
|
||||||
{
|
{
|
||||||
ctx := self.signalContext sender.
|
ctx := self.signalContext sender.
|
||||||
self.signalContext := nil.
|
self.signalContext := nil.
|
||||||
@ -272,7 +273,7 @@ extend MethodContext
|
|||||||
while (i < size)
|
while (i < size)
|
||||||
{
|
{
|
||||||
exc := self basicAt: i.
|
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).
|
^self basicAt: (i + 1).
|
||||||
}.
|
}.
|
||||||
@ -301,7 +302,7 @@ extend MethodContext
|
|||||||
actpos := (self basicSize) - 1.
|
actpos := (self basicSize) - 1.
|
||||||
|
|
||||||
excblk := self findExceptionHandlerFor: (exception class).
|
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
|
## self is an exception context but doesn't have a matching
|
||||||
## exception handler or the exception context is already
|
## exception handler or the exception context is already
|
||||||
|
@ -7,17 +7,20 @@ class Magnitude(Object)
|
|||||||
|
|
||||||
method between: min and: max
|
method between: min and: max
|
||||||
{
|
{
|
||||||
^self >= min and: [self <= max]
|
^self >= min and self <= max
|
||||||
}
|
}
|
||||||
|
|
||||||
method min: aMagnitude
|
method min: aMagnitude
|
||||||
{
|
{
|
||||||
^self < aMagnitude ifTrue: [self] ifFalse: [aMagnitude]
|
##^self < aMagnitude ifTrue: [self] ifFalse: [aMagnitude]
|
||||||
|
^if (self < aMagnitude) { self } else { aMagnitude }.
|
||||||
}
|
}
|
||||||
|
|
||||||
method max: 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
|
method = ass
|
||||||
{
|
{
|
||||||
^(self.key = ass key) and: [ self.value = ass value ]
|
^(self.key = ass key) and (self.value = ass value)
|
||||||
}
|
}
|
||||||
|
|
||||||
method hash
|
method hash
|
||||||
@ -85,15 +88,15 @@ class(#limited) Character(Magnitude)
|
|||||||
{
|
{
|
||||||
##<primitive: #Character_digitValue>
|
##<primitive: #Character_digitValue>
|
||||||
|
|
||||||
if (self >= $0 and: [self <= $9])
|
if ((self >= $0) and (self <= $9))
|
||||||
{
|
{
|
||||||
^self asInteger - $0 asInteger
|
^self asInteger - $0 asInteger
|
||||||
}
|
}
|
||||||
elsif (self >= $A and: [self <= $Z])
|
elsif ((self >= $A) and (self <= $Z))
|
||||||
{
|
{
|
||||||
^self asInteger - $A asInteger + 10
|
^self asInteger - $A asInteger + 10
|
||||||
}
|
}
|
||||||
elsif (self >= $a and: [self <= $z])
|
elsif ((self >= $a) and (self <= $z))
|
||||||
{
|
{
|
||||||
^self asInteger - $a asInteger + 10
|
^self asInteger - $a asInteger + 10
|
||||||
}.
|
}.
|
||||||
|
@ -395,7 +395,7 @@ class SemaphoreHeap(Object)
|
|||||||
left := self leftChildIndex: cindex.
|
left := self leftChildIndex: cindex.
|
||||||
right := self rightChildIndex: 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.
|
xitem := self.arr at: younger.
|
||||||
if (item youngerThan: xitem) { break }.
|
if (item youngerThan: xitem) { break }.
|
||||||
|
@ -54,13 +54,13 @@ class(#byte(4)) IP4Address(IPAddress)
|
|||||||
c := str at: pos.
|
c := str at: pos.
|
||||||
pos := pos + 1.
|
pos := pos + 1.
|
||||||
|
|
||||||
if (c >= $0 and: [c <= $9])
|
if ((c >= $0) and (c <= $9))
|
||||||
{
|
{
|
||||||
acc := acc * 10 + (c asInteger - $0 asInteger).
|
acc := acc * 10 + (c asInteger - $0 asInteger).
|
||||||
if (acc > 255) { Exception signal: ('invalid IPv4 address B ' & str). }.
|
if (acc > 255) { Exception signal: ('invalid IPv4 address B ' & str). }.
|
||||||
digits := digits + 1.
|
digits := digits + 1.
|
||||||
}
|
}
|
||||||
elsif (c = $.)
|
elsif (c == $.)
|
||||||
{
|
{
|
||||||
if (dots >= 3 or: [digits == 0]) { ^Error.Code.EINVAL }.
|
if (dots >= 3 or: [digits == 0]) { ^Error.Code.EINVAL }.
|
||||||
self basicAt: (dots + address_offset) put: acc.
|
self basicAt: (dots + address_offset) put: acc.
|
||||||
@ -113,7 +113,7 @@ class(#byte(16)) IP6Address(IP4Address)
|
|||||||
mysize := self basicSize.
|
mysize := self basicSize.
|
||||||
|
|
||||||
## handle leading :: specially
|
## handle leading :: specially
|
||||||
if (size > 0 and: [(str at: pos) == $:])
|
if ((size > 0) and ((str at: pos) == $:))
|
||||||
{
|
{
|
||||||
pos := pos + 1.
|
pos := pos + 1.
|
||||||
if (pos >= size or: [ (str at: pos) ~~ $:]) { ^Error.Code.EINVAL }.
|
if (pos >= size or: [ (str at: pos) ~~ $:]) { ^Error.Code.EINVAL }.
|
||||||
@ -131,7 +131,7 @@ class(#byte(16)) IP6Address(IP4Address)
|
|||||||
pos := pos + 1.
|
pos := pos + 1.
|
||||||
|
|
||||||
v1 := ch digitValue.
|
v1 := ch digitValue.
|
||||||
if (v1 >= 0 and: [v1 <= 15])
|
if ((v1 >= 0) and (v1 <= 15))
|
||||||
{
|
{
|
||||||
val := (val bitShift: 4) bitOr: v1.
|
val := (val bitShift: 4) bitOr: v1.
|
||||||
if (val > 16rFFFF) { ^Error.Code.EINVAL }.
|
if (val > 16rFFFF) { ^Error.Code.EINVAL }.
|
||||||
@ -168,7 +168,7 @@ class(#byte(16)) IP6Address(IP4Address)
|
|||||||
continue.
|
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 copyFrom: curseg) offset:0 offset: tgpos) isError) { ^Error.Code.EINVAL }.
|
||||||
if ((super __fromString: str offset: curseg offset: tgpos) isError) { ^Error.Code.EINVAL }.
|
if ((super __fromString: str offset: curseg offset: tgpos) isError) { ^Error.Code.EINVAL }.
|
||||||
|
@ -164,7 +164,7 @@ class MyObject(Object)
|
|||||||
0 to: c do: [:i |
|
0 to: c do: [:i |
|
||||||
| ch |
|
| ch |
|
||||||
ch := s at: i.
|
ch := s at: i.
|
||||||
if (ch == $\ or: [ch == $"])
|
if ((ch == $\) or (ch == $"))
|
||||||
{
|
{
|
||||||
f putc($', $\, (s at: i), $').
|
f putc($', $\, (s at: i), $').
|
||||||
}
|
}
|
||||||
|
@ -2250,8 +2250,8 @@ static int emit_single_param_instruction (moo_t* moo, int cmd, moo_oow_t param_1
|
|||||||
|
|
||||||
case BCODE_JUMP_FORWARD_0:
|
case BCODE_JUMP_FORWARD_0:
|
||||||
case BCODE_JUMP_BACKWARD_0:
|
case BCODE_JUMP_BACKWARD_0:
|
||||||
case BCODE_JUMP_BACKWARD_IF_FALSE_0:
|
case BCODE_JUMPOP_BACKWARD_IF_FALSE_0:
|
||||||
case BCODE_JUMP_BACKWARD_IF_TRUE_0:
|
case BCODE_JUMPOP_BACKWARD_IF_TRUE_0:
|
||||||
if (param_1 < 4)
|
if (param_1 < 4)
|
||||||
{
|
{
|
||||||
/* low 2 bits to hold the parameter */
|
/* low 2 bits to hold the parameter */
|
||||||
@ -2271,11 +2271,13 @@ static int emit_single_param_instruction (moo_t* moo, int cmd, moo_oow_t param_1
|
|||||||
}
|
}
|
||||||
|
|
||||||
case BCODE_JUMP_BACKWARD_X:
|
case BCODE_JUMP_BACKWARD_X:
|
||||||
case BCODE_JUMP_BACKWARD_IF_FALSE_X:
|
case BCODE_JUMPOP_BACKWARD_IF_FALSE_X:
|
||||||
case BCODE_JUMP_BACKWARD_IF_TRUE_X:
|
case BCODE_JUMPOP_BACKWARD_IF_TRUE_X:
|
||||||
case BCODE_JUMP_FORWARD_X:
|
case BCODE_JUMP_FORWARD_X:
|
||||||
case BCODE_JUMP_FORWARD_IF_FALSE:
|
|
||||||
case BCODE_JUMP_FORWARD_IF_TRUE:
|
case BCODE_JUMP_FORWARD_IF_TRUE:
|
||||||
|
case BCODE_JUMP_FORWARD_IF_FALSE:
|
||||||
|
case BCODE_JUMPOP_FORWARD_IF_FALSE:
|
||||||
|
case BCODE_JUMPOP_FORWARD_IF_TRUE:
|
||||||
if (param_1 > MAX_CODE_JUMP)
|
if (param_1 > MAX_CODE_JUMP)
|
||||||
{
|
{
|
||||||
cmd = cmd + 1; /* convert to a JUMP2 instruction */
|
cmd = cmd + 1; /* convert to a JUMP2 instruction */
|
||||||
@ -2283,11 +2285,13 @@ static int emit_single_param_instruction (moo_t* moo, int cmd, moo_oow_t param_1
|
|||||||
}
|
}
|
||||||
/* fall thru */
|
/* fall thru */
|
||||||
case BCODE_JUMP2_FORWARD:
|
case BCODE_JUMP2_FORWARD:
|
||||||
case BCODE_JUMP2_BACKWARD:
|
|
||||||
case BCODE_JUMP2_BACKWARD_IF_FALSE:
|
|
||||||
case BCODE_JUMP2_BACKWARD_IF_TRUE:
|
|
||||||
case BCODE_JUMP2_FORWARD_IF_FALSE:
|
|
||||||
case BCODE_JUMP2_FORWARD_IF_TRUE:
|
case BCODE_JUMP2_FORWARD_IF_TRUE:
|
||||||
|
case BCODE_JUMP2_FORWARD_IF_FALSE:
|
||||||
|
case BCODE_JUMP2_BACKWARD:
|
||||||
|
case BCODE_JUMPOP2_BACKWARD_IF_FALSE:
|
||||||
|
case BCODE_JUMPOP2_BACKWARD_IF_TRUE:
|
||||||
|
case BCODE_JUMPOP2_FORWARD_IF_FALSE:
|
||||||
|
case BCODE_JUMPOP2_FORWARD_IF_TRUE:
|
||||||
case BCODE_PUSH_INTLIT:
|
case BCODE_PUSH_INTLIT:
|
||||||
case BCODE_PUSH_NEGINTLIT:
|
case BCODE_PUSH_NEGINTLIT:
|
||||||
case BCODE_PUSH_CHARLIT:
|
case BCODE_PUSH_CHARLIT:
|
||||||
@ -2441,8 +2445,8 @@ static MOO_INLINE int emit_backward_jump_instruction (moo_t* moo, int cmd, moo_o
|
|||||||
moo_oow_t adj;
|
moo_oow_t adj;
|
||||||
|
|
||||||
MOO_ASSERT (moo, cmd == BCODE_JUMP_BACKWARD_0 ||
|
MOO_ASSERT (moo, cmd == BCODE_JUMP_BACKWARD_0 ||
|
||||||
cmd == BCODE_JUMP_BACKWARD_IF_FALSE_0 ||
|
cmd == BCODE_JUMPOP_BACKWARD_IF_FALSE_0 ||
|
||||||
cmd == BCODE_JUMP_BACKWARD_IF_TRUE_0);
|
cmd == BCODE_JUMPOP_BACKWARD_IF_TRUE_0);
|
||||||
|
|
||||||
/* the short BCODE_JUMP_BACKWARD instructions use low 2 bits to encode
|
/* the short BCODE_JUMP_BACKWARD instructions use low 2 bits to encode
|
||||||
* the jump offset. so it can encode 0, 1, 2, 3. the instruction itself
|
* the jump offset. so it can encode 0, 1, 2, 3. the instruction itself
|
||||||
@ -2475,7 +2479,9 @@ static int patch_long_forward_jump_instruction (moo_t* moo, moo_oow_t jip, moo_o
|
|||||||
|
|
||||||
MOO_ASSERT (moo, moo->c->mth.code.ptr[jip] == BCODE_JUMP_FORWARD_X ||
|
MOO_ASSERT (moo, moo->c->mth.code.ptr[jip] == BCODE_JUMP_FORWARD_X ||
|
||||||
moo->c->mth.code.ptr[jip] == BCODE_JUMP_FORWARD_IF_FALSE ||
|
moo->c->mth.code.ptr[jip] == BCODE_JUMP_FORWARD_IF_FALSE ||
|
||||||
moo->c->mth.code.ptr[jip] == BCODE_JUMP_FORWARD_IF_TRUE);
|
moo->c->mth.code.ptr[jip] == BCODE_JUMP_FORWARD_IF_TRUE ||
|
||||||
|
moo->c->mth.code.ptr[jip] == BCODE_JUMPOP_FORWARD_IF_FALSE ||
|
||||||
|
moo->c->mth.code.ptr[jip] == BCODE_JUMPOP_FORWARD_IF_TRUE);
|
||||||
|
|
||||||
if (code_size > MAX_CODE_JUMP)
|
if (code_size > MAX_CODE_JUMP)
|
||||||
{
|
{
|
||||||
@ -5534,23 +5540,16 @@ start_over:
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
if (TOKEN_TYPE(moo) == MOO_IOTOK_AND || TOKEN_TYPE(moo) == MOO_IOTOK_OR)
|
||||||
if (TOKEN_TYPE(moo) == MOO_IOTOK_AND)
|
|
||||||
{
|
{
|
||||||
|
int bcode;
|
||||||
|
bcode = (TOKEN_TYPE(moo) == MOO_IOTOK_AND)? BCODE_JUMP_FORWARD_IF_FALSE: BCODE_JUMP_FORWARD_IF_TRUE;
|
||||||
|
/* TODO: optimization if the expression is a known constant that can be determined to be boolean */
|
||||||
if (add_to_oow_pool(moo, &jumptoend, moo->c->mth.code.len) <= -1 ||
|
if (add_to_oow_pool(moo, &jumptoend, moo->c->mth.code.len) <= -1 ||
|
||||||
emit_single_param_instruction(moo, BCODE_JUMP_FORWARD_IF_FALSE, MAX_CODE_JUMP) <= -1 ||
|
emit_single_param_instruction(moo, bcode, MAX_CODE_JUMP) <= -1) goto oops;
|
||||||
emit_byte_instruction(moo, BCODE_POP_STACKTOP) <= -1) goto oops;
|
|
||||||
GET_TOKEN (moo);
|
GET_TOKEN (moo);
|
||||||
goto start_over;
|
goto start_over;
|
||||||
}
|
}
|
||||||
else if (TOKEN_TYPE(moo) == MOO_IOTOK_OR)
|
|
||||||
{
|
|
||||||
if (add_to_oow_pool(moo, &jumptoend, moo->c->mth.code.len) <= -1 ||
|
|
||||||
emit_single_param_instruction(moo, BCODE_JUMP_FORWARD_IF_TRUE, MAX_CODE_JUMP) <= -1 ||
|
|
||||||
emit_byte_instruction(moo, BCODE_POP_STACKTOP) <= -1) goto oops;
|
|
||||||
GET_TOKEN (moo);
|
|
||||||
goto start_over;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* patch instructions that jumps to the end of if expression */
|
/* patch instructions that jumps to the end of if expression */
|
||||||
for (jumptoend_chunk = jumptoend.head, i = 0; jumptoend_chunk; jumptoend_chunk = jumptoend_chunk->next)
|
for (jumptoend_chunk = jumptoend.head, i = 0; jumptoend_chunk; jumptoend_chunk = jumptoend_chunk->next)
|
||||||
@ -5694,11 +5693,11 @@ static int compile_if_expression (moo_t* moo)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
/* remember position of the jump_forward_if_false instruction to be generated */
|
/* remember position of the jumpop_forward_if_false instruction to be generated */
|
||||||
jumptonext = moo->c->mth.code.len;
|
jumptonext = moo->c->mth.code.len;
|
||||||
/* BCODE_JUMP_FORWARD_IF_FALSE is always a long jump instruction.
|
/* BCODE_JUMPOP_FORWARD_IF_FALSE is always a long jump instruction.
|
||||||
* just specify MAX_CODE_JUMP for consistency with short jump variants */
|
* just specify MAX_CODE_JUMP for consistency with short jump variants */
|
||||||
if (emit_single_param_instruction (moo, BCODE_JUMP_FORWARD_IF_FALSE, MAX_CODE_JUMP) <= -1) goto oops;
|
if (emit_single_param_instruction (moo, BCODE_JUMPOP_FORWARD_IF_FALSE, MAX_CODE_JUMP) <= -1) goto oops;
|
||||||
}
|
}
|
||||||
|
|
||||||
GET_TOKEN (moo); /* get { */
|
GET_TOKEN (moo); /* get { */
|
||||||
@ -5827,9 +5826,9 @@ static int compile_while_expression (moo_t* moo) /* or compile_until_expression
|
|||||||
|
|
||||||
if (cond_style != 1)
|
if (cond_style != 1)
|
||||||
{
|
{
|
||||||
/* BCODE_JUMP_FORWARD_IF_FALSE is always a long jump instruction.
|
/* BCODE_JUMPOP_FORWARD_IF_FALSE is always a long jump instruction.
|
||||||
* just specify MAX_CODE_JUMP for consistency with short jump variants */
|
* just specify MAX_CODE_JUMP for consistency with short jump variants */
|
||||||
if (emit_single_param_instruction (moo, (is_until_loop? BCODE_JUMP_FORWARD_IF_TRUE: BCODE_JUMP_FORWARD_IF_FALSE), MAX_CODE_JUMP) <= -1) goto oops;
|
if (emit_single_param_instruction (moo, (is_until_loop? BCODE_JUMPOP_FORWARD_IF_TRUE: BCODE_JUMPOP_FORWARD_IF_FALSE), MAX_CODE_JUMP) <= -1) goto oops;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* remember information about this while loop. */
|
/* remember information about this while loop. */
|
||||||
@ -5954,7 +5953,7 @@ static int compile_do_while_expression (moo_t* moo)
|
|||||||
|
|
||||||
if (compile_conditional (moo) <= -1) goto oops;
|
if (compile_conditional (moo) <= -1) goto oops;
|
||||||
postcondpos = moo->c->mth.code.len;
|
postcondpos = moo->c->mth.code.len;
|
||||||
jbinst = (is_until_loop? BCODE_JUMP_BACKWARD_IF_FALSE_0: BCODE_JUMP_BACKWARD_IF_TRUE_0);
|
jbinst = (is_until_loop? BCODE_JUMPOP_BACKWARD_IF_FALSE_0: BCODE_JUMPOP_BACKWARD_IF_TRUE_0);
|
||||||
if (precondpos + 1 == postcondpos)
|
if (precondpos + 1 == postcondpos)
|
||||||
{
|
{
|
||||||
/* simple optimization -
|
/* simple optimization -
|
||||||
|
@ -264,41 +264,6 @@ int moo_decode (moo_t* moo, moo_oop_method_t mth, const moo_oocs_t* classfqn)
|
|||||||
LOG_INST_1 (moo, "jump_backward %zu", (moo_oow_t)(bcode & 0x3)); /* low 2 bits */
|
LOG_INST_1 (moo, "jump_backward %zu", (moo_oow_t)(bcode & 0x3)); /* low 2 bits */
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
case BCODE_JUMP_BACKWARD_IF_FALSE_X:
|
|
||||||
FETCH_PARAM_CODE_TO (moo, b1);
|
|
||||||
LOG_INST_1 (moo, "jump_backward_if_false %zu", b1);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case BCODE_JUMP_BACKWARD_IF_FALSE_0:
|
|
||||||
case BCODE_JUMP_BACKWARD_IF_FALSE_1:
|
|
||||||
case BCODE_JUMP_BACKWARD_IF_FALSE_2:
|
|
||||||
case BCODE_JUMP_BACKWARD_IF_FALSE_3:
|
|
||||||
LOG_INST_1 (moo, "jump_backward_if_false %zu", (moo_oow_t)(bcode & 0x3)); /* low 2 bits */
|
|
||||||
break;
|
|
||||||
|
|
||||||
case BCODE_JUMP_BACKWARD_IF_TRUE_X:
|
|
||||||
FETCH_PARAM_CODE_TO (moo, b1);
|
|
||||||
LOG_INST_1 (moo, "jump_backward_if_true %zu", b1);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case BCODE_JUMP_BACKWARD_IF_TRUE_0:
|
|
||||||
case BCODE_JUMP_BACKWARD_IF_TRUE_1:
|
|
||||||
case BCODE_JUMP_BACKWARD_IF_TRUE_2:
|
|
||||||
case BCODE_JUMP_BACKWARD_IF_TRUE_3:
|
|
||||||
LOG_INST_1 (moo, "jump_backward_if_true %zu", (moo_oow_t)(bcode & 0x3)); /* low 2 bits */
|
|
||||||
break;
|
|
||||||
|
|
||||||
case BCODE_JUMP_FORWARD_IF_FALSE:
|
|
||||||
FETCH_PARAM_CODE_TO (moo, b1);
|
|
||||||
LOG_INST_1 (moo, "jump_forward_if_false %zu", b1);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case BCODE_JUMP_FORWARD_IF_TRUE:
|
|
||||||
FETCH_PARAM_CODE_TO (moo, b1);
|
|
||||||
LOG_INST_1 (moo, "jump_forward_if_true %zu", b1);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case BCODE_JUMP2_FORWARD:
|
case BCODE_JUMP2_FORWARD:
|
||||||
FETCH_PARAM_CODE_TO (moo, b1);
|
FETCH_PARAM_CODE_TO (moo, b1);
|
||||||
LOG_INST_1 (moo, "jump2_forward %zu", b1);
|
LOG_INST_1 (moo, "jump2_forward %zu", b1);
|
||||||
@ -309,19 +274,73 @@ int moo_decode (moo_t* moo, moo_oop_method_t mth, const moo_oocs_t* classfqn)
|
|||||||
LOG_INST_1 (moo, "jump2_backward %zu", b1);
|
LOG_INST_1 (moo, "jump2_backward %zu", b1);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case BCODE_JUMP_FORWARD_IF_TRUE:
|
||||||
|
FETCH_PARAM_CODE_TO (moo, b1);
|
||||||
|
LOG_INST_1 (moo, "jump_forward_if_true %zu", b1);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case BCODE_JUMP_FORWARD_IF_FALSE:
|
||||||
|
FETCH_PARAM_CODE_TO (moo, b1);
|
||||||
|
LOG_INST_1 (moo, "jump_forward_if_false %zu", b1);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case BCODE_JUMP2_FORWARD_IF_TRUE:
|
||||||
|
FETCH_PARAM_CODE_TO (moo, b1);
|
||||||
|
LOG_INST_1 (moo, "jump2_forward_if_true %zu", b1);
|
||||||
|
break;
|
||||||
|
|
||||||
case BCODE_JUMP2_FORWARD_IF_FALSE:
|
case BCODE_JUMP2_FORWARD_IF_FALSE:
|
||||||
FETCH_PARAM_CODE_TO (moo, b1);
|
FETCH_PARAM_CODE_TO (moo, b1);
|
||||||
LOG_INST_1 (moo, "jump2_forward_if_false %zu", b1);
|
LOG_INST_1 (moo, "jump2_forward_if_false %zu", b1);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BCODE_JUMP2_BACKWARD_IF_FALSE:
|
case BCODE_JUMPOP_BACKWARD_IF_FALSE_X:
|
||||||
FETCH_PARAM_CODE_TO (moo, b1);
|
FETCH_PARAM_CODE_TO (moo, b1);
|
||||||
LOG_INST_1 (moo, "jump2_backward_if_false %zu", b1);
|
LOG_INST_1 (moo, "jumpop_backward_if_false %zu", b1);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case BCODE_JUMP2_BACKWARD_IF_TRUE:
|
case BCODE_JUMPOP_BACKWARD_IF_FALSE_0:
|
||||||
|
case BCODE_JUMPOP_BACKWARD_IF_FALSE_1:
|
||||||
|
case BCODE_JUMPOP_BACKWARD_IF_FALSE_2:
|
||||||
|
case BCODE_JUMPOP_BACKWARD_IF_FALSE_3:
|
||||||
|
LOG_INST_1 (moo, "jumpop_backward_if_false %zu", (moo_oow_t)(bcode & 0x3)); /* low 2 bits */
|
||||||
|
break;
|
||||||
|
|
||||||
|
case BCODE_JUMPOP_BACKWARD_IF_TRUE_X:
|
||||||
FETCH_PARAM_CODE_TO (moo, b1);
|
FETCH_PARAM_CODE_TO (moo, b1);
|
||||||
LOG_INST_1 (moo, "jump2_backward_if_true %zu", b1);
|
LOG_INST_1 (moo, "jumpop_backward_if_true %zu", b1);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case BCODE_JUMPOP_BACKWARD_IF_TRUE_0:
|
||||||
|
case BCODE_JUMPOP_BACKWARD_IF_TRUE_1:
|
||||||
|
case BCODE_JUMPOP_BACKWARD_IF_TRUE_2:
|
||||||
|
case BCODE_JUMPOP_BACKWARD_IF_TRUE_3:
|
||||||
|
LOG_INST_1 (moo, "jumpop_backward_if_true %zu", (moo_oow_t)(bcode & 0x3)); /* low 2 bits */
|
||||||
|
break;
|
||||||
|
|
||||||
|
case BCODE_JUMPOP_FORWARD_IF_FALSE:
|
||||||
|
FETCH_PARAM_CODE_TO (moo, b1);
|
||||||
|
LOG_INST_1 (moo, "jumpop_forward_if_false %zu", b1);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case BCODE_JUMPOP_FORWARD_IF_TRUE:
|
||||||
|
FETCH_PARAM_CODE_TO (moo, b1);
|
||||||
|
LOG_INST_1 (moo, "jumpop_forward_if_true %zu", b1);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case BCODE_JUMPOP2_FORWARD_IF_FALSE:
|
||||||
|
FETCH_PARAM_CODE_TO (moo, b1);
|
||||||
|
LOG_INST_1 (moo, "jumpop2_forward_if_false %zu", b1);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case BCODE_JUMPOP2_BACKWARD_IF_FALSE:
|
||||||
|
FETCH_PARAM_CODE_TO (moo, b1);
|
||||||
|
LOG_INST_1 (moo, "jumpop2_backward_if_false %zu", b1);
|
||||||
|
break;
|
||||||
|
|
||||||
|
case BCODE_JUMPOP2_BACKWARD_IF_TRUE:
|
||||||
|
FETCH_PARAM_CODE_TO (moo, b1);
|
||||||
|
LOG_INST_1 (moo, "jumpop2_backward_if_true %zu", b1);
|
||||||
break;
|
break;
|
||||||
/* -------------------------------------------------------- */
|
/* -------------------------------------------------------- */
|
||||||
|
|
||||||
|
139
moo/lib/exec.c
139
moo/lib/exec.c
@ -4939,55 +4939,6 @@ static int __execute (moo_t* moo)
|
|||||||
moo->ip -= (bcode & 0x3); /* low 2 bits */
|
moo->ip -= (bcode & 0x3); /* low 2 bits */
|
||||||
NEXT_INST();
|
NEXT_INST();
|
||||||
|
|
||||||
ON_INST(BCODE_JUMP_BACKWARD_IF_FALSE_X)
|
|
||||||
FETCH_PARAM_CODE_TO (moo, b1);
|
|
||||||
LOG_INST1 (moo, "jump_backward_if_false %zu", b1);
|
|
||||||
if (MOO_STACK_GETTOP(moo) == moo->_false) moo->ip -= b1;
|
|
||||||
MOO_STACK_POP (moo);
|
|
||||||
NEXT_INST();
|
|
||||||
|
|
||||||
ON_INST(BCODE_JUMP_BACKWARD_IF_FALSE_0)
|
|
||||||
ON_INST(BCODE_JUMP_BACKWARD_IF_FALSE_1)
|
|
||||||
ON_INST(BCODE_JUMP_BACKWARD_IF_FALSE_2)
|
|
||||||
ON_INST(BCODE_JUMP_BACKWARD_IF_FALSE_3)
|
|
||||||
LOG_INST1 (moo, "jump_backward_if_false %zu", (moo_oow_t)(bcode & 0x3));
|
|
||||||
if (MOO_STACK_GETTOP(moo) == moo->_false) moo->ip -= (bcode & 0x3); /* low 2 bits */
|
|
||||||
MOO_STACK_POP (moo);
|
|
||||||
NEXT_INST();
|
|
||||||
|
|
||||||
ON_INST(BCODE_JUMP_BACKWARD_IF_TRUE_X)
|
|
||||||
FETCH_PARAM_CODE_TO (moo, b1);
|
|
||||||
LOG_INST1 (moo, "jump_backward_if_true %zu", b1);
|
|
||||||
/*if (MOO_STACK_GETTOP(moo) == moo->_true) moo->ip -= b1;*/
|
|
||||||
if (MOO_STACK_GETTOP(moo) != moo->_false) moo->ip -= b1;
|
|
||||||
MOO_STACK_POP (moo);
|
|
||||||
NEXT_INST();
|
|
||||||
|
|
||||||
ON_INST(BCODE_JUMP_BACKWARD_IF_TRUE_0)
|
|
||||||
ON_INST(BCODE_JUMP_BACKWARD_IF_TRUE_1)
|
|
||||||
ON_INST(BCODE_JUMP_BACKWARD_IF_TRUE_2)
|
|
||||||
ON_INST(BCODE_JUMP_BACKWARD_IF_TRUE_3)
|
|
||||||
LOG_INST1 (moo, "jump_backward_if_true %zu", (moo_oow_t)(bcode & 0x3));
|
|
||||||
/*if (MOO_STACK_GETTOP(moo) == moo->_true) moo->ip -= (bcode & 0x3);*/ /* low 2 bits */
|
|
||||||
if (MOO_STACK_GETTOP(moo) != moo->_false) moo->ip -= (bcode & 0x3);
|
|
||||||
MOO_STACK_POP (moo);
|
|
||||||
NEXT_INST();
|
|
||||||
|
|
||||||
ON_INST(BCODE_JUMP_FORWARD_IF_FALSE)
|
|
||||||
FETCH_PARAM_CODE_TO (moo, b1);
|
|
||||||
LOG_INST1 (moo, "jump_forward_if_false %zu", b1);
|
|
||||||
if (MOO_STACK_GETTOP(moo) == moo->_false) moo->ip += b1;
|
|
||||||
MOO_STACK_POP (moo);
|
|
||||||
NEXT_INST();
|
|
||||||
|
|
||||||
ON_INST(BCODE_JUMP_FORWARD_IF_TRUE)
|
|
||||||
FETCH_PARAM_CODE_TO (moo, b1);
|
|
||||||
LOG_INST1 (moo, "jump_forward_if_true %zu", b1);
|
|
||||||
/*if (MOO_STACK_GETTOP(moo) == moo->_true) moo->ip += b1;*/
|
|
||||||
if (MOO_STACK_GETTOP(moo) != moo->_false) moo->ip += b1;
|
|
||||||
MOO_STACK_POP (moo);
|
|
||||||
NEXT_INST();
|
|
||||||
|
|
||||||
ON_INST(BCODE_JUMP2_FORWARD)
|
ON_INST(BCODE_JUMP2_FORWARD)
|
||||||
FETCH_PARAM_CODE_TO (moo, b1);
|
FETCH_PARAM_CODE_TO (moo, b1);
|
||||||
LOG_INST1 (moo, "jump2_forward %zu", b1);
|
LOG_INST1 (moo, "jump2_forward %zu", b1);
|
||||||
@ -5000,31 +4951,103 @@ static int __execute (moo_t* moo)
|
|||||||
moo->ip -= MAX_CODE_JUMP + b1;
|
moo->ip -= MAX_CODE_JUMP + b1;
|
||||||
NEXT_INST();
|
NEXT_INST();
|
||||||
|
|
||||||
ON_INST(BCODE_JUMP2_FORWARD_IF_FALSE)
|
ON_INST(BCODE_JUMP_FORWARD_IF_TRUE)
|
||||||
FETCH_PARAM_CODE_TO (moo, b1);
|
FETCH_PARAM_CODE_TO (moo, b1);
|
||||||
LOG_INST1 (moo, "jump2_forward_if_false %zu", b1);
|
LOG_INST1 (moo, "jump_forward_if_true %zu", b1);
|
||||||
if (MOO_STACK_GETTOP(moo) == moo->_false) moo->ip += MAX_CODE_JUMP + b1;
|
if (MOO_STACK_GETTOP(moo) != moo->_false) moo->ip += b1;
|
||||||
MOO_STACK_POP (moo);
|
NEXT_INST();
|
||||||
|
|
||||||
|
ON_INST(BCODE_JUMP_FORWARD_IF_FALSE)
|
||||||
|
FETCH_PARAM_CODE_TO (moo, b1);
|
||||||
|
LOG_INST1 (moo, "jump_forward_if_false %zu", b1);
|
||||||
|
if (MOO_STACK_GETTOP(moo) == moo->_false) moo->ip += b1;
|
||||||
NEXT_INST();
|
NEXT_INST();
|
||||||
|
|
||||||
ON_INST(BCODE_JUMP2_FORWARD_IF_TRUE)
|
ON_INST(BCODE_JUMP2_FORWARD_IF_TRUE)
|
||||||
FETCH_PARAM_CODE_TO (moo, b1);
|
FETCH_PARAM_CODE_TO (moo, b1);
|
||||||
LOG_INST1 (moo, "jump2_forward_if_true %zu", b1);
|
LOG_INST1 (moo, "jump2_forward_if_true %zu", b1);
|
||||||
/*if (MOO_STACK_GETTOP(moo) == moo->_true) moo->ip += MAX_CODE_JUMP + b1;*/
|
if (MOO_STACK_GETTOP(moo) != moo->_false) moo->ip += MAX_CODE_JUMP + b1;
|
||||||
|
NEXT_INST();
|
||||||
|
|
||||||
|
ON_INST(BCODE_JUMP2_FORWARD_IF_FALSE)
|
||||||
|
FETCH_PARAM_CODE_TO (moo, b1);
|
||||||
|
LOG_INST1 (moo, "jump2_forward_if_false %zu", b1);
|
||||||
|
if (MOO_STACK_GETTOP(moo) == moo->_false) moo->ip += MAX_CODE_JUMP + b1;
|
||||||
|
NEXT_INST();
|
||||||
|
|
||||||
|
|
||||||
|
ON_INST(BCODE_JUMPOP_BACKWARD_IF_FALSE_X)
|
||||||
|
FETCH_PARAM_CODE_TO (moo, b1);
|
||||||
|
LOG_INST1 (moo, "jumpop_backward_if_false %zu", b1);
|
||||||
|
if (MOO_STACK_GETTOP(moo) == moo->_false) moo->ip -= b1;
|
||||||
|
MOO_STACK_POP (moo);
|
||||||
|
NEXT_INST();
|
||||||
|
|
||||||
|
ON_INST(BCODE_JUMPOP_BACKWARD_IF_FALSE_0)
|
||||||
|
ON_INST(BCODE_JUMPOP_BACKWARD_IF_FALSE_1)
|
||||||
|
ON_INST(BCODE_JUMPOP_BACKWARD_IF_FALSE_2)
|
||||||
|
ON_INST(BCODE_JUMPOP_BACKWARD_IF_FALSE_3)
|
||||||
|
LOG_INST1 (moo, "jumpop_backward_if_false %zu", (moo_oow_t)(bcode & 0x3));
|
||||||
|
if (MOO_STACK_GETTOP(moo) == moo->_false) moo->ip -= (bcode & 0x3); /* low 2 bits */
|
||||||
|
MOO_STACK_POP (moo);
|
||||||
|
NEXT_INST();
|
||||||
|
|
||||||
|
ON_INST(BCODE_JUMPOP_BACKWARD_IF_TRUE_X)
|
||||||
|
FETCH_PARAM_CODE_TO (moo, b1);
|
||||||
|
LOG_INST1 (moo, "jumpop_backward_if_true %zu", b1);
|
||||||
|
/*if (MOO_STACK_GETTOP(moo) == moo->_true) moo->ip -= b1;*/
|
||||||
|
if (MOO_STACK_GETTOP(moo) != moo->_false) moo->ip -= b1;
|
||||||
|
MOO_STACK_POP (moo);
|
||||||
|
NEXT_INST();
|
||||||
|
|
||||||
|
ON_INST(BCODE_JUMPOP_BACKWARD_IF_TRUE_0)
|
||||||
|
ON_INST(BCODE_JUMPOP_BACKWARD_IF_TRUE_1)
|
||||||
|
ON_INST(BCODE_JUMPOP_BACKWARD_IF_TRUE_2)
|
||||||
|
ON_INST(BCODE_JUMPOP_BACKWARD_IF_TRUE_3)
|
||||||
|
LOG_INST1 (moo, "jumpop_backward_if_true %zu", (moo_oow_t)(bcode & 0x3));
|
||||||
|
/*if (MOO_STACK_GETTOP(moo) == moo->_true) moo->ip -= (bcode & 0x3);*/ /* low 2 bits */
|
||||||
|
if (MOO_STACK_GETTOP(moo) != moo->_false) moo->ip -= (bcode & 0x3);
|
||||||
|
MOO_STACK_POP (moo);
|
||||||
|
NEXT_INST();
|
||||||
|
|
||||||
|
ON_INST(BCODE_JUMPOP_FORWARD_IF_FALSE)
|
||||||
|
FETCH_PARAM_CODE_TO (moo, b1);
|
||||||
|
LOG_INST1 (moo, "jumpop_forward_if_false %zu", b1);
|
||||||
|
if (MOO_STACK_GETTOP(moo) == moo->_false) moo->ip += b1;
|
||||||
|
MOO_STACK_POP (moo);
|
||||||
|
NEXT_INST();
|
||||||
|
|
||||||
|
ON_INST(BCODE_JUMPOP_FORWARD_IF_TRUE)
|
||||||
|
FETCH_PARAM_CODE_TO (moo, b1);
|
||||||
|
LOG_INST1 (moo, "jumpop_forward_if_true %zu", b1);
|
||||||
|
if (MOO_STACK_GETTOP(moo) != moo->_false) moo->ip += b1;
|
||||||
|
MOO_STACK_POP (moo);
|
||||||
|
NEXT_INST();
|
||||||
|
|
||||||
|
ON_INST(BCODE_JUMPOP2_FORWARD_IF_FALSE)
|
||||||
|
FETCH_PARAM_CODE_TO (moo, b1);
|
||||||
|
LOG_INST1 (moo, "jumpop2_forward_if_false %zu", b1);
|
||||||
|
if (MOO_STACK_GETTOP(moo) == moo->_false) moo->ip += MAX_CODE_JUMP + b1;
|
||||||
|
MOO_STACK_POP (moo);
|
||||||
|
NEXT_INST();
|
||||||
|
|
||||||
|
ON_INST(BCODE_JUMPOP2_FORWARD_IF_TRUE)
|
||||||
|
FETCH_PARAM_CODE_TO (moo, b1);
|
||||||
|
LOG_INST1 (moo, "jumpop2_forward_if_true %zu", b1);
|
||||||
if (MOO_STACK_GETTOP(moo) != moo->_false) moo->ip += MAX_CODE_JUMP + b1;
|
if (MOO_STACK_GETTOP(moo) != moo->_false) moo->ip += MAX_CODE_JUMP + b1;
|
||||||
MOO_STACK_POP (moo);
|
MOO_STACK_POP (moo);
|
||||||
NEXT_INST();
|
NEXT_INST();
|
||||||
|
|
||||||
ON_INST(BCODE_JUMP2_BACKWARD_IF_FALSE)
|
ON_INST(BCODE_JUMPOP2_BACKWARD_IF_FALSE)
|
||||||
FETCH_PARAM_CODE_TO (moo, b1);
|
FETCH_PARAM_CODE_TO (moo, b1);
|
||||||
LOG_INST1 (moo, "jump2_backward_if_false %zu", b1);
|
LOG_INST1 (moo, "jumpop2_backward_if_false %zu", b1);
|
||||||
if (MOO_STACK_GETTOP(moo) == moo->_false) moo->ip -= MAX_CODE_JUMP + b1;
|
if (MOO_STACK_GETTOP(moo) == moo->_false) moo->ip -= MAX_CODE_JUMP + b1;
|
||||||
MOO_STACK_POP (moo);
|
MOO_STACK_POP (moo);
|
||||||
NEXT_INST();
|
NEXT_INST();
|
||||||
|
|
||||||
ON_INST(BCODE_JUMP2_BACKWARD_IF_TRUE)
|
ON_INST(BCODE_JUMPOP2_BACKWARD_IF_TRUE)
|
||||||
FETCH_PARAM_CODE_TO (moo, b1);
|
FETCH_PARAM_CODE_TO (moo, b1);
|
||||||
LOG_INST1 (moo, "jump2_backward_if_true %zu", b1);
|
LOG_INST1 (moo, "jumpop2_backward_if_true %zu", b1);
|
||||||
/* if (MOO_STACK_GETTOP(moo) == moo->_true) moo->ip -= MAX_CODE_JUMP + b1; */
|
/* if (MOO_STACK_GETTOP(moo) == moo->_true) moo->ip -= MAX_CODE_JUMP + b1; */
|
||||||
if (MOO_STACK_GETTOP(moo) != moo->_false) moo->ip -= MAX_CODE_JUMP + b1;
|
if (MOO_STACK_GETTOP(moo) != moo->_false) moo->ip -= MAX_CODE_JUMP + b1;
|
||||||
MOO_STACK_POP (moo);
|
MOO_STACK_POP (moo);
|
||||||
|
@ -76,14 +76,14 @@
|
|||||||
/* 73 */ &&case_BCODE_JUMP_BACKWARD_1,
|
/* 73 */ &&case_BCODE_JUMP_BACKWARD_1,
|
||||||
/* 74 */ &&case_BCODE_JUMP_BACKWARD_2,
|
/* 74 */ &&case_BCODE_JUMP_BACKWARD_2,
|
||||||
/* 75 */ &&case_BCODE_JUMP_BACKWARD_3,
|
/* 75 */ &&case_BCODE_JUMP_BACKWARD_3,
|
||||||
/* 76 */ &&case_BCODE_JUMP_BACKWARD_IF_FALSE_0,
|
/* 76 */ &&case_BCODE_JUMPOP_BACKWARD_IF_FALSE_0,
|
||||||
/* 77 */ &&case_BCODE_JUMP_BACKWARD_IF_FALSE_1,
|
/* 77 */ &&case_BCODE_JUMPOP_BACKWARD_IF_FALSE_1,
|
||||||
/* 78 */ &&case_BCODE_JUMP_BACKWARD_IF_FALSE_2,
|
/* 78 */ &&case_BCODE_JUMPOP_BACKWARD_IF_FALSE_2,
|
||||||
/* 79 */ &&case_BCODE_JUMP_BACKWARD_IF_FALSE_3,
|
/* 79 */ &&case_BCODE_JUMPOP_BACKWARD_IF_FALSE_3,
|
||||||
/* 80 */ &&case_BCODE_JUMP_BACKWARD_IF_TRUE_0,
|
/* 80 */ &&case_BCODE_JUMPOP_BACKWARD_IF_TRUE_0,
|
||||||
/* 81 */ &&case_BCODE_JUMP_BACKWARD_IF_TRUE_1,
|
/* 81 */ &&case_BCODE_JUMPOP_BACKWARD_IF_TRUE_1,
|
||||||
/* 82 */ &&case_BCODE_JUMP_BACKWARD_IF_TRUE_2,
|
/* 82 */ &&case_BCODE_JUMPOP_BACKWARD_IF_TRUE_2,
|
||||||
/* 83 */ &&case_BCODE_JUMP_BACKWARD_IF_TRUE_3,
|
/* 83 */ &&case_BCODE_JUMPOP_BACKWARD_IF_TRUE_3,
|
||||||
/* 84 */ &&case_DEFAULT,
|
/* 84 */ &&case_DEFAULT,
|
||||||
/* 85 */ &&case_DEFAULT,
|
/* 85 */ &&case_DEFAULT,
|
||||||
/* 86 */ &&case_DEFAULT,
|
/* 86 */ &&case_DEFAULT,
|
||||||
@ -198,24 +198,24 @@
|
|||||||
/* 195 */ &&case_DEFAULT,
|
/* 195 */ &&case_DEFAULT,
|
||||||
/* 196 */ &&case_BCODE_JUMP_FORWARD_X,
|
/* 196 */ &&case_BCODE_JUMP_FORWARD_X,
|
||||||
/* 197 */ &&case_BCODE_JUMP2_FORWARD,
|
/* 197 */ &&case_BCODE_JUMP2_FORWARD,
|
||||||
/* 198 */ &&case_DEFAULT,
|
/* 198 */ &&case_BCODE_JUMP_FORWARD_IF_TRUE,
|
||||||
/* 199 */ &&case_DEFAULT,
|
/* 199 */ &&case_BCODE_JUMP2_FORWARD_IF_TRUE,
|
||||||
/* 200 */ &&case_BCODE_JUMP_BACKWARD_X,
|
/* 200 */ &&case_BCODE_JUMP_BACKWARD_X,
|
||||||
/* 201 */ &&case_BCODE_JUMP2_BACKWARD,
|
/* 201 */ &&case_BCODE_JUMP2_BACKWARD,
|
||||||
/* 202 */ &&case_DEFAULT,
|
/* 202 */ &&case_DEFAULT,
|
||||||
/* 203 */ &&case_DEFAULT,
|
/* 203 */ &&case_DEFAULT,
|
||||||
/* 204 */ &&case_BCODE_JUMP_BACKWARD_IF_FALSE_X,
|
/* 204 */ &&case_BCODE_JUMPOP_BACKWARD_IF_FALSE_X,
|
||||||
/* 205 */ &&case_BCODE_JUMP2_BACKWARD_IF_FALSE,
|
/* 205 */ &&case_BCODE_JUMPOP2_BACKWARD_IF_FALSE,
|
||||||
/* 206 */ &&case_DEFAULT,
|
/* 206 */ &&case_DEFAULT,
|
||||||
/* 207 */ &&case_DEFAULT,
|
/* 207 */ &&case_DEFAULT,
|
||||||
/* 208 */ &&case_BCODE_JUMP_BACKWARD_IF_TRUE_X,
|
/* 208 */ &&case_BCODE_JUMPOP_BACKWARD_IF_TRUE_X,
|
||||||
/* 209 */ &&case_BCODE_JUMP2_BACKWARD_IF_TRUE,
|
/* 209 */ &&case_BCODE_JUMPOP2_BACKWARD_IF_TRUE,
|
||||||
/* 210 */ &&case_DEFAULT,
|
/* 210 */ &&case_BCODE_JUMP_FORWARD_IF_FALSE,
|
||||||
/* 211 */ &&case_DEFAULT,
|
/* 211 */ &&case_BCODE_JUMP2_FORWARD_IF_FALSE,
|
||||||
/* 212 */ &&case_BCODE_JUMP_FORWARD_IF_FALSE,
|
/* 212 */ &&case_BCODE_JUMPOP_FORWARD_IF_FALSE,
|
||||||
/* 213 */ &&case_BCODE_JUMP2_FORWARD_IF_FALSE,
|
/* 213 */ &&case_BCODE_JUMPOP2_FORWARD_IF_FALSE,
|
||||||
/* 214 */ &&case_BCODE_JUMP_FORWARD_IF_TRUE,
|
/* 214 */ &&case_BCODE_JUMPOP_FORWARD_IF_TRUE,
|
||||||
/* 215 */ &&case_BCODE_JUMP2_FORWARD_IF_TRUE,
|
/* 215 */ &&case_BCODE_JUMPOP2_FORWARD_IF_TRUE,
|
||||||
/* 216 */ &&case_BCODE_STORE_INTO_CTXTEMPVAR_X,
|
/* 216 */ &&case_BCODE_STORE_INTO_CTXTEMPVAR_X,
|
||||||
/* 217 */ &&case_DEFAULT,
|
/* 217 */ &&case_DEFAULT,
|
||||||
/* 218 */ &&case_DEFAULT,
|
/* 218 */ &&case_DEFAULT,
|
||||||
|
@ -54,13 +54,11 @@
|
|||||||
/*#define MOO_DEBUG_LEXER 1*/
|
/*#define MOO_DEBUG_LEXER 1*/
|
||||||
#define MOO_DEBUG_COMPILER 1
|
#define MOO_DEBUG_COMPILER 1
|
||||||
#define MOO_DEBUG_VM_PROCESSOR 1
|
#define MOO_DEBUG_VM_PROCESSOR 1
|
||||||
#define MOO_DEBUG_VM_EXEC
|
/*#define MOO_DEBUG_VM_EXEC*/
|
||||||
#define MOO_PROFILE_VM 1
|
#define MOO_PROFILE_VM 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* allow the caller to drive process switching by calling
|
/* allow the caller to drive process switching by calling
|
||||||
* moo_switchprocess(). */
|
* moo_switchprocess(). */
|
||||||
#define MOO_EXTERNAL_PROCESS_SWITCH
|
#define MOO_EXTERNAL_PROCESS_SWITCH
|
||||||
@ -714,17 +712,21 @@ SHORT INSTRUCTION CODE LONG INSTRUCTION C
|
|||||||
|
|
||||||
|
|
||||||
68-71 0100 01XX JUMP_FORWARD 196 1100 0100 XXXXXXXX JUMP_FORWARD_X
|
68-71 0100 01XX JUMP_FORWARD 196 1100 0100 XXXXXXXX JUMP_FORWARD_X
|
||||||
197 1000 0101 XXXXXXXX JUMP2_FORWARD
|
197 1100 0101 XXXXXXXX JUMP2_FORWARD
|
||||||
|
198 1100 0110 XXXXXXXX JUMP_FORWARD_IF_TRUE
|
||||||
|
199 1100 0111 XXXXXXXX JUMP2_FORWARD_IF_TRUE
|
||||||
72-75 0100 10XX JUMP_BACKWARD 200 1100 1000 XXXXXXXX JUMP_BACKWARD_X
|
72-75 0100 10XX JUMP_BACKWARD 200 1100 1000 XXXXXXXX JUMP_BACKWARD_X
|
||||||
201 1101 1001 XXXXXXXX JUMP2_BACKWARD
|
201 1101 1001 XXXXXXXX JUMP2_BACKWARD
|
||||||
76-79 0100 11XX JUMP_BACKWARD_IF_FALSE 204 1100 1100 XXXXXXXX JUMP_BACKWARD_IF_FALSE_X
|
76-79 0100 11XX JUMPOP_BACKWARD_IF_FALSE 204 1100 1100 XXXXXXXX JUMPOP_BACKWARD_IF_FALSE_X
|
||||||
205 1101 1101 XXXXXXXX JUMP2_BACKWARD_IF_FALSE
|
205 1101 1101 XXXXXXXX JUMPOP2_BACKWARD_IF_FALSE
|
||||||
80-83 0101 00XX JUMP_BACKWARD_IF_TRUE 208 1101 0000 XXXXXXXX JUMP_BACKWARD_IF_TRUE_X
|
80-83 0101 00XX JUMPOP_BACKWARD_IF_TRUE 208 1101 0000 XXXXXXXX JUMPOP_BACKWARD_IF_TRUE_X
|
||||||
209 1101 0001 XXXXXXXX JUMP2_FORWARD_IF_TRUE
|
209 1101 0001 XXXXXXXX JUMPOP2_FORWARD_IF_TRUE
|
||||||
84-87 0101 01XX UNUSED 212 1101 0100 XXXXXXXX JUMP_FORWARD_IF_FALSE
|
84-87 0101 01XX UNUSED 210 1101 0010 XXXXXXXX JUMP_FORWARD_IF_FALSE
|
||||||
213 1101 0101 XXXXXXXX JUMP2_FORWARD_IF_FALSE
|
211 1101 0011 XXXXXXXX JUMP2_FORWARD_IF_FALSE
|
||||||
214 1101 0110 XXXXXXXX JUMP_FORWARD_IF_TRUE
|
212 1101 0100 XXXXXXXX JUMPOP_FORWARD_IF_FALSE
|
||||||
215 1101 0111 XXXXXXXX JUMP2_FORWARD_IF_TRUE
|
213 1101 0101 XXXXXXXX JUMPOP2_FORWARD_IF_FALSE
|
||||||
|
214 1101 0110 XXXXXXXX JUMPOP_FORWARD_IF_TRUE
|
||||||
|
215 1101 0111 XXXXXXXX JUMPOP2_FORWARD_IF_TRUE
|
||||||
|
|
||||||
vv
|
vv
|
||||||
88-91 0101 10XX YYYYYYYY STORE_INTO_CTXTEMPVAR 216 1101 1000 XXXXXXXX YYYYYYYY STORE_INTO_CTXTEMPVAR_X (bit 3 on, bit 2 off)
|
88-91 0101 10XX YYYYYYYY STORE_INTO_CTXTEMPVAR 216 1101 1000 XXXXXXXX YYYYYYYY STORE_INTO_CTXTEMPVAR_X (bit 3 on, bit 2 off)
|
||||||
@ -850,15 +852,15 @@ enum moo_bcode_t
|
|||||||
BCODE_JUMP_BACKWARD_2 = 0x4A, /* 74 */
|
BCODE_JUMP_BACKWARD_2 = 0x4A, /* 74 */
|
||||||
BCODE_JUMP_BACKWARD_3 = 0x4B, /* 75 */
|
BCODE_JUMP_BACKWARD_3 = 0x4B, /* 75 */
|
||||||
|
|
||||||
BCODE_JUMP_BACKWARD_IF_FALSE_0 = 0x4C, /* 76 */
|
BCODE_JUMPOP_BACKWARD_IF_FALSE_0 = 0x4C, /* 76 */
|
||||||
BCODE_JUMP_BACKWARD_IF_FALSE_1 = 0x4D, /* 77 */
|
BCODE_JUMPOP_BACKWARD_IF_FALSE_1 = 0x4D, /* 77 */
|
||||||
BCODE_JUMP_BACKWARD_IF_FALSE_2 = 0x4E, /* 78 */
|
BCODE_JUMPOP_BACKWARD_IF_FALSE_2 = 0x4E, /* 78 */
|
||||||
BCODE_JUMP_BACKWARD_IF_FALSE_3 = 0x4F, /* 79 */
|
BCODE_JUMPOP_BACKWARD_IF_FALSE_3 = 0x4F, /* 79 */
|
||||||
|
|
||||||
BCODE_JUMP_BACKWARD_IF_TRUE_0 = 0x50, /* 80 */
|
BCODE_JUMPOP_BACKWARD_IF_TRUE_0 = 0x50, /* 80 */
|
||||||
BCODE_JUMP_BACKWARD_IF_TRUE_1 = 0x51, /* 81 */
|
BCODE_JUMPOP_BACKWARD_IF_TRUE_1 = 0x51, /* 81 */
|
||||||
BCODE_JUMP_BACKWARD_IF_TRUE_2 = 0x52, /* 82 */
|
BCODE_JUMPOP_BACKWARD_IF_TRUE_2 = 0x52, /* 82 */
|
||||||
BCODE_JUMP_BACKWARD_IF_TRUE_3 = 0x53, /* 83 */
|
BCODE_JUMPOP_BACKWARD_IF_TRUE_3 = 0x53, /* 83 */
|
||||||
|
|
||||||
/* UNUSED 0x54 - 0x57 */
|
/* UNUSED 0x54 - 0x57 */
|
||||||
|
|
||||||
@ -938,18 +940,22 @@ enum moo_bcode_t
|
|||||||
|
|
||||||
BCODE_JUMP_FORWARD_X = 0xC4, /* 196 ## */
|
BCODE_JUMP_FORWARD_X = 0xC4, /* 196 ## */
|
||||||
BCODE_JUMP2_FORWARD = 0xC5, /* 197 */
|
BCODE_JUMP2_FORWARD = 0xC5, /* 197 */
|
||||||
|
BCODE_JUMP_FORWARD_IF_TRUE = 0xC6, /* 198 ## */
|
||||||
|
BCODE_JUMP2_FORWARD_IF_TRUE = 0xC7, /* 199 */
|
||||||
BCODE_JUMP_BACKWARD_X = 0xC8, /* 200 ## */
|
BCODE_JUMP_BACKWARD_X = 0xC8, /* 200 ## */
|
||||||
BCODE_JUMP2_BACKWARD = 0xC9, /* 201 */
|
BCODE_JUMP2_BACKWARD = 0xC9, /* 201 */
|
||||||
|
|
||||||
BCODE_JUMP_BACKWARD_IF_FALSE_X = 0xCC, /* 204 ## */
|
BCODE_JUMPOP_BACKWARD_IF_FALSE_X = 0xCC, /* 204 ## */
|
||||||
BCODE_JUMP2_BACKWARD_IF_FALSE = 0xCD, /* 205 */
|
BCODE_JUMPOP2_BACKWARD_IF_FALSE = 0xCD, /* 205 */
|
||||||
BCODE_JUMP_BACKWARD_IF_TRUE_X = 0xD0, /* 208 ## */
|
BCODE_JUMPOP_BACKWARD_IF_TRUE_X = 0xD0, /* 208 ## */
|
||||||
BCODE_JUMP2_BACKWARD_IF_TRUE = 0xD1, /* 209 */
|
BCODE_JUMPOP2_BACKWARD_IF_TRUE = 0xD1, /* 209 */
|
||||||
|
|
||||||
BCODE_JUMP_FORWARD_IF_FALSE = 0xD4, /* 212 ## */
|
BCODE_JUMP_FORWARD_IF_FALSE = 0xD2, /* 210 ## */
|
||||||
BCODE_JUMP2_FORWARD_IF_FALSE = 0xD5, /* 213 */
|
BCODE_JUMP2_FORWARD_IF_FALSE = 0xD3, /* 211 */
|
||||||
BCODE_JUMP_FORWARD_IF_TRUE = 0xD6, /* 214 ## */
|
BCODE_JUMPOP_FORWARD_IF_FALSE = 0xD4, /* 212 ## */
|
||||||
BCODE_JUMP2_FORWARD_IF_TRUE = 0xD7, /* 215 */
|
BCODE_JUMPOP2_FORWARD_IF_FALSE = 0xD5, /* 213 */
|
||||||
|
BCODE_JUMPOP_FORWARD_IF_TRUE = 0xD6, /* 214 ## */
|
||||||
|
BCODE_JUMPOP2_FORWARD_IF_TRUE = 0xD7, /* 215 */
|
||||||
|
|
||||||
BCODE_STORE_INTO_CTXTEMPVAR_X = 0xD8, /* 216 ## */
|
BCODE_STORE_INTO_CTXTEMPVAR_X = 0xD8, /* 216 ## */
|
||||||
BCODE_POP_INTO_CTXTEMPVAR_X = 0xDC, /* 220 ## */
|
BCODE_POP_INTO_CTXTEMPVAR_X = 0xDC, /* 220 ## */
|
||||||
|
Loading…
x
Reference in New Issue
Block a user