@@ -107,6 +107,35 @@ export function passForStatement(parent: ts.ForStatement, ctx: Context, builder:
107107 builder . setInsertionPoint ( next ) ;
108108}
109109
110+ export function passDoStatement ( parent : ts . DoStatement , ctx : Context , builder : llvm . IRBuilder ) {
111+ const conditionBlock = llvm . BasicBlock . create ( ctx . llvmContext , "for.condition" ) ;
112+ ctx . scope . currentFunction . addBasicBlock ( conditionBlock ) ;
113+
114+ const positiveBlock = llvm . BasicBlock . create ( ctx . llvmContext , "for.true" ) ;
115+ ctx . scope . currentFunction . addBasicBlock ( positiveBlock ) ;
116+
117+ const next = llvm . BasicBlock . create ( ctx . llvmContext , "for.end" ) ;
118+ ctx . scope . currentFunction . addBasicBlock ( next ) ;
119+
120+ builder . createBr ( positiveBlock ) ;
121+ builder . setInsertionPoint ( positiveBlock ) ;
122+
123+ passStatement ( < any > parent . statement , ctx , builder ) ;
124+
125+ builder . createBr ( conditionBlock ) ;
126+ builder . setInsertionPoint ( conditionBlock ) ;
127+
128+ emitCondition (
129+ parent . expression ,
130+ ctx ,
131+ builder ,
132+ positiveBlock ,
133+ next
134+ ) ;
135+
136+ builder . setInsertionPoint ( next ) ;
137+ }
138+
110139export function emitCondition (
111140 condition : ts . Expression ,
112141 ctx : Context ,
@@ -527,6 +556,9 @@ export function passStatement(stmt: ts.Statement, ctx: Context, builder: llvm.IR
527556 case ts . SyntaxKind . ForStatement :
528557 passForStatement ( < any > stmt , ctx , builder ) ;
529558 break ;
559+ case ts . SyntaxKind . DoStatement :
560+ passDoStatement ( < any > stmt , ctx , builder ) ;
561+ break ;
530562 case ts . SyntaxKind . BinaryExpression :
531563 buildFromBinaryExpression ( < any > stmt , ctx , builder ) ;
532564 break ;
0 commit comments