Permalink
Browse files

Inlining support for ifNil:ifNotNil:.

  • Loading branch information...
1 parent 9265ec1 commit bea570285af3966e27dd7e6fcba1d8064c756f3c @briantrice committed Apr 17, 2011
Showing with 19 additions and 0 deletions.
  1. +19 −0 src/mobius/compiler-inlining.slate
@@ -275,6 +275,25 @@ gen@(SSAVM Compiler traits) generate: _@#ifFalse: on: args fromSource: msg resul
finalResult
].
+gen@(SSAVM Compiler traits) generate: _@#ifNil:ifNotNil: on: args fromSource: msg result: finalResult
+[
+ falseLabel ::= gen newLabelIndex.
+ endLabel ::= gen newLabelIndex.
+ finalResult `defaultsTo: gen newRegister.
+ lhsValueReg ::= gen generate: args first result: finalResult. "do not evaluate twice"
+ condReg ::= gen newRegister.
+ gen emit: gen isNilOp
+ withParameters: {condReg. lhsValueReg}
+ fromSource: msg.
+ gen emitBranchIfFalse: condReg to: falseLabel fromSource: msg.
+ gen generateExecutionOf: {args second} fromSource: msg result: finalResult.
+ gen emitJumpToLabel: endLabel fromSource: msg.
+ gen emitLabel &labelIndex: falseLabel.
+ gen generateExecutionOf: {args third} fromSource: msg result: finalResult.
+ gen emitLabel &labelIndex: endLabel.
+ finalResult
+].
+
gen@(SSAVM Compiler traits) generate: _@#ifNil: on: args fromSource: msg result: finalResult
[
endLabel ::= gen newLabelIndex.

0 comments on commit bea5702

Please sign in to comment.