Commit 4542c159 authored by Jürg Billeter's avatar Jürg Billeter Committed by Jürg Billeter
Browse files

remove unnecessary construction properties to improve performance

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

	* vala/valaarray.vala, vala/valaarraylengthfield.vala,
	  vala/valaarrayresizemethod.vala, vala/valaattribute.vala,
	  vala/valacodenode.vala, vala/valaconstant.vala, vala/valafield.vala,
	  vala/valanamespacereference.vala, vala/valasignal.vala,
	  vala/valasourcefile.vala: remove unnecessary construction properties
	  to improve performance

svn path=/trunk/; revision=378
parent f639be72
2007-07-23 Jürg Billeter <j@bitron.ch>
* vala/valaarray.vala, vala/valaarraylengthfield.vala,
vala/valaarrayresizemethod.vala, vala/valaattribute.vala,
vala/valacodenode.vala, vala/valaconstant.vala, vala/valafield.vala,
vala/valanamespacereference.vala, vala/valasignal.vala,
vala/valasourcefile.vala: remove unnecessary construction properties
to improve performance
2007-07-23 Jürg Billeter <j@bitron.ch> 2007-07-23 Jürg Billeter <j@bitron.ch>
* vala/valaexpressionstatement.vala, vala/valasemanticanalyzer.vala, * vala/valaexpressionstatement.vala, vala/valasemanticanalyzer.vala,
......
...@@ -49,13 +49,13 @@ public class Vala.Array : DataType { ...@@ -49,13 +49,13 @@ public class Vala.Array : DataType {
private ArrayResizeMethod resize_method; private ArrayResizeMethod resize_method;
public Array (DataType! _element_type, int _rank, SourceReference! _source_reference) { public Array (DataType! _element_type, int _rank, SourceReference _source_reference) {
rank = _rank; rank = _rank;
element_type = _element_type; element_type = _element_type;
source_reference = _source_reference; source_reference = _source_reference;
} }
public Array.with_type_parameter (TypeParameter! _element_type_parameter, int _rank, SourceReference! _source_reference) { public Array.with_type_parameter (TypeParameter! _element_type_parameter, int _rank, SourceReference _source_reference) {
rank = _rank; rank = _rank;
element_type_parameter = _element_type_parameter; element_type_parameter = _element_type_parameter;
source_reference = _source_reference; source_reference = _source_reference;
...@@ -88,10 +88,6 @@ public class Vala.Array : DataType { ...@@ -88,10 +88,6 @@ public class Vala.Array : DataType {
i--; i--;
} }
name = "%s]".printf (name); name = "%s]".printf (name);
length_field = new ArrayLengthField (source_reference);
resize_method = new ArrayResizeMethod (source_reference);
} }
/** /**
...@@ -190,10 +186,36 @@ public class Vala.Array : DataType { ...@@ -190,10 +186,36 @@ public class Vala.Array : DataType {
} }
public ArrayLengthField get_length_field () { public ArrayLengthField get_length_field () {
if (length_field == null) {
length_field = new ArrayLengthField (source_reference);
length_field.access = MemberAccessibility.PUBLIC;
var root_symbol = source_reference.file.context.root;
length_field.type_reference = new TypeReference ();
length_field.type_reference.data_type = (DataType) root_symbol.scope.lookup ("int");
}
return length_field; return length_field;
} }
public ArrayResizeMethod get_resize_method () { public ArrayResizeMethod get_resize_method () {
if (resize_method == null) {
resize_method = new ArrayResizeMethod (source_reference);
resize_method.return_type = new TypeReference ();
resize_method.access = MemberAccessibility.PUBLIC;
resize_method.set_cname ("g_renew");
var root_symbol = source_reference.file.context.root;
var int_type = new TypeReference ();
int_type.data_type = (DataType) root_symbol.scope.lookup ("int");
resize_method.add_parameter (new FormalParameter ("length", int_type));
resize_method.returns_modified_pointer = true;
}
return resize_method; return resize_method;
} }
} }
...@@ -26,21 +26,12 @@ using GLib; ...@@ -26,21 +26,12 @@ using GLib;
* Represents the Array.length field. * Represents the Array.length field.
*/ */
public class Vala.ArrayLengthField : Field { public class Vala.ArrayLengthField : Field {
construct {
access = MemberAccessibility.PUBLIC;
var root_symbol = source_reference.file.context.root;
type_reference.data_type = (DataType) root_symbol.scope.lookup ("int");
}
/** /**
* Creates a new array length field. * Creates a new array length field.
* *
* @return newly created field * @return newly created field
*/ */
public ArrayLengthField (SourceReference! source) { public ArrayLengthField (construct SourceReference source_reference) {
name = "length"; name = "length";
type_reference = new TypeReference ();
source_reference = source;
} }
} }
...@@ -26,28 +26,12 @@ using GLib; ...@@ -26,28 +26,12 @@ using GLib;
* Represents the Array.resize method. * Represents the Array.resize method.
*/ */
public class Vala.ArrayResizeMethod : Method { public class Vala.ArrayResizeMethod : Method {
construct {
access = MemberAccessibility.PUBLIC;
set_cname ("g_renew");
var root_symbol = source_reference.file.context.root;
var int_type = new TypeReference ();
int_type.data_type = (DataType) root_symbol.scope.lookup ("int");
add_parameter (new FormalParameter ("length", int_type));
returns_modified_pointer = true;
}
/** /**
* Creates a new array resize method. * Creates a new array resize method.
* *
* @return newly created method * @return newly created method
*/ */
public ArrayResizeMethod (SourceReference! _source_reference) { public ArrayResizeMethod (construct SourceReference source_reference) {
name = "resize"; name = "resize";
return_type = new TypeReference ();
source_reference = _source_reference;
} }
} }
...@@ -29,23 +29,21 @@ public class Vala.Attribute : CodeNode { ...@@ -29,23 +29,21 @@ public class Vala.Attribute : CodeNode {
/** /**
* The name of the attribute type. * The name of the attribute type.
*/ */
public string! name { get; set construct; } public string! name { get; set; }
/** /**
* Contains all specified attribute arguments. * Contains all specified attribute arguments.
*/ */
public List<NamedArgument> args; public List<NamedArgument> args;
/** /**
* Creates a new attribute. * Creates a new attribute.
* *
* @param name attribute type name * @param name attribute type name
* @param source reference to source code * @param source_reference reference to source code
* @return newly created attribute * @return newly created attribute
*/ */
public Attribute (string! _name, SourceReference source) { public Attribute (construct string! name, construct SourceReference source_reference) {
name = _name;
source_reference = source;
} }
/** /**
......
...@@ -38,7 +38,7 @@ public abstract class Vala.CodeNode { ...@@ -38,7 +38,7 @@ public abstract class Vala.CodeNode {
* References the location in the source file where this code node has * References the location in the source file where this code node has
* been written. * been written.
*/ */
public SourceReference source_reference { get; set construct; } public SourceReference source_reference { get; set; }
/** /**
* Contains all attributes that have been specified for this code node. * Contains all attributes that have been specified for this code node.
......
...@@ -29,7 +29,7 @@ public class Vala.Constant : Member, Lockable { ...@@ -29,7 +29,7 @@ public class Vala.Constant : Member, Lockable {
/** /**
* The data type of this constant. * The data type of this constant.
*/ */
public TypeReference! type_reference { get; set construct; } public TypeReference! type_reference { get; set; }
/** /**
* The value of this constant. * The value of this constant.
...@@ -51,17 +51,13 @@ public class Vala.Constant : Member, Lockable { ...@@ -51,17 +51,13 @@ public class Vala.Constant : Member, Lockable {
/** /**
* Creates a new constant. * Creates a new constant.
* *
* @param name constant name * @param name constant name
* @param type constant type * @param type_reference constant type
* @param init constant value * @param initializer constant value
* @param source reference to source code * @param source_reference reference to source code
* @return newly created constant * @return newly created constant
*/ */
public Constant (string! _name, TypeReference! type, Expression init, SourceReference source) { public Constant (construct string! name, construct TypeReference! type_reference, construct Expression initializer, construct SourceReference source_reference) {
name = _name;
type_reference = type;
initializer = init;
source_reference = source;
} }
public override void accept (CodeVisitor! visitor) { public override void accept (CodeVisitor! visitor) {
......
...@@ -29,7 +29,7 @@ public class Vala.Field : Member, Invokable, Lockable { ...@@ -29,7 +29,7 @@ public class Vala.Field : Member, Invokable, Lockable {
/** /**
* The data type of this field. * The data type of this field.
*/ */
public TypeReference! type_reference { get; set construct; } public TypeReference! type_reference { get; set; }
/** /**
* Specifies the expression to be used to initialize this field. * Specifies the expression to be used to initialize this field.
......
/* valanamespacereference.vala /* valanamespacereference.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 * This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public * modify it under the terms of the GNU Lesser General Public
...@@ -29,7 +29,7 @@ public class Vala.NamespaceReference : CodeNode { ...@@ -29,7 +29,7 @@ public class Vala.NamespaceReference : CodeNode {
/** /**
* The name of the namespace this reference is referring to. * The name of the namespace this reference is referring to.
*/ */
public string! name { get; set construct; } public string! name { get; set; }
/** /**
* The resolved symbol of the namespace this reference is referring to. * The resolved symbol of the namespace this reference is referring to.
...@@ -39,13 +39,11 @@ public class Vala.NamespaceReference : CodeNode { ...@@ -39,13 +39,11 @@ public class Vala.NamespaceReference : CodeNode {
/** /**
* Creates a new namespace reference. * Creates a new namespace reference.
* *
* @param name namespace name * @param name namespace name
* @param source reference to source code * @param source_reference reference to source code
* @return newly created namespace reference * @return newly created namespace reference
*/ */
public NamespaceReference (string! _name, SourceReference source) { public NamespaceReference (construct string! name, construct SourceReference source_reference) {
name = _name;
source_reference = source;
} }
public override void accept (CodeVisitor! visitor) { public override void accept (CodeVisitor! visitor) {
......
...@@ -29,7 +29,7 @@ public class Vala.Signal : Member, Invokable, Lockable { ...@@ -29,7 +29,7 @@ public class Vala.Signal : Member, Invokable, Lockable {
/** /**
* The return type of handlers of this signal. * The return type of handlers of this signal.
*/ */
public TypeReference! return_type { get; set construct; } public TypeReference! return_type { get; set; }
/** /**
* Specifies the accessibility of the signal. Currently only public * Specifies the accessibility of the signal. Currently only public
......
...@@ -29,7 +29,7 @@ public class Vala.SourceFile { ...@@ -29,7 +29,7 @@ public class Vala.SourceFile {
/** /**
* The name of this source file. * The name of this source file.
*/ */
public string! filename { get; set construct; } public string! filename { get; set; }
/** /**
* The header comment of this source file. * The header comment of this source file.
......
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