Commit 0c563506 authored by Jürg Billeter's avatar Jürg Billeter Committed by Jürg Billeter

rename CodeGenerator to CCodeGenerator, add abstract CodeGenerator and

2007-09-17  Juerg Billeter  <j@bitron.ch>

	* vala/Makefile.am, vala/valacodebinding.vala,
	  vala/valacodecontext.vala, vala/valacodegenerator.vala,
	  vala/valacodenode.vala, gobject/Makefile.am,
	  gobject/valaccodegenerator.vala, compiler/valacompiler.vala: rename
	  CodeGenerator to CCodeGenerator, add abstract CodeGenerator and
	  CodeBinding classes

svn path=/trunk/; revision=617
parent 251f0e7a
2007-09-17 Jürg Billeter <j@bitron.ch>
* vala/Makefile.am, vala/valacodebinding.vala,
vala/valacodecontext.vala, vala/valacodegenerator.vala,
vala/valacodenode.vala, gobject/Makefile.am,
gobject/valaccodegenerator.vala, compiler/valacompiler.vala: rename
CodeGenerator to CCodeGenerator, add abstract CodeGenerator and
CodeBinding classes
2007-09-17 Jürg Billeter <j@bitron.ch> 2007-09-17 Jürg Billeter <j@bitron.ch>
* vala/valacodevisitor.vala, vala/valalambdaexpression.vala, * vala/valacodevisitor.vala, vala/valalambdaexpression.vala,
......
...@@ -170,6 +170,8 @@ class Vala.Compiler : Object { ...@@ -170,6 +170,8 @@ class Vala.Compiler : Object {
context.optlevel = optlevel; context.optlevel = optlevel;
context.save_temps = save_temps; context.save_temps = save_temps;
context.codegen = new CCodeGenerator (!disable_memory_management);
/* default package */ /* default package */
if (!add_package (context, "glib-2.0")) { if (!add_package (context, "glib-2.0")) {
Report.error (null, "glib-2.0 not found in specified Vala API directories"); Report.error (null, "glib-2.0 not found in specified Vala API directories");
...@@ -248,8 +250,7 @@ class Vala.Compiler : Object { ...@@ -248,8 +250,7 @@ class Vala.Compiler : Object {
} }
} }
var code_generator = new CodeGenerator (!disable_memory_management); context.codegen.emit (context);
code_generator.emit (context);
if (Report.get_errors () > 0) { if (Report.get_errors () > 0) {
return quit (); return quit ();
......
...@@ -19,36 +19,36 @@ libvala_la_SOURCES = \ ...@@ -19,36 +19,36 @@ libvala_la_SOURCES = \
valaclassregisterfunction.c \ valaclassregisterfunction.c \
valaclassregisterfunction.h \ valaclassregisterfunction.h \
valaclassregisterfunction.vala \ valaclassregisterfunction.vala \
valacodegenerator.c \ valaccodegenerator.c \
valacodegenerator.h \ valaccodegenerator.h \
valacodegenerator.vala \ valaccodegenerator.vala \
valacodegeneratorassignment.c \ valaccodegeneratorassignment.c \
valacodegeneratorassignment.h \ valaccodegeneratorassignment.h \
valacodegeneratorassignment.vala \ valaccodegeneratorassignment.vala \
valacodegeneratorclass.c \ valaccodegeneratorclass.c \
valacodegeneratorclass.h \ valaccodegeneratorclass.h \
valacodegeneratorclass.vala \ valaccodegeneratorclass.vala \
valacodegeneratorinterface.c \ valaccodegeneratorinterface.c \
valacodegeneratorinterface.h \ valaccodegeneratorinterface.h \
valacodegeneratorinterface.vala \ valaccodegeneratorinterface.vala \
valacodegeneratorinvocationexpression.c \ valaccodegeneratorinvocationexpression.c \
valacodegeneratorinvocationexpression.h \ valaccodegeneratorinvocationexpression.h \
valacodegeneratorinvocationexpression.vala \ valaccodegeneratorinvocationexpression.vala \
valacodegeneratormemberaccess.c \ valaccodegeneratormemberaccess.c \
valacodegeneratormemberaccess.h \ valaccodegeneratormemberaccess.h \
valacodegeneratormemberaccess.vala \ valaccodegeneratormemberaccess.vala \
valacodegeneratormethod.c \ valaccodegeneratormethod.c \
valacodegeneratormethod.h \ valaccodegeneratormethod.h \
valacodegeneratormethod.vala \ valaccodegeneratormethod.vala \
valacodegeneratorsignal.c \ valaccodegeneratorsignal.c \
valacodegeneratorsignal.h \ valaccodegeneratorsignal.h \
valacodegeneratorsignal.vala \ valaccodegeneratorsignal.vala \
valacodegeneratorsourcefile.c \ valaccodegeneratorsourcefile.c \
valacodegeneratorsourcefile.h \ valaccodegeneratorsourcefile.h \
valacodegeneratorsourcefile.vala \ valaccodegeneratorsourcefile.vala \
valacodegeneratorstruct.c \ valaccodegeneratorstruct.c \
valacodegeneratorstruct.h \ valaccodegeneratorstruct.h \
valacodegeneratorstruct.vala \ valaccodegeneratorstruct.vala \
valadbusbindingprovider.c \ valadbusbindingprovider.c \
valadbusbindingprovider.h \ valadbusbindingprovider.h \
valadbusbindingprovider.vala \ valadbusbindingprovider.vala \
...@@ -71,16 +71,16 @@ gobjectincludedir = $(includedir)/vala-1.0/gobject ...@@ -71,16 +71,16 @@ gobjectincludedir = $(includedir)/vala-1.0/gobject
gobjectinclude_HEADERS = \ gobjectinclude_HEADERS = \
valaccodecompiler.h \ valaccodecompiler.h \
valaclassregisterfunction.h \ valaclassregisterfunction.h \
valacodegenerator.h \ valaccodegenerator.h \
valacodegeneratorassignment.h \ valaccodegeneratorassignment.h \
valacodegeneratorclass.h \ valaccodegeneratorclass.h \
valacodegeneratorinterface.h \ valaccodegeneratorinterface.h \
valacodegeneratorinvocationexpression.h \ valaccodegeneratorinvocationexpression.h \
valacodegeneratormemberaccess.h \ valaccodegeneratormemberaccess.h \
valacodegeneratormethod.h \ valaccodegeneratormethod.h \
valacodegeneratorsignal.h \ valaccodegeneratorsignal.h \
valacodegeneratorsourcefile.h \ valaccodegeneratorsourcefile.h \
valacodegeneratorstruct.h \ valaccodegeneratorstruct.h \
valadbusbindingprovider.h \ valadbusbindingprovider.h \
valadbusmethod.h \ valadbusmethod.h \
valadbussignal.h \ valadbussignal.h \
......
/* valacodegenerator.vala /* valaccodegenerator.vala
* *
* Copyright (C) 2006-2007 Jürg Billeter, Raffaele Sandrini * Copyright (C) 2006-2007 Jürg Billeter, Raffaele Sandrini
* *
...@@ -27,7 +27,7 @@ using Gee; ...@@ -27,7 +27,7 @@ using Gee;
/** /**
* Code visitor generating C Code. * Code visitor generating C Code.
*/ */
public class Vala.CodeGenerator : CodeVisitor { public class Vala.CCodeGenerator : CodeGenerator {
/** /**
* Specifies whether automatic memory management is active. * Specifies whether automatic memory management is active.
*/ */
...@@ -123,7 +123,7 @@ public class Vala.CodeGenerator : CodeVisitor { ...@@ -123,7 +123,7 @@ public class Vala.CodeGenerator : CodeVisitor {
private bool requires_array_free; private bool requires_array_free;
private bool requires_array_move; private bool requires_array_move;
public CodeGenerator (bool manage_memory = true) { public CCodeGenerator (bool manage_memory = true) {
memory_management = manage_memory; memory_management = manage_memory;
} }
...@@ -193,12 +193,7 @@ public class Vala.CodeGenerator : CodeVisitor { ...@@ -193,12 +193,7 @@ public class Vala.CodeGenerator : CodeVisitor {
c_keywords.add ("cdecl"); c_keywords.add ("cdecl");
} }
/** public override void emit (CodeContext! context) {
* Generate and emit C code for the specified code context.
*
* @param context a code context
*/
public void emit (CodeContext! context) {
this.context = context; this.context = context;
context.find_header_cycles (); context.find_header_cycles ();
......
/* valacodegeneratorassignment.vala /* valaccodegeneratorassignment.vala
* *
* Copyright (C) 2006-2007 Jürg Billeter, Raffaele Sandrini * Copyright (C) 2006-2007 Jürg Billeter, Raffaele Sandrini
* *
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
using GLib; using GLib;
using Gee; using Gee;
public class Vala.CodeGenerator { public class Vala.CCodeGenerator {
public override void visit_assignment (Assignment! a) { public override void visit_assignment (Assignment! a) {
a.accept_children (this); a.accept_children (this);
......
/* valacodegeneratorclass.vala /* valaccodegeneratorclass.vala
* *
* Copyright (C) 2006-2007 Jürg Billeter, Raffaele Sandrini * Copyright (C) 2006-2007 Jürg Billeter, Raffaele Sandrini
* *
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
using GLib; using GLib;
public class Vala.CodeGenerator { public class Vala.CCodeGenerator {
public override void visit_class (Class! cl) { public override void visit_class (Class! cl) {
var old_symbol = current_symbol; var old_symbol = current_symbol;
var old_type_symbol = current_type_symbol; var old_type_symbol = current_type_symbol;
......
/* valacodegeneratorinterface.vala /* valaccodegeneratorinterface.vala
* *
* Copyright (C) 2006-2007 Jürg Billeter, Raffaele Sandrini * Copyright (C) 2006-2007 Jürg Billeter, Raffaele Sandrini
* *
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
using GLib; using GLib;
public class Vala.CodeGenerator { public class Vala.CCodeGenerator {
public override void visit_interface (Interface! iface) { public override void visit_interface (Interface! iface) {
current_symbol = iface; current_symbol = iface;
current_type_symbol = iface; current_type_symbol = iface;
......
/* valacodegeneratorinvocationexpression.vala /* valaccodegeneratorinvocationexpression.vala
* *
* Copyright (C) 2006-2007 Jürg Billeter, Raffaele Sandrini * Copyright (C) 2006-2007 Jürg Billeter, Raffaele Sandrini
* *
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
using GLib; using GLib;
using Gee; using Gee;
public class Vala.CodeGenerator { public class Vala.CCodeGenerator {
public override void visit_invocation_expression (InvocationExpression! expr) { public override void visit_invocation_expression (InvocationExpression! expr) {
expr.accept_children (this); expr.accept_children (this);
......
/* valacodegeneratormemberaccess.vala /* valaccodegeneratormemberaccess.vala
* *
* Copyright (C) 2006-2007 Jürg Billeter, Raffaele Sandrini * Copyright (C) 2006-2007 Jürg Billeter, Raffaele Sandrini
* *
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
using GLib; using GLib;
public class Vala.CodeGenerator { public class Vala.CCodeGenerator {
private void process_cmember (MemberAccess! expr, CCodeExpression pub_inst, DataType base_type) { private void process_cmember (MemberAccess! expr, CCodeExpression pub_inst, DataType base_type) {
if (expr.symbol_reference is Method) { if (expr.symbol_reference is Method) {
var m = (Method) expr.symbol_reference; var m = (Method) expr.symbol_reference;
......
/* valacodegeneratormethod.vala /* valaccodegeneratormethod.vala
* *
* Copyright (C) 2006-2007 Jürg Billeter, Raffaele Sandrini * Copyright (C) 2006-2007 Jürg Billeter, Raffaele Sandrini
* *
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
using GLib; using GLib;
using Gee; using Gee;
public class Vala.CodeGenerator { public class Vala.CCodeGenerator {
public override void visit_method (Method! m) { public override void visit_method (Method! m) {
Method old_method = current_method; Method old_method = current_method;
TypeReference old_return_type = current_return_type; TypeReference old_return_type = current_return_type;
......
/* valacodegeneratorsignal.vala /* valaccodegeneratorsignal.vala
* *
* Copyright (C) 2006-2007 Jürg Billeter, Raffaele Sandrini * Copyright (C) 2006-2007 Jürg Billeter, Raffaele Sandrini
* *
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
using GLib; using GLib;
public class Vala.CodeGenerator { public class Vala.CCodeGenerator {
private string get_marshaller_type_name (TypeReference t) { private string get_marshaller_type_name (TypeReference t) {
if (t.type_parameter != null) { if (t.type_parameter != null) {
return ("POINTER"); return ("POINTER");
......
/* valacodegeneratorsourcefile.vala /* valaccodegeneratorsourcefile.vala
* *
* Copyright (C) 2006-2007 Jürg Billeter, Raffaele Sandrini * Copyright (C) 2006-2007 Jürg Billeter, Raffaele Sandrini
* *
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
using GLib; using GLib;
using Gee; using Gee;
public class Vala.CodeGenerator { public class Vala.CCodeGenerator {
private CCodeIncludeDirective get_internal_include (string! filename) { private CCodeIncludeDirective get_internal_include (string! filename) {
return new CCodeIncludeDirective (filename, context.library == null); return new CCodeIncludeDirective (filename, context.library == null);
} }
......
/* valacodegeneratorstruct.vala /* valaccodegeneratorstruct.vala
* *
* Copyright (C) 2006-2007 Jürg Billeter, Raffaele Sandrini * Copyright (C) 2006-2007 Jürg Billeter, Raffaele Sandrini
* *
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
using GLib; using GLib;
public class Vala.CodeGenerator { public class Vala.CCodeGenerator {
public override void visit_struct (Struct! st) { public override void visit_struct (Struct! st) {
var old_type_symbol = current_type_symbol; var old_type_symbol = current_type_symbol;
var old_instance_struct = instance_struct; var old_instance_struct = instance_struct;
......
...@@ -77,9 +77,15 @@ libvalacore_la_SOURCES = \ ...@@ -77,9 +77,15 @@ libvalacore_la_SOURCES = \
valaclass.c \ valaclass.c \
valaclass.h \ valaclass.h \
valaclass.vala \ valaclass.vala \
valacodebinding.c \
valacodebinding.h \
valacodebinding.vala \
valacodecontext.c \ valacodecontext.c \
valacodecontext.h \ valacodecontext.h \
valacodecontext.vala \ valacodecontext.vala \
valacodegenerator.c \
valacodegenerator.h \
valacodegenerator.vala \
valacodenode.c \ valacodenode.c \
valacodenode.h \ valacodenode.h \
valacodenode.vala \ valacodenode.vala \
...@@ -346,7 +352,9 @@ valainclude_HEADERS = \ ...@@ -346,7 +352,9 @@ valainclude_HEADERS = \
valacatchclause.h \ valacatchclause.h \
valacharacterliteral.h \ valacharacterliteral.h \
valaclass.h \ valaclass.h \
valacodebinding.h \
valacodecontext.h \ valacodecontext.h \
valacodegenerator.h \
valacodenode.h \ valacodenode.h \
valacodevisitor.h \ valacodevisitor.h \
valaconditionalexpression.h \ valaconditionalexpression.h \
......
/* valacodebinding.vala
*
* Copyright (C) 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
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Author:
* Jürg Billeter <j@bitron.ch>
*/
using GLib;
/**
* The link between a source code node and generated code.
*/
public abstract class Vala.CodeBinding : Object {
}
...@@ -119,7 +119,12 @@ public class Vala.CodeContext : Object { ...@@ -119,7 +119,12 @@ public class Vala.CodeContext : Object {
public Namespace! root { public Namespace! root {
get { return _root; } get { return _root; }
} }
/**
* The selected code generator.
*/
public CodeGenerator codegen { get; set; }
/** /**
* Returns a copy of the list of source files. * Returns a copy of the list of source files.
* *
......
/* valacodegenerator.vala
*
* Copyright (C) 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
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
* Author:
* Jürg Billeter <j@bitron.ch>
*/
using GLib;
/**
* Abstract code visitor generating code.
*/
public abstract class Vala.CodeGenerator : CodeVisitor {
/**
* Generate and emit C code for the specified code context.
*
* @param context a code context
*/
public abstract void emit (CodeContext! context);
}
...@@ -62,7 +62,12 @@ public abstract class Vala.CodeNode : Object { ...@@ -62,7 +62,12 @@ public abstract class Vala.CodeNode : Object {
_ccodenode = value; _ccodenode = value;
} }
} }
/**
* Binding to the generated code.
*/
public CodeBinding code_binding { get; set; }
/** /**
* Specifies whether a fatal error has been detected in this code node. * Specifies whether a fatal error has been detected in this code node.
*/ */
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment