]> git.ipfire.org Git - thirdparty/vala.git/commitdiff
codegen: Add CodeGenerator.create_local method
authorJürg Billeter <j@bitron.ch>
Thu, 21 Oct 2010 10:46:43 +0000 (12:46 +0200)
committerJürg Billeter <j@bitron.ch>
Thu, 28 Oct 2010 09:36:34 +0000 (11:36 +0200)
codegen/valaccodebasemodule.vala
codegen/valadovabasemodule.vala
vala/valacodecontext.vala
vala/valacodegenerator.vala

index 4f4effa2fb67151836257d14bffa3a0421374992..427def83139481394fc854807a74b4ce44a2b88a 100644 (file)
@@ -2272,6 +2272,12 @@ public class Vala.CCodeBaseModule : CodeGenerator {
                }
        }
 
+       public override LocalVariable create_local (DataType type) {
+               var result = get_temp_variable (type, type.value_owned);
+               emit_temp_var (result);
+               return result;
+       }
+
        public LocalVariable get_temp_variable (DataType type, bool value_owned = true, CodeNode? node_reference = null, bool init = true) {
                var var_type = type.copy ();
                var_type.value_owned = value_owned;
index 0ae752ee5b94335288bf4b8f269d0775e4b00b14..ae7bea0b122c05beb4e2cf80db6583c68b268c22 100644 (file)
@@ -927,6 +927,12 @@ public class Vala.DovaBaseModule : CodeGenerator {
                }
        }
 
+       public override LocalVariable create_local (DataType type) {
+               var result = get_temp_variable (type, type.value_owned);
+               emit_temp_var (result);
+               return result;
+       }
+
        public LocalVariable get_temp_variable (DataType type, bool value_owned = true, CodeNode? node_reference = null) {
                var var_type = type.copy ();
                var_type.value_owned = value_owned;
index 988a864f991f550c94d535673f193530b53f8b59..5d3b02284f9fb2c67f84f3f550970792b887943a 100644 (file)
@@ -203,7 +203,7 @@ public class Vala.CodeContext {
        /**
         * The selected code generator.
         */
-       public CodeGenerator codegen { get; set; default = new CodeGenerator (); }
+       public CodeGenerator codegen { get; set; }
 
        public CodeContext () {
        }
index 39442abf972ef24aaa2a014b1b4684aefc1ea06b..08713bc24d9537e8845a031260803973c665535b 100644 (file)
@@ -23,7 +23,7 @@
 /**
  * Abstract code visitor generating code.
  */
-public class Vala.CodeGenerator : CodeVisitor {
+public abstract class Vala.CodeGenerator : CodeVisitor {
        /**
         * Generate and emit C code for the specified code context.
         *
@@ -31,4 +31,6 @@ public class Vala.CodeGenerator : CodeVisitor {
         */
        public virtual void emit (CodeContext context) {
        }
+
+       public abstract LocalVariable create_local (DataType type);
 }