vala r1259 - in trunk: . gobject vala
- From: juergbi svn gnome org
- To: svn-commits-list gnome org
- Subject: vala r1259 - in trunk: . gobject vala
- Date: Sat, 19 Apr 2008 06:34:21 +0100 (BST)
Author: juergbi
Date: Sat Apr 19 05:34:20 2008
New Revision: 1259
URL: http://svn.gnome.org/viewvc/vala?rev=1259&view=rev
Log:
2008-04-19 Juerg Billeter <j bitron ch>
* vala/valaarraycreationexpression.vala, vala/valaassignment.vala,
vala/valacodebinding.vala, vala/valacodecontext.vala,
vala/valacodenode.vala, vala/valaelementaccess.vala,
vala/valamethod.vala, vala/valaparser.vala,
vala/valasemanticanalyzer.vala,
gobject/valaccodearraycreationexpressionbinding.vala,
gobject/valaccodeassignmentbinding.vala,
gobject/valaccodebinding.vala,
gobject/valaccodeelementaccessbinding.vala,
gobject/valaccodegenerator.vala,
gobject/valaccodegeneratormemberaccess.vala,
gobject/valaccodemethodbinding.vala,
gobject/valadbusbindingprovider.vala:
Use lazy initialization for code bindings
Modified:
trunk/ChangeLog
trunk/gobject/valaccodearraycreationexpressionbinding.vala
trunk/gobject/valaccodeassignmentbinding.vala
trunk/gobject/valaccodebinding.vala
trunk/gobject/valaccodeelementaccessbinding.vala
trunk/gobject/valaccodegenerator.vala
trunk/gobject/valaccodegeneratormemberaccess.vala
trunk/gobject/valaccodemethodbinding.vala
trunk/gobject/valadbusbindingprovider.vala
trunk/vala/valaarraycreationexpression.vala
trunk/vala/valaassignment.vala
trunk/vala/valacodebinding.vala
trunk/vala/valacodecontext.vala
trunk/vala/valacodenode.vala
trunk/vala/valaelementaccess.vala
trunk/vala/valamethod.vala
trunk/vala/valaparser.vala
trunk/vala/valasemanticanalyzer.vala
Modified: trunk/gobject/valaccodearraycreationexpressionbinding.vala
==============================================================================
--- trunk/gobject/valaccodearraycreationexpressionbinding.vala (original)
+++ trunk/gobject/valaccodearraycreationexpressionbinding.vala Sat Apr 19 05:34:20 2008
@@ -30,7 +30,7 @@
public class Vala.CCodeArrayCreationExpressionBinding : CCodeExpressionBinding {
public ArrayCreationExpression array_creation_expression { get; set; }
- public CCodeArrayCreationExpressionBinding (CodeGenerator codegen, ArrayCreationExpression array_creation_expression) {
+ public CCodeArrayCreationExpressionBinding (CCodeGenerator codegen, ArrayCreationExpression array_creation_expression) {
this.array_creation_expression = array_creation_expression;
this.codegen = codegen;
}
Modified: trunk/gobject/valaccodeassignmentbinding.vala
==============================================================================
--- trunk/gobject/valaccodeassignmentbinding.vala (original)
+++ trunk/gobject/valaccodeassignmentbinding.vala Sat Apr 19 05:34:20 2008
@@ -30,7 +30,7 @@
public class Vala.CCodeAssignmentBinding : CCodeExpressionBinding {
public Assignment assignment { get; set; }
- public CCodeAssignmentBinding (CodeGenerator codegen, Assignment assignment) {
+ public CCodeAssignmentBinding (CCodeGenerator codegen, Assignment assignment) {
this.assignment = assignment;
this.codegen = codegen;
}
Modified: trunk/gobject/valaccodebinding.vala
==============================================================================
--- trunk/gobject/valaccodebinding.vala (original)
+++ trunk/gobject/valaccodebinding.vala Sat Apr 19 05:34:20 2008
@@ -1,6 +1,6 @@
/* valaccodebinding.vala
*
- * Copyright (C) 2007 JÃrg Billeter
+ * Copyright (C) 2007-2008 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
@@ -30,4 +30,29 @@
* The C Code generator.
*/
public CCodeGenerator codegen { get; set; }
+
+ /**
+ * Generate code for this source code node.
+ */
+ public abstract void emit ();
+
+ public CCodeBinding? code_binding (CodeNode node) {
+ return (CCodeBinding) node.get_code_binding (codegen);
+ }
+
+ public CCodeMethodBinding method_binding (Method node) {
+ return (CCodeMethodBinding) node.get_code_binding (codegen);
+ }
+
+ public CCodeArrayCreationExpressionBinding array_creation_expression_binding (ArrayCreationExpression node) {
+ return (CCodeArrayCreationExpressionBinding) node.get_code_binding (codegen);
+ }
+
+ public CCodeElementAccessBinding element_access_binding (ElementAccess node) {
+ return (CCodeElementAccessBinding) node.get_code_binding (codegen);
+ }
+
+ public CCodeAssignmentBinding assignment_binding (Assignment node) {
+ return (CCodeAssignmentBinding) node.get_code_binding (codegen);
+ }
}
Modified: trunk/gobject/valaccodeelementaccessbinding.vala
==============================================================================
--- trunk/gobject/valaccodeelementaccessbinding.vala (original)
+++ trunk/gobject/valaccodeelementaccessbinding.vala Sat Apr 19 05:34:20 2008
@@ -30,7 +30,7 @@
public class Vala.CCodeElementAccessBinding : CCodeExpressionBinding {
public ElementAccess element_access { get; set; }
- public CCodeElementAccessBinding (CodeGenerator codegen, ElementAccess element_access) {
+ public CCodeElementAccessBinding (CCodeGenerator codegen, ElementAccess element_access) {
this.element_access = element_access;
this.codegen = codegen;
}
Modified: trunk/gobject/valaccodegenerator.vala
==============================================================================
--- trunk/gobject/valaccodegenerator.vala (original)
+++ trunk/gobject/valaccodegenerator.vala Sat Apr 19 05:34:20 2008
@@ -2321,7 +2321,7 @@
}
public override void visit_array_creation_expression (ArrayCreationExpression expr) {
- expr.code_binding.emit ();
+ code_binding (expr).emit ();
}
public override void visit_boolean_literal (BooleanLiteral expr) {
@@ -2624,7 +2624,7 @@
}
public override void visit_element_access (ElementAccess expr) {
- expr.code_binding.emit ();
+ code_binding (expr).emit ();
}
public override void visit_base_access (BaseAccess expr) {
@@ -3451,7 +3451,7 @@
}
public override void visit_assignment (Assignment a) {
- a.code_binding.emit ();
+ code_binding (a).emit ();
}
public CCodeFunctionCall get_property_set_call (Property prop, MemberAccess ma, CCodeExpression cexpr) {
@@ -3844,4 +3844,24 @@
public override CodeBinding? create_assignment_binding (Assignment node) {
return new CCodeAssignmentBinding (this, node);
}
+
+ public CCodeBinding? code_binding (CodeNode node) {
+ return (CCodeBinding) node.get_code_binding (this);
+ }
+
+ public CCodeMethodBinding method_binding (Method node) {
+ return (CCodeMethodBinding) node.get_code_binding (this);
+ }
+
+ public CCodeArrayCreationExpressionBinding array_creation_expression_binding (ArrayCreationExpression node) {
+ return (CCodeArrayCreationExpressionBinding) node.get_code_binding (this);
+ }
+
+ public CCodeElementAccessBinding element_access_binding (ElementAccess node) {
+ return (CCodeElementAccessBinding) node.get_code_binding (this);
+ }
+
+ public CCodeAssignmentBinding assignment_binding (Assignment node) {
+ return (CCodeAssignmentBinding) node.get_code_binding (this);
+ }
}
Modified: trunk/gobject/valaccodegeneratormemberaccess.vala
==============================================================================
--- trunk/gobject/valaccodegeneratormemberaccess.vala (original)
+++ trunk/gobject/valaccodegeneratormemberaccess.vala Sat Apr 19 05:34:20 2008
@@ -46,7 +46,7 @@
}
if (m.base_method != null) {
- var binding = CCodeMethodBinding.get (m.base_method);
+ var binding = method_binding (m.base_method);
if (!binding.has_wrapper) {
var inst = pub_inst;
if (expr.inner != null && !expr.inner.is_pure ()) {
Modified: trunk/gobject/valaccodemethodbinding.vala
==============================================================================
--- trunk/gobject/valaccodemethodbinding.vala (original)
+++ trunk/gobject/valaccodemethodbinding.vala Sat Apr 19 05:34:20 2008
@@ -1,6 +1,6 @@
/* valaccodemethodbinding.vala
*
- * Copyright (C) 2007 JÃrg Billeter
+ * Copyright (C) 2007-2008 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
@@ -33,15 +33,11 @@
get { return (method.get_attribute ("NoWrapper") == null); }
}
- public CCodeMethodBinding (CodeGenerator codegen, Method method) {
+ public CCodeMethodBinding (CCodeGenerator codegen, Method method) {
this.method = method;
this.codegen = codegen;
}
- public static CCodeMethodBinding get (Method method) {
- return (CCodeMethodBinding) method.code_binding;
- }
-
public override void emit () {
}
}
Modified: trunk/gobject/valadbusbindingprovider.vala
==============================================================================
--- trunk/gobject/valadbusbindingprovider.vala (original)
+++ trunk/gobject/valadbusbindingprovider.vala Sat Apr 19 05:34:20 2008
@@ -63,13 +63,13 @@
if (!is_dbus_interface (ret_type)) {
return null;
}
- var m = _context.create_method ("get_object", ret_type, ma.source_reference);
+ var m = new Method ("get_object", ret_type, ma.source_reference);
m.set_cname ("dbus_g_proxy_new_for_name");
m.add_cheader_filename ("dbus/dbus-glib.h");
m.access = SymbolAccessibility.PUBLIC;
var string_type_ref = new ClassType (string_type);
- m.add_parameter (_context.create_formal_parameter ("name", string_type_ref));
- m.add_parameter (_context.create_formal_parameter ("path", string_type_ref));
+ m.add_parameter (new FormalParameter ("name", string_type_ref));
+ m.add_parameter (new FormalParameter ("path", string_type_ref));
symbols.add (m);
return m;
} else if (ma.inner != null && ma.inner.static_type != null && is_dbus_interface (ma.inner.static_type)) {
Modified: trunk/vala/valaarraycreationexpression.vala
==============================================================================
--- trunk/vala/valaarraycreationexpression.vala (original)
+++ trunk/vala/valaarraycreationexpression.vala Sat Apr 19 05:34:20 2008
@@ -104,4 +104,8 @@
element_type = new_type;
}
}
+
+ public override CodeBinding? create_code_binding (CodeGenerator codegen) {
+ return codegen.create_array_creation_expression_binding (this);
+ }
}
Modified: trunk/vala/valaassignment.vala
==============================================================================
--- trunk/vala/valaassignment.vala (original)
+++ trunk/vala/valaassignment.vala Sat Apr 19 05:34:20 2008
@@ -95,6 +95,10 @@
public override bool is_pure () {
return false;
}
+
+ public override CodeBinding? create_code_binding (CodeGenerator codegen) {
+ return codegen.create_assignment_binding (this);
+ }
}
public enum Vala.AssignmentOperator {
Modified: trunk/vala/valacodebinding.vala
==============================================================================
--- trunk/vala/valacodebinding.vala (original)
+++ trunk/vala/valacodebinding.vala Sat Apr 19 05:34:20 2008
@@ -1,6 +1,6 @@
/* valacodebinding.vala
*
- * Copyright (C) 2007 JÃrg Billeter
+ * Copyright (C) 2007-2008 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
@@ -26,8 +26,4 @@
* The link between a source code node and generated code.
*/
public abstract class Vala.CodeBinding : Object {
- /**
- * Generate code for this source code node.
- */
- public abstract void emit ();
}
Modified: trunk/vala/valacodecontext.vala
==============================================================================
--- trunk/vala/valacodecontext.vala (original)
+++ trunk/vala/valacodecontext.vala Sat Apr 19 05:34:20 2008
@@ -408,454 +408,4 @@
return null;
}
-
- public Namespace create_namespace (string name, SourceReference? source_reference = null) {
- var node = new Namespace (name, source_reference);
- node.code_binding = codegen.create_namespace_binding (node);
- return node;
- }
-
- public Class create_class (string name, SourceReference? source_reference = null) {
- var node = new Class (name, source_reference);
- node.code_binding = codegen.create_class_binding (node);
- return node;
- }
-
- public Struct create_struct (string name, SourceReference? source_reference = null) {
- var node = new Struct (name, source_reference);
- node.code_binding = codegen.create_struct_binding (node);
- return node;
- }
-
- public Interface create_interface (string name, SourceReference? source_reference = null) {
- var node = new Interface (name, source_reference);
- node.code_binding = codegen.create_interface_binding (node);
- return node;
- }
-
- public Enum create_enum (string name, SourceReference? source_reference = null) {
- var node = new Enum (name, source_reference);
- node.code_binding = codegen.create_enum_binding (node);
- return node;
- }
-
- public EnumValue create_enum_value (string name, SourceReference? source_reference = null) {
- var node = new EnumValue (name, source_reference);
- node.code_binding = codegen.create_enum_value_binding (node);
- return node;
- }
-
- public EnumValue create_enum_value_with_value (string name, Expression? value, SourceReference? source_reference = null) {
- var node = new EnumValue.with_value (name, value, source_reference);
- node.code_binding = codegen.create_enum_value_binding (node);
- return node;
- }
-
- public ErrorDomain create_error_domain (string name, SourceReference? source_reference = null) {
- var node = new ErrorDomain (name, source_reference);
- node.code_binding = codegen.create_error_domain_binding (node);
- return node;
- }
-
- public ErrorCode create_error_code (string name) {
- var node = new ErrorCode (name);
- node.code_binding = codegen.create_error_code_binding (node);
- return node;
- }
-
- public ErrorCode create_error_code_with_value (string name, Expression? value) {
- var node = new ErrorCode.with_value (name, value);
- node.code_binding = codegen.create_error_code_binding (node);
- return node;
- }
-
- public Delegate create_delegate (string? name, DataType return_type, SourceReference? source_reference = null) {
- var node = new Delegate (name, return_type, source_reference);
- node.code_binding = codegen.create_delegate_binding (node);
- return node;
- }
-
- public Constant create_constant (string name, DataType type_reference, Expression? initializer, SourceReference? source_reference) {
- var node = new Constant (name, type_reference, initializer, source_reference);
- node.code_binding = codegen.create_constant_binding (node);
- return node;
- }
-
- public Field create_field (string name, DataType type_reference, Expression? initializer, SourceReference? source_reference = null) {
- var node = new Field (name, type_reference, initializer, source_reference);
- node.code_binding = codegen.create_field_binding (node);
- return node;
- }
-
- public Method create_method (string name, DataType return_type, SourceReference? source_reference = null) {
- var node = new Method (name, return_type, source_reference);
- node.code_binding = codegen.create_method_binding (node);
- return node;
- }
-
- public CreationMethod create_creation_method (string type_name, string? name, SourceReference? source_reference = null) {
- var node = new CreationMethod (type_name, name, source_reference);
- node.code_binding = codegen.create_creation_method_binding (node);
- return node;
- }
-
- public FormalParameter create_formal_parameter (string name, DataType type_reference, SourceReference? source_reference = null) {
- var node = new FormalParameter (name, type_reference, source_reference);
- node.code_binding = codegen.create_formal_parameter_binding (node);
- return node;
- }
-
- public FormalParameter create_formal_parameter_with_ellipsis (SourceReference? source_reference = null) {
- var node = new FormalParameter.with_ellipsis (source_reference);
- node.code_binding = codegen.create_formal_parameter_binding (node);
- return node;
- }
-
- public Property create_property (string name, DataType type_reference, PropertyAccessor? get_accessor, PropertyAccessor? set_accessor, SourceReference? source_reference) {
- var node = new Property (name, type_reference, get_accessor, set_accessor, source_reference);
- node.code_binding = codegen.create_property_binding (node);
- return node;
- }
-
- public PropertyAccessor create_property_accessor (bool readable, bool writable, bool construction, Block? body, SourceReference? source_reference) {
- var node = new PropertyAccessor (readable, writable, construction, body, source_reference);
- node.code_binding = codegen.create_property_accessor_binding (node);
- return node;
- }
-
- public Signal create_signal (string name, DataType return_type, SourceReference? source_reference = null) {
- var node = new Signal (name, return_type, source_reference);
- node.code_binding = codegen.create_signal_binding (node);
- return node;
- }
-
- public Constructor create_constructor (SourceReference? source_reference) {
- var node = new Constructor (source_reference);
- node.code_binding = codegen.create_constructor_binding (node);
- return node;
- }
-
- public Destructor create_destructor (SourceReference? source_reference = null) {
- var node = new Destructor (source_reference);
- node.code_binding = codegen.create_destructor_binding (node);
- return node;
- }
-
- public TypeParameter create_type_parameter (string name, SourceReference? source_reference) {
- var node = new TypeParameter (name, source_reference);
- node.code_binding = codegen.create_type_parameter_binding (node);
- return node;
- }
-
- public Block create_block (SourceReference? source_reference = null) {
- var node = new Block (source_reference);
- node.code_binding = codegen.create_block_binding (node);
- return node;
- }
-
- public EmptyStatement create_empty_statement (SourceReference? source_reference = null) {
- var node = new EmptyStatement (source_reference);
- node.code_binding = codegen.create_empty_statement_binding (node);
- return node;
- }
-
- public DeclarationStatement create_declaration_statement (Symbol declaration, SourceReference? source_reference) {
- var node = new DeclarationStatement (declaration, source_reference);
- node.code_binding = codegen.create_declaration_statement_binding (node);
- return node;
- }
-
- public LocalVariable create_local_variable (DataType? variable_type, string name, Expression? initializer = null, SourceReference? source_reference = null) {
- var node = new LocalVariable (variable_type, name, initializer, source_reference);
- node.code_binding = codegen.create_local_variable_binding (node);
- return node;
- }
-
- public InitializerList create_initializer_list (SourceReference? source_reference) {
- var node = new InitializerList (source_reference);
- node.code_binding = codegen.create_initializer_list_binding (node);
- return node;
- }
-
- public ExpressionStatement create_expression_statement (Expression expression, SourceReference? source_reference = null) {
- var node = new ExpressionStatement (expression, source_reference);
- node.code_binding = codegen.create_expression_statement_binding (node);
- return node;
- }
-
- public IfStatement create_if_statement (Expression condition, Block true_statement, Block? false_statement, SourceReference? source_reference) {
- var node = new IfStatement (condition, true_statement, false_statement, source_reference);
- node.code_binding = codegen.create_if_statement_binding (node);
- return node;
- }
-
- public SwitchStatement create_switch_statement (Expression expression, SourceReference? source_reference) {
- var node = new SwitchStatement (expression, source_reference);
- node.code_binding = codegen.create_switch_statement_binding (node);
- return node;
- }
-
- public SwitchSection create_switch_section (SourceReference? source_reference) {
- var node = new SwitchSection (source_reference);
- node.code_binding = codegen.create_switch_section_binding (node);
- return node;
- }
-
- public SwitchLabel create_switch_label (Expression expression, SourceReference? source_reference = null) {
- var node = new SwitchLabel (expression, source_reference);
- node.code_binding = codegen.create_switch_label_binding (node);
- return node;
- }
-
- public SwitchLabel create_switch_label_with_default (SourceReference? source_reference = null) {
- var node = new SwitchLabel.with_default (source_reference);
- node.code_binding = codegen.create_switch_label_binding (node);
- return node;
- }
-
- public WhileStatement create_while_statement (Expression condition, Block body, SourceReference? source_reference = null) {
- var node = new WhileStatement (condition, body, source_reference);
- node.code_binding = codegen.create_while_statement_binding (node);
- return node;
- }
-
- public DoStatement create_do_statement (Block body, Expression condition, SourceReference? source_reference = null) {
- var node = new DoStatement (body, condition, source_reference);
- node.code_binding = codegen.create_do_statement_binding (node);
- return node;
- }
-
- public ForStatement create_for_statement (Expression condition, Block body, SourceReference? source_reference = null) {
- var node = new ForStatement (condition, body, source_reference);
- node.code_binding = codegen.create_for_statement_binding (node);
- return node;
- }
-
- public ForeachStatement create_foreach_statement (DataType type_reference, string variable_name, Expression collection, Block body, SourceReference? source_reference) {
- var node = new ForeachStatement (type_reference, variable_name, collection, body, source_reference);
- node.code_binding = codegen.create_foreach_statement_binding (node);
- return node;
- }
-
- public BreakStatement create_break_statement (SourceReference? source_reference) {
- var node = new BreakStatement (source_reference);
- node.code_binding = codegen.create_break_statement_binding (node);
- return node;
- }
-
- public ContinueStatement create_continue_statement (SourceReference? source_reference) {
- var node = new ContinueStatement (source_reference);
- node.code_binding = codegen.create_continue_statement_binding (node);
- return node;
- }
-
- public ReturnStatement create_return_statement (Expression? return_expression = null, SourceReference? source_reference = null) {
- var node = new ReturnStatement (return_expression, source_reference);
- node.code_binding = codegen.create_return_statement_binding (node);
- return node;
- }
-
- public ThrowStatement create_throw_statement (Expression error_expression, SourceReference? source_reference = null) {
- var node = new ThrowStatement (error_expression, source_reference);
- node.code_binding = codegen.create_throw_statement_binding (node);
- return node;
- }
-
- public TryStatement create_try_statement (Block body, Block? finally_body, SourceReference? source_reference = null) {
- var node = new TryStatement (body, finally_body, source_reference);
- node.code_binding = codegen.create_try_statement_binding (node);
- return node;
- }
-
- public CatchClause create_catch_clause (DataType type_reference, string variable_name, Block body, SourceReference? source_reference = null) {
- var node = new CatchClause (type_reference, variable_name, body, source_reference);
- node.code_binding = codegen.create_catch_clause_binding (node);
- return node;
- }
-
- public LockStatement create_lock_statement (Expression resource, Block body, SourceReference? source_reference = null) {
- var node = new LockStatement (resource, body, source_reference);
- node.code_binding = codegen.create_lock_statement_binding (node);
- return node;
- }
-
- public DeleteStatement create_delete_statement (Expression expression, SourceReference? source_reference = null) {
- var node = new DeleteStatement (expression, source_reference);
- node.code_binding = codegen.create_delete_statement_binding (node);
- return node;
- }
-
- public ArrayCreationExpression create_array_creation_expression (DataType element_type, int rank, InitializerList? initializer_list, SourceReference? source_reference) {
- var node = new ArrayCreationExpression (element_type, rank, initializer_list, source_reference);
- node.code_binding = codegen.create_array_creation_expression_binding (node);
- return node;
- }
-
- public BooleanLiteral create_boolean_literal (bool value, SourceReference? source_reference) {
- var node = new BooleanLiteral (value, source_reference);
- node.code_binding = codegen.create_boolean_literal_binding (node);
- return node;
- }
-
- public CharacterLiteral create_character_literal (string value, SourceReference? source_reference) {
- var node = new CharacterLiteral (value, source_reference);
- node.code_binding = codegen.create_character_literal_binding (node);
- return node;
- }
-
- public IntegerLiteral create_integer_literal (string value, SourceReference? source_reference = null) {
- var node = new IntegerLiteral (value, source_reference);
- node.code_binding = codegen.create_integer_literal_binding (node);
- return node;
- }
-
- public RealLiteral create_real_literal (string value, SourceReference? source_reference) {
- var node = new RealLiteral (value, source_reference);
- node.code_binding = codegen.create_real_literal_binding (node);
- return node;
- }
-
- public StringLiteral create_string_literal (string value, SourceReference? source_reference) {
- var node = new StringLiteral (value, source_reference);
- node.code_binding = codegen.create_string_literal_binding (node);
- return node;
- }
-
- public NullLiteral create_null_literal (SourceReference? source_reference = null) {
- var node = new NullLiteral (source_reference);
- node.code_binding = codegen.create_null_literal_binding (node);
- return node;
- }
-
- public ParenthesizedExpression create_parenthesized_expression (Expression inner, SourceReference? source_reference) {
- var node = new ParenthesizedExpression (inner, source_reference);
- node.code_binding = codegen.create_parenthesized_expression_binding (node);
- return node;
- }
-
- public MemberAccess create_member_access (Expression? inner, string member_name, SourceReference? source_reference = null) {
- var node = new MemberAccess (inner, member_name, source_reference);
- node.code_binding = codegen.create_member_access_binding (node);
- return node;
- }
-
- public MemberAccess create_member_access_simple (string member_name, SourceReference? source_reference = null) {
- var node = new MemberAccess.simple (member_name, source_reference);
- node.code_binding = codegen.create_member_access_binding (node);
- return node;
- }
-
- public MemberAccess create_member_access_pointer (Expression inner, string member_name, SourceReference? source_reference = null) {
- var node = new MemberAccess.pointer (inner, member_name, source_reference);
- node.code_binding = codegen.create_member_access_binding (node);
- return node;
- }
-
- public InvocationExpression create_invocation_expression (Expression call, SourceReference? source_reference = null) {
- var node = new InvocationExpression (call, source_reference);
- node.code_binding = codegen.create_invocation_expression_binding (node);
- return node;
- }
-
- public ElementAccess create_element_access (Expression container, SourceReference? source_reference) {
- var node = new ElementAccess (container, source_reference);
- node.code_binding = codegen.create_element_access_binding (node);
- return node;
- }
-
- public BaseAccess create_base_access (SourceReference? source_reference = null) {
- var node = new BaseAccess (source_reference);
- node.code_binding = codegen.create_base_access_binding (node);
- return node;
- }
-
- public PostfixExpression create_postfix_expression (Expression inner, bool increment, SourceReference? source_reference) {
- var node = new PostfixExpression (inner, increment, source_reference);
- node.code_binding = codegen.create_postfix_expression_binding (node);
- return node;
- }
-
- public ObjectCreationExpression create_object_creation_expression (MemberAccess member_name, SourceReference? source_reference) {
- var node = new ObjectCreationExpression (member_name, source_reference);
- node.code_binding = codegen.create_object_creation_expression_binding (node);
- return node;
- }
-
- public SizeofExpression create_sizeof_expression (DataType type_reference, SourceReference? source_reference) {
- var node = new SizeofExpression (type_reference, source_reference);
- node.code_binding = codegen.create_sizeof_expression_binding (node);
- return node;
- }
-
- public TypeofExpression create_typeof_expression (DataType type_reference, SourceReference? source_reference) {
- var node = new TypeofExpression (type_reference, source_reference);
- node.code_binding = codegen.create_typeof_expression_binding (node);
- return node;
- }
-
- public UnaryExpression create_unary_expression (UnaryOperator operator, Expression inner, SourceReference? source_reference) {
- var node = new UnaryExpression (operator, inner, source_reference);
- node.code_binding = codegen.create_unary_expression_binding (node);
- return node;
- }
-
- public CastExpression create_cast_expression (Expression inner, DataType type_reference, SourceReference? source_reference, bool is_silent_cast) {
- var node = new CastExpression (inner, type_reference, source_reference, is_silent_cast);
- node.code_binding = codegen.create_cast_expression_binding (node);
- return node;
- }
-
- public PointerIndirection create_pointer_indirection (Expression inner, SourceReference? source_reference = null) {
- var node = new PointerIndirection (inner, source_reference);
- node.code_binding = codegen.create_pointer_indirection_binding (node);
- return node;
- }
-
- public AddressofExpression create_addressof_expression (Expression inner, SourceReference? source_reference = null) {
- var node = new AddressofExpression (inner, source_reference);
- node.code_binding = codegen.create_addressof_expression_binding (node);
- return node;
- }
-
- public ReferenceTransferExpression create_reference_transfer_expression (Expression inner, SourceReference? source_reference = null) {
- var node = new ReferenceTransferExpression (inner, source_reference);
- node.code_binding = codegen.create_reference_transfer_expression_binding (node);
- return node;
- }
-
- public BinaryExpression create_binary_expression (BinaryOperator operator, Expression left, Expression right, SourceReference? source_reference = null) {
- var node = new BinaryExpression (operator, left, right, source_reference);
- node.code_binding = codegen.create_binary_expression_binding (node);
- return node;
- }
-
- public TypeCheck create_type_check (Expression expression, DataType type_reference, SourceReference? source_reference) {
- var node = new TypeCheck (expression, type_reference, source_reference);
- node.code_binding = codegen.create_type_check_binding (node);
- return node;
- }
-
- public ConditionalExpression create_conditional_expression (Expression condition, Expression true_expression, Expression false_expression, SourceReference? source_reference) {
- var node = new ConditionalExpression (condition, true_expression, false_expression, source_reference);
- node.code_binding = codegen.create_conditional_expression_binding (node);
- return node;
- }
-
- public LambdaExpression create_lambda_expression (Expression expression_body, SourceReference? source_reference) {
- var node = new LambdaExpression (expression_body, source_reference);
- node.code_binding = codegen.create_lambda_expression_binding (node);
- return node;
- }
-
- public LambdaExpression create_lambda_expression_with_statement_body (Block statement_body, SourceReference? source_reference) {
- var node = new LambdaExpression.with_statement_body (statement_body, source_reference);
- node.code_binding = codegen.create_lambda_expression_binding (node);
- return node;
- }
-
- public Assignment create_assignment (Expression left, Expression right, AssignmentOperator operator = AssignmentOperator.SIMPLE, SourceReference? source_reference = null) {
- var node = new Assignment (left, right, operator, source_reference);
- node.code_binding = codegen.create_assignment_binding (node);
- return node;
- }
}
Modified: trunk/vala/valacodenode.vala
==============================================================================
--- trunk/vala/valacodenode.vala (original)
+++ trunk/vala/valacodenode.vala Sat Apr 19 05:34:20 2008
@@ -64,11 +64,6 @@
}
/**
- * Binding to the generated code.
- */
- public CodeBinding? code_binding { get; set; }
-
- /**
* Specifies whether a fatal error has been detected in this code node.
*/
public bool error { get; set; }
@@ -116,7 +111,8 @@
return null;
}
-
+
+ private CodeBinding? code_binding;
private CCodeNode? _ccodenode;
/**
@@ -135,4 +131,23 @@
return str.append (" */").str;
}
+
+ /**
+ * Returns the binding to the generated code.
+ *
+ * @return code binding
+ */
+ public CodeBinding? get_code_binding (CodeGenerator codegen) {
+ if (code_binding == null) {
+ code_binding = create_code_binding (codegen);
+ }
+ return code_binding;
+ }
+
+ /**
+ * Creates the binding to the generated code.
+ */
+ public virtual CodeBinding? create_code_binding (CodeGenerator codegen) {
+ return null;
+ }
}
Modified: trunk/vala/valaelementaccess.vala
==============================================================================
--- trunk/vala/valaelementaccess.vala (original)
+++ trunk/vala/valaelementaccess.vala Sat Apr 19 05:34:20 2008
@@ -81,4 +81,8 @@
}
return container.is_pure ();
}
+
+ public override CodeBinding? create_code_binding (CodeGenerator codegen) {
+ return codegen.create_element_access_binding (this);
+ }
}
Modified: trunk/vala/valamethod.vala
==============================================================================
--- trunk/vala/valamethod.vala (original)
+++ trunk/vala/valamethod.vala Sat Apr 19 05:34:20 2008
@@ -504,4 +504,8 @@
}
}
}
+
+ public override CodeBinding? create_code_binding (CodeGenerator codegen) {
+ return codegen.create_method_binding (this);
+ }
}
Modified: trunk/vala/valaparser.vala
==============================================================================
--- trunk/vala/valaparser.vala (original)
+++ trunk/vala/valaparser.vala Sat Apr 19 05:34:20 2008
@@ -246,25 +246,25 @@
switch (current ()) {
case TokenType.TRUE:
next ();
- return context.create_boolean_literal (true, get_src (begin));
+ return new BooleanLiteral (true, get_src (begin));
case TokenType.FALSE:
next ();
- return context.create_boolean_literal (false, get_src (begin));
+ return new BooleanLiteral (false, get_src (begin));
case TokenType.INTEGER_LITERAL:
next ();
- return context.create_integer_literal (get_last_string (), get_src (begin));
+ return new IntegerLiteral (get_last_string (), get_src (begin));
case TokenType.REAL_LITERAL:
next ();
- return context.create_real_literal (get_last_string (), get_src (begin));
+ return new RealLiteral (get_last_string (), get_src (begin));
case TokenType.CHARACTER_LITERAL:
next ();
- return context.create_character_literal (get_last_string (), get_src (begin));
+ return new CharacterLiteral (get_last_string (), get_src (begin));
case TokenType.STRING_LITERAL:
next ();
- return context.create_string_literal (get_last_string (), get_src (begin));
+ return new StringLiteral (get_last_string (), get_src (begin));
case TokenType.NULL:
next ();
- return context.create_null_literal (get_src (begin));
+ return new NullLiteral (get_src (begin));
}
throw new ParseError.SYNTAX (get_error ("expected literal"));
@@ -482,7 +482,7 @@
var begin = get_location ();
string id = parse_identifier ();
Gee.List<DataType> type_arg_list = parse_type_argument_list (true);
- var expr = context.create_member_access (null, id, get_src (begin));
+ var expr = new MemberAccess (null, id, get_src (begin));
if (type_arg_list != null) {
foreach (DataType type_arg in type_arg_list) {
expr.add_type_argument (type_arg);
@@ -508,14 +508,14 @@
}
return tuple;
}
- return context.create_parenthesized_expression (expr_list.get (0), get_src (begin));
+ return new ParenthesizedExpression (expr_list.get (0), get_src (begin));
}
Expression parse_member_access (SourceLocation begin, Expression inner) throws ParseError {
expect (TokenType.DOT);
string id = parse_identifier ();
Gee.List<DataType> type_arg_list = parse_type_argument_list (true);
- var expr = context.create_member_access (inner, id, get_src (begin));
+ var expr = new MemberAccess (inner, id, get_src (begin));
if (type_arg_list != null) {
foreach (DataType type_arg in type_arg_list) {
expr.add_type_argument (type_arg);
@@ -528,7 +528,7 @@
expect (TokenType.OP_PTR);
string id = parse_identifier ();
Gee.List<DataType> type_arg_list = parse_type_argument_list (true);
- var expr = context.create_member_access_pointer (inner, id, get_src (begin));
+ var expr = new MemberAccess.pointer (inner, id, get_src (begin));
if (type_arg_list != null) {
foreach (DataType type_arg in type_arg_list) {
expr.add_type_argument (type_arg);
@@ -548,7 +548,7 @@
var member = (MemberAccess) inner;
member.creation_member = true;
- var expr = context.create_object_creation_expression (member, get_src (begin));
+ var expr = new ObjectCreationExpression (member, get_src (begin));
expr.struct_creation = true;
foreach (Expression arg in arg_list) {
expr.add_argument (arg);
@@ -558,7 +558,7 @@
}
return expr;
} else {
- var expr = context.create_invocation_expression (inner, get_src (begin));
+ var expr = new InvocationExpression (inner, get_src (begin));
foreach (Expression arg in arg_list) {
expr.add_argument (arg);
}
@@ -571,7 +571,7 @@
var index_list = parse_expression_list ();
expect (TokenType.CLOSE_BRACKET);
- var expr = context.create_element_access (inner, get_src (begin));
+ var expr = new ElementAccess (inner, get_src (begin));
foreach (Expression index in index_list) {
expr.append_index (index);
}
@@ -589,23 +589,23 @@
Expression parse_this_access () throws ParseError {
var begin = get_location ();
expect (TokenType.THIS);
- return context.create_member_access (null, "this", get_src (begin));
+ return new MemberAccess (null, "this", get_src (begin));
}
Expression parse_base_access () throws ParseError {
var begin = get_location ();
expect (TokenType.BASE);
- return context.create_base_access (get_src (begin));
+ return new BaseAccess (get_src (begin));
}
Expression parse_post_increment_expression (SourceLocation begin, Expression inner) throws ParseError {
expect (TokenType.OP_INC);
- return context.create_postfix_expression (inner, true, get_src (begin));
+ return new PostfixExpression (inner, true, get_src (begin));
}
Expression parse_post_decrement_expression (SourceLocation begin, Expression inner) throws ParseError {
expect (TokenType.OP_DEC);
- return context.create_postfix_expression (inner, false, get_src (begin));
+ return new PostfixExpression (inner, false, get_src (begin));
}
Expression parse_object_or_array_creation_expression () throws ParseError {
@@ -629,7 +629,7 @@
expect (TokenType.CLOSE_PARENS);
var init_list = parse_object_initializer ();
- var expr = context.create_object_creation_expression (member, get_src (begin));
+ var expr = new ObjectCreationExpression (member, get_src (begin));
foreach (Expression arg in arg_list) {
expr.add_argument (arg);
}
@@ -655,7 +655,7 @@
if (current () == TokenType.OPEN_BRACE) {
initializer = parse_initializer ();
}
- var expr = context.create_array_creation_expression (UnresolvedType.new_from_expression (member), size_specifier_list.size, initializer, get_src (begin));
+ var expr = new ArrayCreationExpression (UnresolvedType.new_from_expression (member), size_specifier_list.size, initializer, get_src (begin));
if (size_specified) {
foreach (Expression size in size_specifier_list) {
expr.append_size (size);
@@ -691,7 +691,7 @@
var type = parse_type ();
expect (TokenType.CLOSE_PARENS);
- return context.create_sizeof_expression (type, get_src (begin));
+ return new SizeofExpression (type, get_src (begin));
}
Expression parse_typeof_expression () throws ParseError {
@@ -701,7 +701,7 @@
var type = parse_type ();
expect (TokenType.CLOSE_PARENS);
- return context.create_typeof_expression (type, get_src (begin));
+ return new TypeofExpression (type, get_src (begin));
}
UnaryOperator get_unary_operator (TokenType token_type) {
@@ -724,13 +724,13 @@
if (operator != UnaryOperator.NONE) {
next ();
var op = parse_unary_expression ();
- return context.create_unary_expression (operator, op, get_src (begin));
+ return new UnaryExpression (operator, op, get_src (begin));
}
switch (current ()) {
case TokenType.HASH:
next ();
var op = parse_unary_expression ();
- return context.create_reference_transfer_expression (op, get_src (begin));
+ return new ReferenceTransferExpression (op, get_src (begin));
case TokenType.OPEN_PARENS:
next ();
switch (current ()) {
@@ -762,7 +762,7 @@
Report.warning (get_src (begin), "obsolete syntax, weak type modifier unused in cast expressions");
}
var inner = parse_unary_expression ();
- return context.create_cast_expression (inner, type, get_src (begin), false);
+ return new CastExpression (inner, type, get_src (begin), false);
}
}
break;
@@ -773,11 +773,11 @@
case TokenType.STAR:
next ();
var op = parse_unary_expression ();
- return context.create_pointer_indirection (op, get_src (begin));
+ return new PointerIndirection (op, get_src (begin));
case TokenType.BITWISE_AND:
next ();
var op = parse_unary_expression ();
- return context.create_addressof_expression (op, get_src (begin));
+ return new AddressofExpression (op, get_src (begin));
}
var expr = parse_primary_expression ();
@@ -813,7 +813,7 @@
case BinaryOperator.MOD:
next ();
var right = parse_unary_expression ();
- left = context.create_binary_expression (operator, left, right, get_src (begin));
+ left = new BinaryExpression (operator, left, right, get_src (begin));
break;
default:
found = false;
@@ -834,7 +834,7 @@
case BinaryOperator.MINUS:
next ();
var right = parse_multiplicative_expression ();
- left = context.create_binary_expression (operator, left, right, get_src (begin));
+ left = new BinaryExpression (operator, left, right, get_src (begin));
break;
default:
found = false;
@@ -853,7 +853,7 @@
case TokenType.OP_SHIFT_LEFT:
next ();
var right = parse_additive_expression ();
- left = context.create_binary_expression (BinaryOperator.SHIFT_LEFT, left, right, get_src (begin));
+ left = new BinaryExpression (BinaryOperator.SHIFT_LEFT, left, right, get_src (begin));
break;
// don't use OP_SHIFT_RIGHT to support >> for nested generics
case TokenType.OP_GT:
@@ -863,7 +863,7 @@
if (current () == TokenType.OP_GT && tokens[index].begin.pos == first_gt_pos + 1) {
next ();
var right = parse_additive_expression ();
- left = context.create_binary_expression (BinaryOperator.SHIFT_RIGHT, left, right, get_src (begin));
+ left = new BinaryExpression (BinaryOperator.SHIFT_RIGHT, left, right, get_src (begin));
} else {
prev ();
found = false;
@@ -889,14 +889,14 @@
case BinaryOperator.GREATER_THAN_OR_EQUAL:
next ();
var right = parse_shift_expression ();
- left = context.create_binary_expression (operator, left, right, get_src (begin));
+ left = new BinaryExpression (operator, left, right, get_src (begin));
break;
case BinaryOperator.GREATER_THAN:
next ();
// ignore >> and >>= (two tokens due to generics)
if (current () != TokenType.OP_GT && current () != TokenType.OP_GE) {
var right = parse_shift_expression ();
- left = context.create_binary_expression (operator, left, right, get_src (begin));
+ left = new BinaryExpression (operator, left, right, get_src (begin));
} else {
prev ();
found = false;
@@ -907,12 +907,12 @@
case TokenType.IS:
next ();
var type = parse_type ();
- left = context.create_type_check (left, type, get_src (begin));
+ left = new TypeCheck (left, type, get_src (begin));
break;
case TokenType.AS:
next ();
var type = parse_type ();
- left = context.create_cast_expression (left, type, get_src (begin), true);
+ left = new CastExpression (left, type, get_src (begin), true);
break;
default:
found = false;
@@ -935,7 +935,7 @@
case BinaryOperator.INEQUALITY:
next ();
var right = parse_relational_expression ();
- left = context.create_binary_expression (operator, left, right, get_src (begin));
+ left = new BinaryExpression (operator, left, right, get_src (begin));
break;
default:
found = false;
@@ -950,7 +950,7 @@
var left = parse_equality_expression ();
while (accept (TokenType.BITWISE_AND)) {
var right = parse_equality_expression ();
- left = context.create_binary_expression (BinaryOperator.BITWISE_AND, left, right, get_src (begin));
+ left = new BinaryExpression (BinaryOperator.BITWISE_AND, left, right, get_src (begin));
}
return left;
}
@@ -960,7 +960,7 @@
var left = parse_and_expression ();
while (accept (TokenType.CARRET)) {
var right = parse_and_expression ();
- left = context.create_binary_expression (BinaryOperator.BITWISE_XOR, left, right, get_src (begin));
+ left = new BinaryExpression (BinaryOperator.BITWISE_XOR, left, right, get_src (begin));
}
return left;
}
@@ -970,7 +970,7 @@
var left = parse_exclusive_or_expression ();
while (accept (TokenType.BITWISE_OR)) {
var right = parse_exclusive_or_expression ();
- left = context.create_binary_expression (BinaryOperator.BITWISE_OR, left, right, get_src (begin));
+ left = new BinaryExpression (BinaryOperator.BITWISE_OR, left, right, get_src (begin));
}
return left;
}
@@ -980,7 +980,7 @@
var left = parse_inclusive_or_expression ();
while (accept (TokenType.IN)) {
var right = parse_inclusive_or_expression ();
- left = context.create_binary_expression (BinaryOperator.IN, left, right, get_src (begin));
+ left = new BinaryExpression (BinaryOperator.IN, left, right, get_src (begin));
}
return left;
}
@@ -990,7 +990,7 @@
var left = parse_in_expression ();
while (accept (TokenType.OP_AND)) {
var right = parse_in_expression ();
- left = context.create_binary_expression (BinaryOperator.AND, left, right, get_src (begin));
+ left = new BinaryExpression (BinaryOperator.AND, left, right, get_src (begin));
}
return left;
}
@@ -1000,7 +1000,7 @@
var left = parse_conditional_and_expression ();
while (accept (TokenType.OP_OR)) {
var right = parse_conditional_and_expression ();
- left = context.create_binary_expression (BinaryOperator.OR, left, right, get_src (begin));
+ left = new BinaryExpression (BinaryOperator.OR, left, right, get_src (begin));
}
return left;
}
@@ -1012,7 +1012,7 @@
var true_expr = parse_expression ();
expect (TokenType.COLON);
var false_expr = parse_expression ();
- return context.create_conditional_expression (condition, true_expr, false_expr, get_src (begin));
+ return new ConditionalExpression (condition, true_expr, false_expr, get_src (begin));
} else {
return condition;
}
@@ -1036,10 +1036,10 @@
LambdaExpression lambda;
if (current () == TokenType.OPEN_BRACE) {
var block = parse_block ();
- lambda = context.create_lambda_expression_with_statement_body (block, get_src (begin));
+ lambda = new LambdaExpression.with_statement_body (block, get_src (begin));
} else {
var expr = parse_expression ();
- lambda = context.create_lambda_expression (expr, get_src (begin));
+ lambda = new LambdaExpression (expr, get_src (begin));
}
foreach (string param in params) {
lambda.add_parameter (param);
@@ -1078,7 +1078,7 @@
if (operator != AssignmentOperator.NONE) {
next ();
var rhs = parse_expression ();
- expr = context.create_assignment (expr, rhs, operator, get_src (begin));
+ expr = new Assignment (expr, rhs, operator, get_src (begin));
if (expr == null) {
// workaround for current limitation of exception handling
throw new ParseError.SYNTAX ("syntax error in assignment");
@@ -1090,7 +1090,7 @@
if (current () == TokenType.OP_GE && tokens[index].begin.pos == first_gt_pos + 1) {
next ();
var rhs = parse_expression ();
- expr = context.create_assignment (expr, rhs, AssignmentOperator.SHIFT_RIGHT, get_src (begin));
+ expr = new Assignment (expr, rhs, AssignmentOperator.SHIFT_RIGHT, get_src (begin));
if (expr == null) {
// workaround for current limitation of exception handling
throw new ParseError.SYNTAX ("syntax error in assignment");
@@ -1245,7 +1245,7 @@
comment = scanner.pop_comment ();
- var block = context.create_block ();
+ var block = new Block ();
var stmt = parse_embedded_statement_without_block ();
if (stmt == null) {
// workaround for current limitation of exception handling
@@ -1280,7 +1280,7 @@
var begin = get_location ();
Gee.List<Statement> list = new ArrayList<Statement> ();
expect (TokenType.OPEN_BRACE);
- var block = context.create_block (get_src_com (begin));
+ var block = new Block (get_src_com (begin));
parse_statements (block);
if (!accept (TokenType.CLOSE_BRACE)) {
// only report error if it's not a secondary error
@@ -1295,7 +1295,7 @@
Statement parse_empty_statement () throws ParseError {
var begin = get_location ();
expect (TokenType.SEMICOLON);
- return context.create_empty_statement (get_src_com (begin));
+ return new EmptyStatement (get_src_com (begin));
}
void parse_local_variable_declarations (Block block) throws ParseError {
@@ -1316,7 +1316,7 @@
type_copy = variable_type.copy ();
}
var local = parse_local_variable (type_copy);
- block.add_statement (context.create_declaration_statement (local, local.source_reference));
+ block.add_statement (new DeclarationStatement (local, local.source_reference));
} while (accept (TokenType.COMMA));
expect (TokenType.SEMICOLON);
}
@@ -1328,14 +1328,14 @@
if (accept (TokenType.ASSIGN)) {
initializer = parse_variable_initializer ();
}
- return context.create_local_variable (variable_type, id, initializer, get_src_com (begin));
+ return new LocalVariable (variable_type, id, initializer, get_src_com (begin));
}
Statement parse_expression_statement () throws ParseError {
var begin = get_location ();
var expr = parse_statement_expression ();
expect (TokenType.SEMICOLON);
- return context.create_expression_statement (expr, get_src_com (begin));
+ return new ExpressionStatement (expr, get_src_com (begin));
}
Expression parse_statement_expression () throws ParseError {
@@ -1357,7 +1357,7 @@
if (accept (TokenType.ELSE)) {
false_stmt = parse_embedded_statement ();
}
- return context.create_if_statement (condition, true_stmt, false_stmt, src);
+ return new IfStatement (condition, true_stmt, false_stmt, src);
}
Statement parse_switch_statement () throws ParseError {
@@ -1366,16 +1366,16 @@
expect (TokenType.OPEN_PARENS);
var condition = parse_expression ();
expect (TokenType.CLOSE_PARENS);
- var stmt = context.create_switch_statement (condition, get_src_com (begin));
+ var stmt = new SwitchStatement (condition, get_src_com (begin));
expect (TokenType.OPEN_BRACE);
while (current () != TokenType.CLOSE_BRACE) {
- var section = context.create_switch_section (get_src_com (begin));
+ var section = new SwitchSection (get_src_com (begin));
do {
if (accept (TokenType.CASE)) {
- section.add_label (context.create_switch_label (parse_expression (), get_src_com (begin)));
+ section.add_label (new SwitchLabel (parse_expression (), get_src_com (begin)));
} else {
expect (TokenType.DEFAULT);
- section.add_label (context.create_switch_label_with_default (get_src_com (begin)));
+ section.add_label (new SwitchLabel.with_default (get_src_com (begin)));
}
expect (TokenType.COLON);
} while (current () == TokenType.CASE || current () == TokenType.DEFAULT);
@@ -1393,7 +1393,7 @@
var condition = parse_expression ();
expect (TokenType.CLOSE_PARENS);
var body = parse_embedded_statement ();
- return context.create_while_statement (condition, body, get_src_com (begin));
+ return new WhileStatement (condition, body, get_src_com (begin));
}
Statement parse_do_statement () throws ParseError {
@@ -1405,7 +1405,7 @@
var condition = parse_expression ();
expect (TokenType.CLOSE_PARENS);
expect (TokenType.SEMICOLON);
- return context.create_do_statement (body, condition, get_src_com (begin));
+ return new DoStatement (body, condition, get_src_com (begin));
}
Statement parse_for_statement () throws ParseError {
@@ -1434,7 +1434,7 @@
initializer_list.add (parse_statement_expression ());
} while (accept (TokenType.COMMA));
} else {
- block = context.create_block (get_src (begin));
+ block = new Block (get_src (begin));
DataType variable_type;
if (accept (TokenType.VAR)) {
variable_type = null;
@@ -1446,7 +1446,7 @@
}
}
var local = parse_local_variable (variable_type);
- block.add_statement (context.create_declaration_statement (local, local.source_reference));
+ block.add_statement (new DeclarationStatement (local, local.source_reference));
}
expect (TokenType.SEMICOLON);
}
@@ -1464,7 +1464,7 @@
expect (TokenType.CLOSE_PARENS);
var src = get_src_com (begin);
var body = parse_embedded_statement ();
- var stmt = context.create_for_statement (condition, body, src);
+ var stmt = new ForStatement (condition, body, src);
foreach (Expression init in initializer_list) {
stmt.add_initializer (init);
}
@@ -1494,21 +1494,21 @@
expect (TokenType.CLOSE_PARENS);
var src = get_src_com (begin);
var body = parse_embedded_statement ();
- return context.create_foreach_statement (type, id, collection, body, src);
+ return new ForeachStatement (type, id, collection, body, src);
}
Statement parse_break_statement () throws ParseError {
var begin = get_location ();
expect (TokenType.BREAK);
expect (TokenType.SEMICOLON);
- return context.create_break_statement (get_src_com (begin));
+ return new BreakStatement (get_src_com (begin));
}
Statement parse_continue_statement () throws ParseError {
var begin = get_location ();
expect (TokenType.CONTINUE);
expect (TokenType.SEMICOLON);
- return context.create_continue_statement (get_src_com (begin));
+ return new ContinueStatement (get_src_com (begin));
}
Statement parse_return_statement () throws ParseError {
@@ -1519,7 +1519,7 @@
expr = parse_expression ();
}
expect (TokenType.SEMICOLON);
- return context.create_return_statement (expr, get_src_com (begin));
+ return new ReturnStatement (expr, get_src_com (begin));
}
Statement parse_throw_statement () throws ParseError {
@@ -1527,7 +1527,7 @@
expect (TokenType.THROW);
var expr = parse_expression ();
expect (TokenType.SEMICOLON);
- return context.create_throw_statement (expr, get_src_com (begin));
+ return new ThrowStatement (expr, get_src_com (begin));
}
Statement parse_try_statement () throws ParseError {
@@ -1544,7 +1544,7 @@
} else {
finally_clause = parse_finally_clause ();
}
- var stmt = context.create_try_statement (try_block, finally_clause, get_src_com (begin));
+ var stmt = new TryStatement (try_block, finally_clause, get_src_com (begin));
foreach (CatchClause clause in catch_clauses) {
stmt.add_catch_clause (clause);
}
@@ -1562,7 +1562,7 @@
expect (TokenType.CLOSE_PARENS);
}
var block = parse_block ();
- catch_clauses.add (context.create_catch_clause (type, id, block, get_src (begin)));
+ catch_clauses.add (new CatchClause (type, id, block, get_src (begin)));
}
}
@@ -1579,7 +1579,7 @@
var expr = parse_expression ();
expect (TokenType.CLOSE_PARENS);
var stmt = parse_embedded_statement ();
- return context.create_lock_statement (expr, stmt, get_src_com (begin));
+ return new LockStatement (expr, stmt, get_src_com (begin));
}
Statement parse_delete_statement () throws ParseError {
@@ -1587,7 +1587,7 @@
expect (TokenType.DELETE);
var expr = parse_expression ();
expect (TokenType.SEMICOLON);
- return context.create_delete_statement (expr, get_src_com (begin));
+ return new DeleteStatement (expr, get_src_com (begin));
}
Gee.List<Attribute>? parse_attributes () throws ParseError {
@@ -1791,7 +1791,7 @@
var begin = get_location ();
expect (TokenType.NAMESPACE);
var sym = parse_symbol_name ();
- var ns = context.create_namespace (sym.name, get_src_com (begin));
+ var ns = new Namespace (sym.name, get_src_com (begin));
ns.pkg = scanner.source_file.pkg;
set_attributes (ns, attrs);
parse_declarations (ns);
@@ -1919,7 +1919,7 @@
} while (accept (TokenType.COMMA));
}
- var cl = context.create_class (sym.name, get_src_com (begin));
+ var cl = new Class (sym.name, get_src_com (begin));
cl.access = access;
if (ModifierFlags.ABSTRACT in flags) {
cl.is_abstract = true;
@@ -1941,17 +1941,17 @@
if (!scanner.source_file.pkg
&& !cl.is_static
&& cl.default_construction_method == null) {
- var m = context.create_creation_method (cl.name, null, cl.source_reference);
+ var m = new CreationMethod (cl.name, null, cl.source_reference);
m.instance = false;
m.access = SymbolAccessibility.PUBLIC;
- m.body = context.create_block (cl.source_reference);
+ m.body = new Block (cl.source_reference);
cl.add_method (m);
}
Symbol result = cl;
while (sym.inner != null) {
sym = sym.inner;
- var ns = context.create_namespace (sym.name, cl.source_reference);
+ var ns = new Namespace (sym.name, cl.source_reference);
ns.pkg = scanner.source_file.pkg;
if (result is Namespace) {
ns.add_namespace ((Namespace) result);
@@ -2013,7 +2013,7 @@
initializer = parse_variable_initializer ();
}
expect (TokenType.SEMICOLON);
- var c = context.create_constant (id, type, initializer, get_src_com (begin));
+ var c = new Constant (id, type, initializer, get_src_com (begin));
c.access = access;
set_attributes (c, attrs);
return c;
@@ -2029,7 +2029,7 @@
unresolved_type.takes_ownership = true;
}
string id = parse_identifier ();
- var f = context.create_field (id, type, null, get_src_com (begin));
+ var f = new Field (id, type, null, get_src_com (begin));
f.access = access;
set_attributes (f, attrs);
if (ModifierFlags.STATIC in flags) {
@@ -2045,7 +2045,7 @@
InitializerList parse_initializer () throws ParseError {
var begin = get_location ();
expect (TokenType.OPEN_BRACE);
- var initializer = context.create_initializer_list (get_src (begin));
+ var initializer = new InitializerList (get_src (begin));
if (current () != TokenType.CLOSE_BRACE) {
do {
initializer.append (parse_variable_initializer ());
@@ -2076,7 +2076,7 @@
}
string id = parse_identifier ();
parse_type_parameter_list ();
- var method = context.create_method (id, type, get_src_com (begin));
+ var method = new Method (id, type, get_src_com (begin));
method.access = access;
set_attributes (method, attrs);
if (ModifierFlags.STATIC in flags) {
@@ -2122,7 +2122,7 @@
type.takes_ownership = true;
}
string id = parse_identifier ();
- var prop = context.create_property (id, type, null, null, get_src_com (begin));
+ var prop = new Property (id, type, null, null, get_src_com (begin));
prop.access = access;
set_attributes (prop, attrs);
if (ModifierFlags.ABSTRACT in flags) {
@@ -2161,7 +2161,7 @@
if (!accept (TokenType.SEMICOLON)) {
block = parse_block ();
}
- prop.get_accessor = context.create_property_accessor (true, false, false, block, get_src (accessor_begin));
+ prop.get_accessor = new PropertyAccessor (true, false, false, block, get_src (accessor_begin));
prop.get_accessor.access = accessor_access;
} else {
bool writable, _construct;
@@ -2181,7 +2181,7 @@
if (!accept (TokenType.SEMICOLON)) {
block = parse_block ();
}
- prop.set_accessor = context.create_property_accessor (false, writable, _construct, block, get_src (accessor_begin));
+ prop.set_accessor = new PropertyAccessor (false, writable, _construct, block, get_src (accessor_begin));
prop.set_accessor.access = accessor_access;
}
}
@@ -2197,7 +2197,7 @@
expect (TokenType.SIGNAL);
var type = parse_type ();
string id = parse_identifier ();
- var sig = context.create_signal (id, type, get_src_com (begin));
+ var sig = new Signal (id, type, get_src_com (begin));
sig.access = access;
set_attributes (sig, attrs);
expect (TokenType.OPEN_PARENS);
@@ -2216,7 +2216,7 @@
var begin = get_location ();
var flags = parse_member_declaration_modifiers ();
expect (TokenType.CONSTRUCT);
- var c = context.create_constructor (get_src_com (begin));
+ var c = new Constructor (get_src_com (begin));
if (ModifierFlags.STATIC in flags) {
c.instance = false;
}
@@ -2230,7 +2230,7 @@
parse_identifier ();
expect (TokenType.OPEN_PARENS);
expect (TokenType.CLOSE_PARENS);
- var d = context.create_destructor (get_src_com (begin));
+ var d = new Destructor (get_src_com (begin));
d.body = parse_block ();
return d;
}
@@ -2248,7 +2248,7 @@
base_types.add (parse_type ());
} while (accept (TokenType.COMMA));
}
- var st = context.create_struct (sym.name, get_src_com (begin));
+ var st = new Struct (sym.name, get_src_com (begin));
st.access = access;
set_attributes (st, attrs);
foreach (TypeParameter type_param in type_param_list) {
@@ -2263,7 +2263,7 @@
Symbol result = st;
while (sym.inner != null) {
sym = sym.inner;
- var ns = context.create_namespace (sym.name, st.source_reference);
+ var ns = new Namespace (sym.name, st.source_reference);
ns.pkg = scanner.source_file.pkg;
if (result is Namespace) {
ns.add_namespace ((Namespace) result);
@@ -2305,7 +2305,7 @@
base_types.add (parse_type ());
} while (accept (TokenType.COMMA));
}
- var iface = context.create_interface (sym.name, get_src_com (begin));
+ var iface = new Interface (sym.name, get_src_com (begin));
iface.access = access;
set_attributes (iface, attrs);
foreach (TypeParameter type_param in type_param_list) {
@@ -2325,7 +2325,7 @@
Symbol result = iface;
while (sym.inner != null) {
sym = sym.inner;
- var ns = context.create_namespace (sym.name, iface.source_reference);
+ var ns = new Namespace (sym.name, iface.source_reference);
ns.pkg = scanner.source_file.pkg;
if (result is Namespace) {
ns.add_namespace ((Namespace) result);
@@ -2370,7 +2370,7 @@
parse_type_declaration_modifiers ();
expect (TokenType.ENUM);
var sym = parse_symbol_name ();
- var en = context.create_enum (sym.name, get_src_com (begin));
+ var en = new Enum (sym.name, get_src_com (begin));
en.access = access;
set_attributes (en, attrs);
@@ -2381,7 +2381,7 @@
break;
}
string id = parse_identifier ();
- var ev = context.create_enum_value (id, get_src (begin));
+ var ev = new EnumValue (id, get_src (begin));
if (accept (TokenType.ASSIGN)) {
ev.value = parse_expression ();
}
@@ -2406,7 +2406,7 @@
Symbol result = en;
while (sym.inner != null) {
sym = sym.inner;
- var ns = context.create_namespace (sym.name, en.source_reference);
+ var ns = new Namespace (sym.name, en.source_reference);
ns.pkg = scanner.source_file.pkg;
if (result is Namespace) {
ns.add_namespace ((Namespace) result);
@@ -2425,7 +2425,7 @@
parse_type_declaration_modifiers ();
expect (TokenType.ERRORDOMAIN);
var sym = parse_symbol_name ();
- var ed = context.create_error_domain (sym.name, get_src_com (begin));
+ var ed = new ErrorDomain (sym.name, get_src_com (begin));
ed.access = access;
set_attributes (ed, attrs);
@@ -2436,7 +2436,7 @@
break;
}
string id = parse_identifier ();
- var ec = context.create_error_code (id);
+ var ec = new ErrorCode (id);
if (accept (TokenType.ASSIGN)) {
ec.value = parse_expression ();
}
@@ -2461,7 +2461,7 @@
Symbol result = ed;
while (sym.inner != null) {
sym = sym.inner;
- var ns = context.create_namespace (sym.name, ed.source_reference);
+ var ns = new Namespace (sym.name, ed.source_reference);
ns.pkg = scanner.source_file.pkg;
if (result is Namespace) {
ns.add_namespace ((Namespace) result);
@@ -2549,7 +2549,7 @@
var begin = get_location ();
if (accept (TokenType.ELLIPSIS)) {
// varargs
- return context.create_formal_parameter_with_ellipsis (get_src (begin));
+ return new FormalParameter.with_ellipsis (get_src (begin));
}
bool construct_param = false;
if (accept (TokenType.CONSTRUCT)) {
@@ -2575,7 +2575,7 @@
}
}
string id = parse_identifier ();
- var param = context.create_formal_parameter (id, type, get_src (begin));
+ var param = new FormalParameter (id, type, get_src (begin));
set_attributes (param, attrs);
param.direction = direction;
param.construct_parameter = construct_param;
@@ -2592,9 +2592,9 @@
var sym = parse_symbol_name ();
CreationMethod method;
if (sym.inner == null) {
- method = context.create_creation_method (sym.name, null, get_src_com (begin));
+ method = new CreationMethod (sym.name, null, get_src_com (begin));
} else {
- method = context.create_creation_method (sym.inner.name, sym.name, get_src_com (begin));
+ method = new CreationMethod (sym.inner.name, sym.name, get_src_com (begin));
}
expect (TokenType.OPEN_PARENS);
if (current () != TokenType.CLOSE_PARENS) {
@@ -2630,7 +2630,7 @@
}
var sym = parse_symbol_name ();
var type_param_list = parse_type_parameter_list ();
- var d = context.create_delegate (sym.name, type, get_src_com (begin));
+ var d = new Delegate (sym.name, type, get_src_com (begin));
d.access = access;
set_attributes (d, attrs);
if (!(ModifierFlags.STATIC in flags)) {
@@ -2657,7 +2657,7 @@
Symbol result = d;
while (sym.inner != null) {
sym = sym.inner;
- var ns = context.create_namespace (sym.name, d.source_reference);
+ var ns = new Namespace (sym.name, d.source_reference);
ns.pkg = scanner.source_file.pkg;
if (result is Namespace) {
ns.add_namespace ((Namespace) result);
@@ -2676,7 +2676,7 @@
do {
var begin = get_location ();
string id = parse_identifier ();
- list.add (context.create_type_parameter (id, get_src (begin)));
+ list.add (new TypeParameter (id, get_src (begin)));
} while (accept (TokenType.COMMA));
expect (TokenType.OP_GT);
}
@@ -2749,7 +2749,7 @@
do {
string id = parse_identifier ();
Gee.List<DataType> type_arg_list = parse_type_argument_list (false);
- expr = context.create_member_access (expr, id, get_src (begin));
+ expr = new MemberAccess (expr, id, get_src (begin));
if (type_arg_list != null) {
foreach (DataType type_arg in type_arg_list) {
expr.add_type_argument (type_arg);
Modified: trunk/vala/valasemanticanalyzer.vala
==============================================================================
--- trunk/vala/valasemanticanalyzer.vala (original)
+++ trunk/vala/valasemanticanalyzer.vala Sat Apr 19 05:34:20 2008
@@ -583,7 +583,7 @@
var left = new MemberAccess (new MemberAccess.simple ("this"), p.name);
var right = new MemberAccess.simple (p.name);
- method_body.add_statement (new ExpressionStatement (context.create_assignment (left, right), p.source_reference));
+ method_body.add_statement (new ExpressionStatement (new Assignment (left, right), p.source_reference));
}
}
@@ -731,12 +731,12 @@
}
acc.automatic_body = true;
acc.body = new Block ();
- var ma = context.create_member_access_simple ("_%s".printf (acc.prop.name), acc.source_reference);
+ var ma = new MemberAccess.simple ("_%s".printf (acc.prop.name), acc.source_reference);
if (acc.readable) {
- acc.body.add_statement (context.create_return_statement (ma, acc.source_reference));
+ acc.body.add_statement (new ReturnStatement (ma, acc.source_reference));
} else {
- var assignment = context.create_assignment (ma, context.create_member_access_simple ("value", acc.source_reference), AssignmentOperator.SIMPLE, acc.source_reference);
- acc.body.add_statement (context.create_expression_statement (assignment));
+ var assignment = new Assignment (ma, new MemberAccess.simple ("value", acc.source_reference), AssignmentOperator.SIMPLE, acc.source_reference);
+ acc.body.add_statement (new ExpressionStatement (assignment));
}
}
@@ -1721,7 +1721,7 @@
if (expr.call is MemberAccess &&
(expr.call.symbol_reference is CreationMethod
|| expr.call.symbol_reference is Struct)) {
- var struct_creation_expression = context.create_object_creation_expression ((MemberAccess) expr.call, expr.source_reference);
+ var struct_creation_expression = new ObjectCreationExpression ((MemberAccess) expr.call, expr.source_reference);
struct_creation_expression.struct_creation = true;
foreach (Expression arg in expr.get_argument_list ()) {
struct_creation_expression.add_argument (arg);
@@ -2496,7 +2496,7 @@
var old_value = new MemberAccess (ma.inner, ma.member_name, expr.inner.source_reference);
var bin = new BinaryExpression (expr.operator == UnaryOperator.INCREMENT ? BinaryOperator.PLUS : BinaryOperator.MINUS, old_value, new IntegerLiteral ("1"), expr.source_reference);
- var assignment = context.create_assignment (ma, bin, AssignmentOperator.SIMPLE, expr.source_reference);
+ var assignment = new Assignment (ma, bin, AssignmentOperator.SIMPLE, expr.source_reference);
var parenthexp = new ParenthesizedExpression (assignment, expr.source_reference);
expr.parent_node.replace_expression (expr, parenthexp);
parenthexp.accept (this);
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]