@@ -283,51 +283,16 @@ class KotlinFileExtractor(val tw: TrapWriter) {
283283
284284 fun extractStatement (s : IrStatement , callable : Label <out DbCallable >, parent : Label <out DbStmtparent >, idx : Int ) {
285285 when (s) {
286- is IrReturn -> {
287- val id = tw.getFreshIdLabel<DbReturnstmt >()
288- val locId = tw.getLocation(s.startOffset, s.endOffset)
289- tw.writeStmts_returnstmt(id, parent, idx, callable)
290- tw.writeHasLocation(id, locId)
291- extractExpression(s.value, id, 0 )
292- } is IrWhileLoop -> {
293- val id = tw.getFreshIdLabel<DbWhilestmt >()
294- val locId = tw.getLocation(s.startOffset, s.endOffset)
295- tw.writeStmts_whilestmt(id, parent, idx, callable)
296- tw.writeHasLocation(id, locId)
297- extractExpression(s.condition, id, 0 )
298- val body = s.body
299- if (body != null ) {
300- extractExpression(body, id, 1 ) // TODO: The QLLs think this is a Stmt
301- }
302- } is IrWhen -> {
303- val x: IrWhen = s
304- if (s.origin == IF ) {
305- var branchParent = parent
306- var branchIdx = idx
307- for (b in x.branches) {
308- if (b is IrElseBranch ) {
309- // TODO
310- } else {
311- val id = tw.getFreshIdLabel<DbIfstmt >()
312- val locId = tw.getLocation(b.startOffset, b.endOffset)
313- tw.writeStmts_ifstmt(id, branchParent, branchIdx, callable)
314- tw.writeHasLocation(id, locId)
315- extractExpression(b.condition, id, 0 )
316- extractExpression(b.result, id, 1 ) // TODO: The QLLs think this is a Stmt
317- branchParent = id
318- branchIdx = 2
319- }
320- }
321- } else {
322- extractorBug(" Unrecognised IrWhen: " + s.javaClass)
323- }
324- } else -> {
286+ is IrExpression -> {
287+ extractExpression(s, callable, parent, idx)
288+ }
289+ else -> {
325290 extractorBug(" Unrecognised IrStatement: " + s.javaClass)
326291 }
327292 }
328293 }
329294
330- fun extractExpression (e : IrExpression , parent : Label <out DbExprparent >, idx : Int ) {
295+ fun extractExpression (e : IrExpression , callable : Label < out DbCallable >, parent : Label <out DbExprparent >, idx : Int ) {
331296 when (e) {
332297 is IrCall -> {
333298 val sig: IdSignature .PublicSignature ? = e.symbol.signature?.asPublic()
@@ -345,8 +310,8 @@ class KotlinFileExtractor(val tw: TrapWriter) {
345310 val locId = tw.getLocation(e.startOffset, e.endOffset)
346311 tw.writeExprs_addexpr(id, typeId, parent, idx)
347312 tw.writeHasLocation(id, locId)
348- extractExpression(left, id, 0 )
349- extractExpression(right, id, 1 )
313+ extractExpression(left, callable, id, 0 )
314+ extractExpression(right, callable, id, 1 )
350315 } else {
351316 extractorBug(" Unrecognised IrCall: left or right is null" )
352317 }
@@ -367,6 +332,44 @@ class KotlinFileExtractor(val tw: TrapWriter) {
367332 tw.writeHasLocation(id, locId)
368333 tw.writeNamestrings(v.toString(), v.toString(), id)
369334 }
335+ is IrReturn -> {
336+ val id = tw.getFreshIdLabel<DbReturnstmt >()
337+ val locId = tw.getLocation(e.startOffset, e.endOffset)
338+ tw.writeStmts_returnstmt(id, parent, idx, callable)
339+ tw.writeHasLocation(id, locId)
340+ extractExpression(e.value, callable, id, 0 )
341+ } is IrWhileLoop -> {
342+ val id = tw.getFreshIdLabel<DbWhilestmt >()
343+ val locId = tw.getLocation(e.startOffset, e.endOffset)
344+ tw.writeStmts_whilestmt(id, parent, idx, callable)
345+ tw.writeHasLocation(id, locId)
346+ extractExpression(e.condition, callable, id, 0 )
347+ val body = e.body
348+ if (body != null ) {
349+ extractExpression(body, callable, id, 1 ) // TODO: The QLLs think this is a Stmt
350+ }
351+ } is IrWhen -> {
352+ if (e.origin == IF ) {
353+ var branchParent = parent
354+ var branchIdx = idx
355+ for (b in e.branches) {
356+ if (b is IrElseBranch ) {
357+ // TODO
358+ } else {
359+ val id = tw.getFreshIdLabel<DbIfstmt >()
360+ val locId = tw.getLocation(b.startOffset, b.endOffset)
361+ tw.writeStmts_ifstmt(id, branchParent, branchIdx, callable)
362+ tw.writeHasLocation(id, locId)
363+ extractExpression(b.condition, callable, id, 0 )
364+ extractExpression(b.result, callable, id, 1 ) // TODO: The QLLs think this is a Stmt
365+ branchParent = id
366+ branchIdx = 2
367+ }
368+ }
369+ } else {
370+ extractorBug(" Unrecognised IrWhen: " + e.javaClass)
371+ }
372+ }
370373 else -> {
371374 extractorBug(" Unrecognised IrExpression: " + e.javaClass)
372375 }
0 commit comments