[vala] codegen: Add CodeGenerator.create_local method
- From: Jürg Billeter <juergbi src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [vala] codegen: Add CodeGenerator.create_local method
- Date: Thu, 28 Oct 2010 10:35:25 +0000 (UTC)
commit 7d8bc26ecd8ce492e6ccd50529ab132d550db88b
Author: Jürg Billeter <j bitron ch>
Date: Thu Oct 21 12:46:43 2010 +0200
codegen: Add CodeGenerator.create_local method
codegen/valaccodebasemodule.vala | 6 ++++++
codegen/valadovabasemodule.vala | 6 ++++++
vala/valacodecontext.vala | 2 +-
vala/valacodegenerator.vala | 4 +++-
4 files changed, 16 insertions(+), 2 deletions(-)
---
diff --git a/codegen/valaccodebasemodule.vala b/codegen/valaccodebasemodule.vala
index 4f4effa..427def8 100644
--- a/codegen/valaccodebasemodule.vala
+++ b/codegen/valaccodebasemodule.vala
@@ -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;
diff --git a/codegen/valadovabasemodule.vala b/codegen/valadovabasemodule.vala
index 0ae752e..ae7bea0 100644
--- a/codegen/valadovabasemodule.vala
+++ b/codegen/valadovabasemodule.vala
@@ -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;
diff --git a/vala/valacodecontext.vala b/vala/valacodecontext.vala
index 988a864..5d3b022 100644
--- a/vala/valacodecontext.vala
+++ b/vala/valacodecontext.vala
@@ -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 () {
}
diff --git a/vala/valacodegenerator.vala b/vala/valacodegenerator.vala
index 39442ab..08713bc 100644
--- a/vala/valacodegenerator.vala
+++ b/vala/valacodegenerator.vala
@@ -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);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]