diff options
author | Juerg Billeter <j@bitron.ch> | 2007-09-04 20:17:31 +0000 |
---|---|---|
committer | Jürg Billeter <juergbi@src.gnome.org> | 2007-09-04 20:17:31 +0000 |
commit | c7229010b2a88d3cf5e1f1f07e815635489bc788 (patch) | |
tree | 8479ea35d1d865beb2a754d056d051c2faa4adfc /ccode | |
parent | ffc76767c23915c789c6c0bf547c477ad85d39ae (diff) | |
download | vala-c7229010b2a88d3cf5e1f1f07e815635489bc788.tar.gz |
emit line directives in debug mode
2007-09-04 Juerg Billeter <j@bitron.ch>
* vala/valacodenode.vala, ccode/valaccodebreakstatement.vala,
ccode/valaccodecasestatement.vala, ccode/valaccodecontinuestatement.vala,
ccode/valaccodedeclaration.vala, ccode/valaccodedostatement.vala,
ccode/valaccodeexpressionstatement.vala, ccode/valaccodeforstatement.vala,
ccode/valaccodefunction.vala, ccode/valaccodeifstatement.vala,
ccode/valaccodereturnstatement.vala, ccode/valaccodeswitchstatement.vala,
ccode/valaccodevariabledeclarator.vala,
ccode/valaccodewhilestatement.vala, ccode/valaccodewriter.vala,
gobject/valacodegenerator.vala, gobject/valacodegeneratormethod.vala,
gobject/valacodegeneratorsourcefile.vala: emit line directives in debug
mode
svn path=/trunk/; revision=580
Diffstat (limited to 'ccode')
-rw-r--r-- | ccode/valaccodebreakstatement.vala | 4 | ||||
-rw-r--r-- | ccode/valaccodecasestatement.vala | 4 | ||||
-rw-r--r-- | ccode/valaccodecontinuestatement.vala | 4 | ||||
-rw-r--r-- | ccode/valaccodedeclaration.vala | 2 | ||||
-rw-r--r-- | ccode/valaccodedostatement.vala | 4 | ||||
-rw-r--r-- | ccode/valaccodeexpressionstatement.vala | 4 | ||||
-rw-r--r-- | ccode/valaccodeforstatement.vala | 2 | ||||
-rw-r--r-- | ccode/valaccodefunction.vala | 3 | ||||
-rw-r--r-- | ccode/valaccodeifstatement.vala | 4 | ||||
-rw-r--r-- | ccode/valaccodereturnstatement.vala | 4 | ||||
-rw-r--r-- | ccode/valaccodeswitchstatement.vala | 2 | ||||
-rw-r--r-- | ccode/valaccodevariabledeclarator.vala | 2 | ||||
-rw-r--r-- | ccode/valaccodewhilestatement.vala | 4 | ||||
-rw-r--r-- | ccode/valaccodewriter.vala | 21 |
14 files changed, 34 insertions, 30 deletions
diff --git a/ccode/valaccodebreakstatement.vala b/ccode/valaccodebreakstatement.vala index 3a2f0339e..5685d581a 100644 --- a/ccode/valaccodebreakstatement.vala +++ b/ccode/valaccodebreakstatement.vala @@ -1,6 +1,6 @@ /* valaccodebreakstatement.vala * - * Copyright (C) 2006 Jürg Billeter + * Copyright (C) 2006-2007 Jürg Billeter * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -27,7 +27,7 @@ using GLib; */ public class Vala.CCodeBreakStatement : CCodeStatement { public override void write (CCodeWriter! writer) { - writer.write_indent (); + writer.write_indent (line); writer.write_string ("break;"); writer.write_newline (); } diff --git a/ccode/valaccodecasestatement.vala b/ccode/valaccodecasestatement.vala index a75efa9d2..111336d90 100644 --- a/ccode/valaccodecasestatement.vala +++ b/ccode/valaccodecasestatement.vala @@ -1,6 +1,6 @@ /* valaccodecasestatement.vala * - * Copyright (C) 2006 Jürg Billeter + * Copyright (C) 2006-2007 Jürg Billeter * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -47,7 +47,7 @@ public class Vala.CCodeCaseStatement : CCodeStatement { } public override void write (CCodeWriter! writer) { - writer.write_indent (); + writer.write_indent (line); writer.write_string ("case "); expression.write (writer); writer.write_string (":"); diff --git a/ccode/valaccodecontinuestatement.vala b/ccode/valaccodecontinuestatement.vala index 02c65d961..482f42489 100644 --- a/ccode/valaccodecontinuestatement.vala +++ b/ccode/valaccodecontinuestatement.vala @@ -1,6 +1,6 @@ /* valaccodecontinuestatement.vala * - * Copyright (C) 2006 Jürg Billeter + * Copyright (C) 2006-2007 Jürg Billeter * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -27,7 +27,7 @@ using GLib; */ public class Vala.CCodeContinueStatement : CCodeStatement { public override void write (CCodeWriter! writer) { - writer.write_indent (); + writer.write_indent (line); writer.write_string ("continue;"); writer.write_newline (); } diff --git a/ccode/valaccodedeclaration.vala b/ccode/valaccodedeclaration.vala index 5a70cc335..9416db06d 100644 --- a/ccode/valaccodedeclaration.vala +++ b/ccode/valaccodedeclaration.vala @@ -54,7 +54,7 @@ public class Vala.CCodeDeclaration : CCodeStatement { public override void write (CCodeWriter! writer) { if ((modifiers & (CCodeModifiers.STATIC | CCodeModifiers.EXTERN)) != 0) { // combined declaration and initialization for static and extern variables - writer.write_indent (); + writer.write_indent (line); if ((modifiers & CCodeModifiers.STATIC) != 0) { writer.write_string ("static "); } diff --git a/ccode/valaccodedostatement.vala b/ccode/valaccodedostatement.vala index 4dd2dc18e..8e0fd07db 100644 --- a/ccode/valaccodedostatement.vala +++ b/ccode/valaccodedostatement.vala @@ -1,6 +1,6 @@ /* valaccodedostatement.vala * - * Copyright (C) 2006 Jürg Billeter + * Copyright (C) 2006-2007 Jürg Billeter * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -42,7 +42,7 @@ public class Vala.CCodeDoStatement : CCodeStatement { } public override void write (CCodeWriter! writer) { - writer.write_indent (); + writer.write_indent (line); writer.write_string ("do"); /* while shouldn't be on a separate line */ diff --git a/ccode/valaccodeexpressionstatement.vala b/ccode/valaccodeexpressionstatement.vala index e247a9471..b0c208d9c 100644 --- a/ccode/valaccodeexpressionstatement.vala +++ b/ccode/valaccodeexpressionstatement.vala @@ -1,6 +1,6 @@ /* valaccodeexpressionstatement.vala * - * Copyright (C) 2006 Jürg Billeter + * Copyright (C) 2006-2007 Jürg Billeter * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -36,7 +36,7 @@ public class Vala.CCodeExpressionStatement : CCodeStatement { } public override void write (CCodeWriter! writer) { - writer.write_indent (); + writer.write_indent (line); if (expression != null) { expression.write (writer); } diff --git a/ccode/valaccodeforstatement.vala b/ccode/valaccodeforstatement.vala index 37600927a..2d5b3a605 100644 --- a/ccode/valaccodeforstatement.vala +++ b/ccode/valaccodeforstatement.vala @@ -64,7 +64,7 @@ public class Vala.CCodeForStatement : CCodeStatement { public override void write (CCodeWriter! writer) { bool first; - writer.write_indent (); + writer.write_indent (line); writer.write_string ("for ("); first = true; diff --git a/ccode/valaccodefunction.vala b/ccode/valaccodefunction.vala index 855d6d00d..1ead25486 100644 --- a/ccode/valaccodefunction.vala +++ b/ccode/valaccodefunction.vala @@ -82,7 +82,7 @@ public class Vala.CCodeFunction : CCodeNode { } public override void write (CCodeWriter! writer) { - writer.write_indent (); + writer.write_indent (line); if ((modifiers & CCodeModifiers.STATIC) == CCodeModifiers.STATIC) { writer.write_string ("static "); } @@ -108,7 +108,6 @@ public class Vala.CCodeFunction : CCodeNode { if (block == null) { writer.write_string (";"); } else { - writer.write_newline (); block.write (writer); writer.write_newline (); } diff --git a/ccode/valaccodeifstatement.vala b/ccode/valaccodeifstatement.vala index 426c590e1..93a9de5ff 100644 --- a/ccode/valaccodeifstatement.vala +++ b/ccode/valaccodeifstatement.vala @@ -1,6 +1,6 @@ /* valaccodeifstatement.vala * - * Copyright (C) 2006 Jürg Billeter + * Copyright (C) 2006-2007 Jürg Billeter * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -55,7 +55,7 @@ public class Vala.CCodeIfStatement : CCodeStatement { public override void write (CCodeWriter! writer) { if (!else_if) { - writer.write_indent (); + writer.write_indent (line); } else { writer.write_string (" "); } diff --git a/ccode/valaccodereturnstatement.vala b/ccode/valaccodereturnstatement.vala index 192953d81..de3e2a96c 100644 --- a/ccode/valaccodereturnstatement.vala +++ b/ccode/valaccodereturnstatement.vala @@ -1,6 +1,6 @@ /* valaccodereturnstatement.vala * - * Copyright (C) 2006 Jürg Billeter + * Copyright (C) 2006-2007 Jürg Billeter * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -36,7 +36,7 @@ public class Vala.CCodeReturnStatement : CCodeStatement { } public override void write (CCodeWriter! writer) { - writer.write_indent (); + writer.write_indent (line); writer.write_string ("return"); if (return_expression != null) { diff --git a/ccode/valaccodeswitchstatement.vala b/ccode/valaccodeswitchstatement.vala index 596b97270..2e63c1a55 100644 --- a/ccode/valaccodeswitchstatement.vala +++ b/ccode/valaccodeswitchstatement.vala @@ -57,7 +57,7 @@ public class Vala.CCodeSwitchStatement : CCodeStatement { } public override void write (CCodeWriter! writer) { - writer.write_indent (); + writer.write_indent (line); writer.write_string ("switch ("); expression.write (writer); writer.write_string (")"); diff --git a/ccode/valaccodevariabledeclarator.vala b/ccode/valaccodevariabledeclarator.vala index 790b776d7..c0772b9de 100644 --- a/ccode/valaccodevariabledeclarator.vala +++ b/ccode/valaccodevariabledeclarator.vala @@ -60,7 +60,7 @@ public class Vala.CCodeVariableDeclarator : CCodeDeclarator { public override void write_initialization (CCodeWriter! writer) { if (initializer != null) { - writer.write_indent (); + writer.write_indent (line); writer.write_string (name); writer.write_string (" = "); diff --git a/ccode/valaccodewhilestatement.vala b/ccode/valaccodewhilestatement.vala index 658b77166..3be28b99d 100644 --- a/ccode/valaccodewhilestatement.vala +++ b/ccode/valaccodewhilestatement.vala @@ -1,6 +1,6 @@ /* valaccodewhilestatement.vala * - * Copyright (C) 2006 Jürg Billeter + * Copyright (C) 2006-2007 Jürg Billeter * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -42,7 +42,7 @@ public class Vala.CCodeWhileStatement : CCodeStatement { } public override void write (CCodeWriter! writer) { - writer.write_indent (); + writer.write_indent (line); writer.write_string ("while ("); condition.write (writer); diff --git a/ccode/valaccodewriter.vala b/ccode/valaccodewriter.vala index 3393983cc..60939a879 100644 --- a/ccode/valaccodewriter.vala +++ b/ccode/valaccodewriter.vala @@ -46,14 +46,17 @@ public class Vala.CCodeWriter : Object { } /** + * Specifies whether to emit line directives. + */ + public bool line_directives { get; set; } + + /** * Specifies whether the output stream is at the beginning of a line. */ public bool bol { - get { - return _bol; - } + get { return _bol; } } - + private string _filename; private string temp_filename; private bool file_exists; @@ -104,14 +107,16 @@ public class Vala.CCodeWriter : Object { /** * Writes tabs according to the current indent level. */ - public void write_indent () { - int i; - + public void write_indent (CCodeLineDirective line = null) { + if (line_directives && line != null) { + line.write (this); + } + if (!bol) { stream.putc ('\n'); } - for (i = 0; i < indent; i++) { + for (int i = 0; i < indent; i++) { stream.putc ('\t'); } |