Commit db24aa20 authored by Jürg Billeter's avatar Jürg Billeter Committed by Jürg Billeter

derive from Symbol class where appropriate and move symbol table into

2007-07-21  Juerg Billeter  <j@bitron.ch>

	* vala/Makefile.am, vala/parser.y, vala/scanner.l, vala/vala.h,
	  vala/valaarray.vala, vala/valaarraylengthfield.vala,
	  vala/valaarrayresizemethod.vala, vala/valaattributeprocessor.vala,
	  vala/valablock.vala, vala/valabreakstatement.vala,
	  vala/valacallback.vala, vala/valaclass.vala,
	  vala/valacodecontext.vala, vala/valacodenode.vala,
	  vala/valacodevisitor.vala, vala/valaconstant.vala,
	  vala/valaconstructor.vala, vala/valacontinuestatement.vala,
	  vala/valacreationmethod.vala, vala/valadatatype.vala,
	  vala/valadeclarationstatement.vala, vala/valadestructor.vala,
	  vala/valadostatement.vala, vala/valaemptystatement.vala,
	  vala/valaenum.vala, vala/valaenumvalue.vala,
	  vala/valaexpressionstatement.vala, vala/valafield.vala,
	  vala/valaflags.vala, vala/valaflagsvalue.vala,
	  vala/valaforeachstatement.vala, vala/valaformalparameter.vala,
	  vala/valaforstatement.vala, vala/valaifstatement.vala,
	  vala/valainterface.vala, vala/valainterfacewriter.vala,
	  vala/valalockstatement.vala, vala/valamember.vala,
	  vala/valamemorymanager.vala, vala/valamethod.vala,
	  vala/valanamespace.vala, vala/valaproperty.vala,
	  vala/valapropertyaccessor.vala, vala/valareturnstatement.vala,
	  vala/valascope.vala, vala/valasemanticanalyzer.vala,
	  vala/valasignal.vala, vala/valasourcefile.vala,
	  vala/valastatement.vala, vala/valastruct.vala,
	  vala/valaswitchstatement.vala, vala/valasymbol.vala,
	  vala/valasymbolbuilder.vala, vala/valasymbolresolver.vala,
	  vala/valathrowstatement.vala, vala/valatrystatement.vala,
	  vala/valatypeparameter.vala, vala/valatypereference.vala,
	  vala/valavariabledeclarator.vala, vala/valawhilestatement.vala,
	  gobject/valacodegenerator.vala,
	  gobject/valacodegeneratorassignment.vala,
	  gobject/valacodegeneratorclass.vala,
	  gobject/valacodegeneratorinterface.vala,
	  gobject/valacodegeneratorinvocationexpression.vala,
	  gobject/valacodegeneratormemberaccess.vala,
	  gobject/valacodegeneratormethod.vala,
	  gobject/valacodegeneratorsignal.vala,
	  gobject/valacodegeneratorstruct.vala, compiler/valacompiler.vala,
	  vapi/atk.vala, vapi/gdk-2.0.vala, vapi/gio-standalone.vala,
	  vapi/glib-2.0.vala, vapi/gstreamer-0.10.vala, vapi/gtk+-2.0.vala,
	  vapi/packages/gstreamer-0.10/gstreamer-0.10-custom.vala,
	  vapi/packages/gtk+-2.0/gtk+-2.0-custom.vala, vapi/pango.vala,
	  vapi/vte.vala, vapigen/valagidlparser.vala, vapigen/valavapigen.vala:
	  derive from Symbol class where appropriate and move symbol table into
	  separate Scope class

svn path=/trunk/; revision=366
parent 611df119
2007-07-21 Jürg Billeter <j@bitron.ch>
* vala/Makefile.am, vala/parser.y, vala/scanner.l, vala/vala.h,
vala/valaarray.vala, vala/valaarraylengthfield.vala,
vala/valaarrayresizemethod.vala, vala/valaattributeprocessor.vala,
vala/valablock.vala, vala/valabreakstatement.vala,
vala/valacallback.vala, vala/valaclass.vala,
vala/valacodecontext.vala, vala/valacodenode.vala,
vala/valacodevisitor.vala, vala/valaconstant.vala,
vala/valaconstructor.vala, vala/valacontinuestatement.vala,
vala/valacreationmethod.vala, vala/valadatatype.vala,
vala/valadeclarationstatement.vala, vala/valadestructor.vala,
vala/valadostatement.vala, vala/valaemptystatement.vala,
vala/valaenum.vala, vala/valaenumvalue.vala,
vala/valaexpressionstatement.vala, vala/valafield.vala,
vala/valaflags.vala, vala/valaflagsvalue.vala,
vala/valaforeachstatement.vala, vala/valaformalparameter.vala,
vala/valaforstatement.vala, vala/valaifstatement.vala,
vala/valainterface.vala, vala/valainterfacewriter.vala,
vala/valalockstatement.vala, vala/valamember.vala,
vala/valamemorymanager.vala, vala/valamethod.vala,
vala/valanamespace.vala, vala/valaproperty.vala,
vala/valapropertyaccessor.vala, vala/valareturnstatement.vala,
vala/valascope.vala, vala/valasemanticanalyzer.vala,
vala/valasignal.vala, vala/valasourcefile.vala,
vala/valastatement.vala, vala/valastruct.vala,
vala/valaswitchstatement.vala, vala/valasymbol.vala,
vala/valasymbolbuilder.vala, vala/valasymbolresolver.vala,
vala/valathrowstatement.vala, vala/valatrystatement.vala,
vala/valatypeparameter.vala, vala/valatypereference.vala,
vala/valavariabledeclarator.vala, vala/valawhilestatement.vala,
gobject/valacodegenerator.vala,
gobject/valacodegeneratorassignment.vala,
gobject/valacodegeneratorclass.vala,
gobject/valacodegeneratorinterface.vala,
gobject/valacodegeneratorinvocationexpression.vala,
gobject/valacodegeneratormemberaccess.vala,
gobject/valacodegeneratormethod.vala,
gobject/valacodegeneratorsignal.vala,
gobject/valacodegeneratorstruct.vala, compiler/valacompiler.vala,
vapi/atk.vala, vapi/gdk-2.0.vala, vapi/gio-standalone.vala,
vapi/glib-2.0.vala, vapi/gstreamer-0.10.vala, vapi/gtk+-2.0.vala,
vapi/packages/gstreamer-0.10/gstreamer-0.10-custom.vala,
vapi/packages/gtk+-2.0/gtk+-2.0-custom.vala, vapi/pango.vala,
vapi/vte.vala, vapigen/valagidlparser.vala, vapigen/valavapigen.vala:
derive from Symbol class where appropriate and move symbol table into
separate Scope class
2007-07-21 Raffaele Sandrini <raffaele@sandrini.ch>
* vapi/zlib.vala: add basic zlib support
......
......@@ -199,13 +199,6 @@ class Vala.Compiler {
return quit ();
}
var builder = new SymbolBuilder ();
builder.build (context);
if (Report.get_errors () > 0) {
return quit ();
}
var attributeprocessor = new AttributeProcessor ();
attributeprocessor.process (context);
......
This diff is collapsed.
......@@ -31,10 +31,10 @@ public class Vala.CodeGenerator {
ma = (MemberAccess)a.left;
}
if (a.left.symbol_reference != null && a.left.symbol_reference.node is Property) {
var prop = (Property) a.left.symbol_reference.node;
if (a.left.symbol_reference is Property) {
var prop = (Property) a.left.symbol_reference;
if (current_class != null && ma.inner == null && in_creation_method) {
if (current_type_symbol is Class && ma.inner == null && in_creation_method) {
// this property is used as a construction parameter
var cpointer = new CCodeIdentifier ("__params_it");
......@@ -111,10 +111,10 @@ public class Vala.CodeGenerator {
a.ccodenode = ccomma;
}
} else if (a.left.symbol_reference != null && a.left.symbol_reference.node is Signal) {
var sig = (Signal) a.left.symbol_reference.node;
} else if (a.left.symbol_reference is Signal) {
var sig = (Signal) a.left.symbol_reference;
var m = (Method) a.right.symbol_reference.node;
var m = (Method) a.right.symbol_reference;
string connect_func;
bool disconnect = false;
......@@ -152,7 +152,7 @@ public class Vala.CodeGenerator {
temp_vars.prepend (temp_decl);
var parse_call = new CCodeFunctionCall (new CCodeIdentifier ("g_signal_parse_name"));
parse_call.add_argument (sig.get_canonical_cconstant ());
var decl_type = (DataType) sig.symbol.parent_symbol.node;
var decl_type = (DataType) sig.parent_symbol;
parse_call.add_argument (new CCodeIdentifier (decl_type.get_type_id ()));
parse_call.add_argument (new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, new CCodeIdentifier (temp_decl.name)));
parse_call.add_argument (new CCodeConstant ("NULL"));
......@@ -258,7 +258,7 @@ public class Vala.CodeGenerator {
}
private CCodeFunctionCall get_property_set_call (Property! prop, MemberAccess! ma, CCodeExpression! cexpr) {
var cl = (Class) prop.symbol.parent_symbol.node;
var cl = (Class) prop.parent_symbol;
var set_func = "g_object_set";
var base_property = prop;
......@@ -268,7 +268,7 @@ public class Vala.CodeGenerator {
} else if (prop.base_interface_property != null) {
base_property = prop.base_interface_property;
}
var base_property_type = (DataType) base_property.symbol.parent_symbol.node;
var base_property_type = (DataType) base_property.parent_symbol;
set_func = "%s_set_%s".printf (base_property_type.get_lower_case_cname (null), base_property.name);
}
......@@ -281,16 +281,16 @@ public class Vala.CodeGenerator {
if (ma.inner == null) {
instance = new CCodeIdentifier ("self");
/* require casts for inherited properties */
req_cast = (base_property.symbol.parent_symbol != current_type_symbol);
req_cast = (base_property.parent_symbol != current_type_symbol);
} else {
instance = (CCodeExpression) ma.inner.ccodenode;
/* require casts if the type of the used instance is
* different than the type which declared the property */
req_cast = base_property.symbol.parent_symbol.node != ma.inner.static_type.data_type;
req_cast = base_property.parent_symbol != ma.inner.static_type.data_type;
}
if (req_cast && ((DataType) prop.symbol.parent_symbol.node).is_reference_type ()) {
var ccast = new CCodeFunctionCall (new CCodeIdentifier (((DataType) base_property.symbol.parent_symbol.node).get_upper_case_cname (null)));
if (req_cast && ((DataType) prop.parent_symbol).is_reference_type ()) {
var ccast = new CCodeFunctionCall (new CCodeIdentifier (((DataType) base_property.parent_symbol).get_upper_case_cname (null)));
ccast.add_argument (instance);
instance = ccast;
}
......
......@@ -25,8 +25,17 @@ using GLib;
public class Vala.CodeGenerator {
public override void visit_class (Class! cl) {
current_symbol = cl.symbol;
current_type_symbol = cl.symbol;
var old_symbol = current_symbol;
var old_type_symbol = current_type_symbol;
var old_class = current_class;
var old_instance_struct = instance_struct;
var old_type_struct = type_struct;
var old_instance_priv_struct = instance_priv_struct;
var old_prop_enum = prop_enum;
var old_instance_init_fragment = instance_init_fragment;
var old_instance_dispose_fragment = instance_dispose_fragment;
current_symbol = cl;
current_type_symbol = cl;
current_class = cl;
if (cl.is_static) {
......@@ -121,9 +130,15 @@ public class Vala.CodeGenerator {
}
}
current_type_symbol = null;
current_class = null;
instance_dispose_fragment = null;
current_type_symbol = old_type_symbol;
current_class = old_class;
instance_dispose_fragment = old_instance_dispose_fragment;
instance_struct = old_instance_struct;
type_struct = old_type_struct;
instance_priv_struct = old_instance_priv_struct;
prop_enum = old_prop_enum;
instance_init_fragment = old_instance_init_fragment;
instance_dispose_fragment = old_instance_dispose_fragment;
}
private void add_class_init_function (Class! cl) {
......@@ -186,7 +201,7 @@ public class Vala.CodeGenerator {
if (m.base_method == null) {
continue;
}
var base_type = m.base_method.symbol.parent_symbol.node;
var base_type = m.base_method.parent_symbol;
var ccast = new CCodeFunctionCall (new CCodeIdentifier ("%s_CLASS".printf (((Class) base_type).get_upper_case_cname (null))));
ccast.add_argument (new CCodeIdentifier ("klass"));
......@@ -270,7 +285,7 @@ public class Vala.CodeGenerator {
continue;
}
var base_type = m.base_interface_method.symbol.parent_symbol.node;
var base_type = m.base_interface_method.parent_symbol;
if (base_type != iface) {
continue;
}
......@@ -298,9 +313,9 @@ public class Vala.CodeGenerator {
init_block.add_statement (instance_init_fragment);
var init_sym = cl.symbol.lookup ("init");
var init_sym = cl.scope.lookup ("init");
if (init_sym != null) {
var init_fun = (Method) init_sym.node;
var init_fun = (Method) init_sym;
init_block.add_statement (init_fun.body.ccodenode);
}
......
......@@ -25,8 +25,8 @@ using GLib;
public class Vala.CodeGenerator {
public override void visit_interface (Interface! iface) {
current_symbol = iface.symbol;
current_type_symbol = iface.symbol;
current_symbol = iface;
current_type_symbol = iface;
if (!iface.is_static) {
type_struct = new CCodeStruct ("_%s".printf (iface.get_type_cname ()));
......
......@@ -38,8 +38,8 @@ public class Vala.CodeGenerator {
var ma = (MemberAccess) expr.call;
if (expr.call.symbol_reference.node is Invokable) {
var i = (Invokable) expr.call.symbol_reference.node;
if (expr.call.symbol_reference is Invokable) {
var i = (Invokable) expr.call.symbol_reference;
params = i.get_parameters ();
if (i is Method) {
......@@ -50,7 +50,7 @@ public class Vala.CodeGenerator {
}
if (m is ArrayResizeMethod) {
var array = (Array) m.symbol.parent_symbol.node;
var array = (Array) m.parent_symbol;
ccall.add_argument (new CCodeIdentifier (array.get_cname ()));
}
......@@ -70,21 +70,21 @@ public class Vala.CodeGenerator {
if (ma.inner == null) {
instance = new CCodeIdentifier ("self");
/* require casts for overriden and inherited methods */
req_cast = m.overrides || m.base_interface_method != null || (m.symbol.parent_symbol != current_type_symbol);
req_cast = m.overrides || m.base_interface_method != null || (m.parent_symbol != current_type_symbol);
} else {
instance = (CCodeExpression) ma.inner.ccodenode;
/* reqiure casts if the type of the used instance is
* different than the type which declared the method */
req_cast = base_method.symbol.parent_symbol.node != ma.inner.static_type.data_type;
req_cast = base_method.parent_symbol != ma.inner.static_type.data_type;
}
if (m.instance_by_reference && (ma.inner != null || m.symbol.parent_symbol != current_type_symbol)) {
if (m.instance_by_reference && (ma.inner != null || m.parent_symbol != current_type_symbol)) {
instance = new CCodeUnaryExpression (CCodeUnaryOperator.ADDRESS_OF, instance);
}
if (req_cast && ((DataType) m.symbol.parent_symbol.node).is_reference_type ()) {
if (req_cast && ((DataType) m.parent_symbol).is_reference_type ()) {
// FIXME: use C cast if debugging disabled
var ccall = new CCodeFunctionCall (new CCodeIdentifier (((DataType) base_method.symbol.parent_symbol.node).get_upper_case_cname (null)));
var ccall = new CCodeFunctionCall (new CCodeIdentifier (((DataType) base_method.parent_symbol).get_upper_case_cname (null)));
ccall.add_argument (instance);
instance = ccall;
}
......
......@@ -25,18 +25,18 @@ using GLib;
public class Vala.CodeGenerator {
private void process_cmember (MemberAccess! expr, CCodeExpression pub_inst, DataType base_type) {
if (expr.symbol_reference.node is Method) {
var m = (Method) expr.symbol_reference.node;
if (expr.symbol_reference is Method) {
var m = (Method) expr.symbol_reference;
if (expr.inner is BaseAccess) {
if (m.base_interface_method != null) {
var base_iface = (Interface) m.base_interface_method.symbol.parent_symbol.node;
var base_iface = (Interface) m.base_interface_method.parent_symbol;
string parent_iface_var = "%s_%s_parent_iface".printf (current_class.get_lower_case_cname (null), base_iface.get_lower_case_cname (null));
expr.ccodenode = new CCodeMemberAccess.pointer (new CCodeIdentifier (parent_iface_var), m.name);
return;
} else if (m.base_method != null) {
var base_class = (Class) m.base_method.symbol.parent_symbol.node;
var base_class = (Class) m.base_method.parent_symbol;
var vcast = new CCodeFunctionCall (new CCodeIdentifier ("%s_CLASS".printf (base_class.get_upper_case_cname (null))));
vcast.add_argument (new CCodeIdentifier ("%s_parent_class".printf (current_class.get_lower_case_cname (null))));
......@@ -52,15 +52,15 @@ public class Vala.CodeGenerator {
} else {
expr.ccodenode = new CCodeIdentifier (m.get_cname ());
}
} else if (expr.symbol_reference.node is ArrayLengthField) {
} else if (expr.symbol_reference is ArrayLengthField) {
expr.ccodenode = get_array_length_cexpression (expr.inner, 1);
} else if (expr.symbol_reference.node is Field) {
var f = (Field) expr.symbol_reference.node;
} else if (expr.symbol_reference is Field) {
var f = (Field) expr.symbol_reference;
if (f.instance) {
CCodeExpression typed_inst;
if (f.symbol.parent_symbol.node != base_type) {
if (f.parent_symbol != base_type) {
// FIXME: use C cast if debugging disabled
typed_inst = new CCodeFunctionCall (new CCodeIdentifier (((DataType) f.symbol.parent_symbol.node).get_upper_case_cname (null)));
typed_inst = new CCodeFunctionCall (new CCodeIdentifier (((DataType) f.parent_symbol).get_upper_case_cname (null)));
((CCodeFunctionCall) typed_inst).add_argument (pub_inst);
} else {
typed_inst = pub_inst;
......@@ -71,7 +71,7 @@ public class Vala.CodeGenerator {
} else {
inst = typed_inst;
}
if (((DataType) f.symbol.parent_symbol.node).is_reference_type ()) {
if (((DataType) f.parent_symbol).is_reference_type ()) {
expr.ccodenode = new CCodeMemberAccess.pointer (inst, f.get_cname ());
} else {
expr.ccodenode = new CCodeMemberAccess (inst, f.get_cname ());
......@@ -79,11 +79,11 @@ public class Vala.CodeGenerator {
} else {
expr.ccodenode = new CCodeIdentifier (f.get_cname ());
}
} else if (expr.symbol_reference.node is Constant) {
var c = (Constant) expr.symbol_reference.node;
} else if (expr.symbol_reference is Constant) {
var c = (Constant) expr.symbol_reference;
expr.ccodenode = new CCodeIdentifier (c.get_cname ());
} else if (expr.symbol_reference.node is Property) {
var prop = (Property) expr.symbol_reference.node;
} else if (expr.symbol_reference is Property) {
var prop = (Property) expr.symbol_reference;
if (!prop.no_accessor_method) {
var base_property = prop;
......@@ -92,7 +92,7 @@ public class Vala.CodeGenerator {
} else if (prop.base_interface_property != null) {
base_property = prop.base_interface_property;
}
var base_property_type = (DataType) base_property.symbol.parent_symbol.node;
var base_property_type = (DataType) base_property.parent_symbol;
var ccall = new CCodeFunctionCall (new CCodeIdentifier ("%s_get_%s".printf (base_property_type.get_lower_case_cname (null), base_property.name)));
CCodeExpression typed_pub_inst = pub_inst;
......@@ -133,14 +133,14 @@ public class Vala.CodeGenerator {
ccomma.append_expression (ctemp);
expr.ccodenode = ccomma;
}
} else if (expr.symbol_reference.node is EnumValue) {
var ev = (EnumValue) expr.symbol_reference.node;
} else if (expr.symbol_reference is EnumValue) {
var ev = (EnumValue) expr.symbol_reference;
expr.ccodenode = new CCodeConstant (ev.get_cname ());
} else if (expr.symbol_reference.node is VariableDeclarator) {
var decl = (VariableDeclarator) expr.symbol_reference.node;
} else if (expr.symbol_reference is VariableDeclarator) {
var decl = (VariableDeclarator) expr.symbol_reference;
expr.ccodenode = new CCodeIdentifier (get_variable_cname (decl.name));
} else if (expr.symbol_reference.node is FormalParameter) {
var p = (FormalParameter) expr.symbol_reference.node;
} else if (expr.symbol_reference is FormalParameter) {
var p = (FormalParameter) expr.symbol_reference;
if (p.name == "this") {
expr.ccodenode = pub_inst;
} else {
......@@ -150,9 +150,9 @@ public class Vala.CodeGenerator {
expr.ccodenode = new CCodeIdentifier (p.name);
}
}
} else if (expr.symbol_reference.node is Signal) {
var sig = (Signal) expr.symbol_reference.node;
var cl = (DataType) sig.symbol.parent_symbol.node;
} else if (expr.symbol_reference is Signal) {
var sig = (Signal) expr.symbol_reference;
var cl = (DataType) sig.parent_symbol;
if (sig.has_emitter) {
var ccall = new CCodeFunctionCall (new CCodeIdentifier ("%s_%s".printf (cl.get_lower_case_cname (null), sig.name)));
......@@ -196,7 +196,7 @@ public class Vala.CodeGenerator {
if (current_type_symbol != null) {
/* base type is available if this is a type method */
base_type = (DataType) current_type_symbol.node;
base_type = (DataType) current_type_symbol;
if (!base_type.is_reference_type ()) {
pub_inst = new CCodeIdentifier ("(*self)");
......
......@@ -28,7 +28,7 @@ public class Vala.CodeGenerator {
Method old_method = current_method;
TypeReference old_return_type = current_return_type;
bool old_method_inner_error = current_method_inner_error;
current_symbol = m.symbol;
current_symbol = m;
current_method = m;
current_return_type = m.return_type;
current_method_inner_error = false;
......@@ -40,7 +40,7 @@ public class Vala.CodeGenerator {
m.accept_children (this);
if (m is CreationMethod) {
if (current_class != null && m.body != null) {
if (current_type_symbol is Class && m.body != null) {
add_object_creation ((CCodeBlock) m.body.ccodenode);
}
......@@ -54,8 +54,8 @@ public class Vala.CodeGenerator {
current_return_type = old_return_type;
current_method_inner_error = old_method_inner_error;
if (current_type_symbol != null && current_type_symbol.node is Interface) {
var iface = (Interface) current_type_symbol.node;
if (current_type_symbol != null && current_type_symbol is Interface) {
var iface = (Interface) current_type_symbol;
if (iface.is_static) {
return;
}
......@@ -71,11 +71,11 @@ public class Vala.CodeGenerator {
this_type.data_type = find_parent_type (m);
if (m.base_interface_method != null) {
var base_type = new TypeReference ();
base_type.data_type = (DataType) m.base_interface_method.symbol.parent_symbol.node;
base_type.data_type = (DataType) m.base_interface_method.parent_symbol;
instance_param = new CCodeFormalParameter ("base", base_type.get_cname ());
} else if (m.overrides) {
var base_type = new TypeReference ();
base_type.data_type = (DataType) m.base_method.symbol.parent_symbol.node;
base_type.data_type = (DataType) m.base_method.parent_symbol;
instance_param = new CCodeFormalParameter ("base", base_type.get_cname ());
} else {
if (m.instance_by_reference) {
......@@ -98,7 +98,7 @@ public class Vala.CodeGenerator {
}
}
if (m is CreationMethod && current_class != null) {
if (m is CreationMethod && current_type_symbol is Class) {
// memory management for generic types
foreach (TypeParameter type_param in current_class.get_type_parameters ()) {
var cparam = new CCodeFormalParameter ("%s_destroy_func".printf (type_param.name.down ()), "GDestroyNotify");
......@@ -178,8 +178,8 @@ public class Vala.CodeGenerator {
var cinit = new CCodeFragment ();
function.block.prepend_statement (cinit);
if (m.symbol.parent_symbol.node is Class) {
var cl = (Class) m.symbol.parent_symbol.node;
if (m.parent_symbol is Class) {
var cl = (Class) m.parent_symbol;
if (m.overrides || m.base_interface_method != null) {
var ccall = new CCodeFunctionCall (new CCodeIdentifier (cl.get_upper_case_cname (null)));
ccall.add_argument (new CCodeIdentifier ("base"));
......@@ -217,7 +217,7 @@ public class Vala.CodeGenerator {
source_type_member_definition.append (function);
if (m is CreationMethod) {
if (current_class != null) {
if (current_type_symbol is Class) {
int n_params = ((CreationMethod) m).n_construction_params;
n_params += (int) current_class.get_type_parameters ().length ();
......@@ -266,7 +266,7 @@ public class Vala.CodeGenerator {
cinit.append (new CCodeExpressionStatement (ccomma));
}
} else {
var st = (Struct) m.symbol.parent_symbol.node;
var st = (Struct) m.parent_symbol;
var cdecl = new CCodeDeclaration (st.get_cname () + "*");
var ccall = new CCodeFunctionCall (new CCodeIdentifier ("g_new0"));
ccall.add_argument (new CCodeConstant (st.get_cname ()));
......@@ -287,7 +287,7 @@ public class Vala.CodeGenerator {
var vfunc = new CCodeFunction (m.get_cname (), m.return_type.get_cname ());
var this_type = new TypeReference ();
this_type.data_type = (DataType) m.symbol.parent_symbol.node;
this_type.data_type = (DataType) m.parent_symbol;
var cparam = new CCodeFormalParameter ("self", this_type.get_cname ());
vfunc.add_parameter (cparam);
......@@ -295,12 +295,12 @@ public class Vala.CodeGenerator {
var vblock = new CCodeBlock ();
CCodeFunctionCall vcast = null;
if (m.symbol.parent_symbol.node is Interface) {
var iface = (Interface) m.symbol.parent_symbol.node;
if (m.parent_symbol is Interface) {
var iface = (Interface) m.parent_symbol;
vcast = new CCodeFunctionCall (new CCodeIdentifier ("%s_GET_INTERFACE".printf (iface.get_upper_case_cname (null))));
} else {
var cl = (Class) m.symbol.parent_symbol.node;
var cl = (Class) m.parent_symbol;
vcast = new CCodeFunctionCall (new CCodeIdentifier ("%s_GET_CLASS".printf (cl.get_upper_case_cname (null))));
}
......@@ -428,11 +428,10 @@ public class Vala.CodeGenerator {
return null;
}
private DataType find_parent_type (CodeNode node) {
var sym = node.symbol;
private DataType find_parent_type (Symbol sym) {
while (sym != null) {
if (sym.node is DataType) {
return (DataType) sym.node;
if (sym is DataType) {
return (DataType) sym;
}
sym = sym.parent_symbol;
}
......
......@@ -76,8 +76,6 @@ public class Vala.CodeGenerator {
}
} else if (t.data_type is Enum) {
return "gint";
} else if (t.data_type is Flags) {
return "guint";
} else if (t.data_type is Array) {
return "gpointer";
}
......
......@@ -25,9 +25,12 @@ using GLib;
public class Vala.CodeGenerator {
public override void visit_struct (Struct! st) {
current_type_symbol = st.symbol;
var old_type_symbol = current_type_symbol;
var old_instance_struct = instance_struct;
var old_instance_dispose_fragment = instance_dispose_fragment;
current_type_symbol = st;
instance_struct = new CCodeStruct ("_%s".printf (st.get_cname ()));
instance_dispose_fragment = null;
if (st.source_reference.file.cycle == null) {
header_type_declaration.append (new CCodeTypeDefinition ("struct _%s".printf (st.get_cname ()), new CCodeVariableDeclarator (st.get_cname ())));
......@@ -40,6 +43,8 @@ public class Vala.CodeGenerator {
st.accept_children (this);
current_type_symbol = null;
current_type_symbol = old_type_symbol;
instance_struct = old_instance_struct;
instance_dispose_fragment = old_instance_dispose_fragment;
}
}
......@@ -127,12 +127,6 @@ libvalacore_la_SOURCES = \
valafield.c \
valafield.h \
valafield.vala \
valaflags.c \
valaflags.h \
valaflags.vala \
valaflagsvalue.c \
valaflagsvalue.h \
valaflagsvalue.vala \
valaforeachstatement.c \
valaforeachstatement.h \
valaforeachstatement.vala \
......@@ -247,6 +241,9 @@ libvalacore_la_SOURCES = \
valareturnstatement.c \
valareturnstatement.h \
valareturnstatement.vala \
valascope.c \
valascope.h \
valascope.vala \
valasemanticanalyzer.c \
valasemanticanalyzer.h \
valasemanticanalyzer.vala \
......@@ -283,9 +280,6 @@ libvalacore_la_SOURCES = \
valaswitchstatement.c \
valaswitchstatement.h \
valaswitchstatement.vala \
valasymbolbuilder.c \
valasymbolbuilder.h \
valasymbolbuilder.vala \
valasymbol.c \
valasymbol.h \
valasymbol.vala \
......@@ -360,8 +354,6 @@ valainclude_HEADERS = \
valaexpression.h \
valaexpressionstatement.h \
valafield.h \
valaflags.h \
valaflagsvalue.h \
valaforeachstatement.h \
valaformalparameter.h \
valaforstatement.h \
......@@ -400,6 +392,7 @@ valainclude_HEADERS = \
valareferencetransferexpression.h \
valareport.h \
valareturnstatement.h \
valascope.h \
valasemanticanalyzer.h \
valasignal.h \
valasizeofexpression.h \
......@@ -412,7 +405,6 @@ valainclude_HEADERS = \
valaswitchlabel.h \
valaswitchsection.h \
valaswitchstatement.h \
valasymbolbuilder.h \
valasymbol.h \
valasymbolresolver.h \
valathrowstatement.h \
......
This diff is collapsed.
......@@ -143,7 +143,6 @@ literal ({integer_literal}|{real_literal}|{character_literal}|{string_literal
"enum" { uploc; return ENUM; }
"false" { uploc; return VALA_FALSE; }
"finally" { uploc; return FINALLY; }
"flags" { uploc; return FLAGS; }
"for" { uploc; return FOR; }
"foreach" { uploc; return FOREACH; }
"get" { uploc; return GET; }
......
......@@ -28,8 +28,6 @@
#include <vala/valaexpression.h>
#include <vala/valaexpressionstatement.h>
#include <vala/valafield.h>
#include <vala/valaflags.h>
#include <vala/valaflagsvalue.h>
#include <vala/valaforeachstatement.h>
#include <vala/valaformalparameter.h>
#include <vala/valaforstatement.h>
......@@ -60,6 +58,7 @@
#include <vala/valareferencetransferexpression.h>
#include <vala/valareport.h>
#include <vala/valareturnstatement.h>
#include <vala/valascope.h>
#include <vala/valasignal.h>
#include <vala/valasizeofexpression.h>
#include <vala/valasourcefile.h>
......
......@@ -90,10 +90,8 @@ public class Vala.Array : DataType {
name = "%s]".printf (name);
length_field = new ArrayLengthField (source_reference);
length_field.symbol = new Symbol (length_field);
resize_method = new ArrayResizeMethod (source_reference);
resize_method.symbol = new Symbol (resize_method);
}
/**
......
......@@ -30,7 +30,7 @@ public class Vala.ArrayLengthField : Field {
access = MemberAccessibility.PUBLIC;
var root_symbol = source_reference.file.context.root;
type_reference.data_type = (DataType) root_symbol.lookup ("int").node;
type_reference.data_type = (DataType) root_symbol.scope.lookup ("int");
}
/**
......
......@@ -33,7 +33,7 @@ public class Vala.ArrayResizeMethod : Method {
var root_symbol = source_reference.file.context.root;
var int_type = new TypeReference ();
int_type.data_type = (DataType) root_symbol.lookup ("int").node;
int_type.data_type = (DataType) root_symbol.scope.lookup ("int");
add_parameter (new FormalParameter ("length", int_type));
......
......@@ -42,6 +42,10 @@ public class Vala.AttributeProcessor : CodeVisitor {
public override void visit_namespace (Namespace! ns) {
ns.process_attributes ();
foreach (Namespace ns in ns.get_namespaces ()) {
ns.accept (this);
}
}
public override void visit_class (Class! cl) {
......@@ -66,10 +70,6 @@ public class Vala.AttributeProcessor : CodeVisitor {
en.process_attributes ();
}
public override void visit_flags (Flags! fl) {
fl.process_attributes ();
}
public override void visit_method (Method! m) {
m.process_attributes ();
}
......
......@@ -25,7 +25,7 @@ using GLib;
/**