vala r2322 - in trunk: . vala
- From: juergbi svn gnome org
- To: svn-commits-list gnome org
- Subject: vala r2322 - in trunk: . vala
- Date: Sat, 10 Jan 2009 13:15:14 +0000 (UTC)
Author: juergbi
Date: Sat Jan 10 13:15:14 2009
New Revision: 2322
URL: http://svn.gnome.org/viewvc/vala?rev=2322&view=rev
Log:
2009-01-10 JÃrg Billeter <j bitron ch>
* vala/valalocalvariable.vala:
Warn when using result variable with incompatible type to prepare
possible introduction of implicit result variable
* vala/valageniescanner.vala:
* vala/valascanner.vala:
* vala/valasymbol.vala:
Fix new warnings
Modified:
trunk/ChangeLog
trunk/vala/valageniescanner.vala
trunk/vala/valalocalvariable.vala
trunk/vala/valascanner.vala
trunk/vala/valasymbol.vala
Modified: trunk/vala/valageniescanner.vala
==============================================================================
--- trunk/vala/valageniescanner.vala (original)
+++ trunk/vala/valageniescanner.vala Sat Jan 10 13:15:14 2009
@@ -1061,15 +1061,15 @@
return null;
}
- var result = new StringBuilder (_comment);
+ var result_builder = new StringBuilder (_comment);
_comment = null;
weak string index;
- while ((index = result.str.chr (-1, '\t')) != null) {
- result.erase (result.str.pointer_to_offset (index), 1);
+ while ((index = result_builder.str.chr (-1, '\t')) != null) {
+ result_builder.erase (result_builder.str.pointer_to_offset (index), 1);
}
- return result.str;
+ return result_builder.str;
}
}
Modified: trunk/vala/valalocalvariable.vala
==============================================================================
--- trunk/vala/valalocalvariable.vala (original)
+++ trunk/vala/valalocalvariable.vala Sat Jan 10 13:15:14 2009
@@ -142,6 +142,16 @@
initializer.target_type = variable_type;
}
+ if (name == "result") {
+ // warn if type of `result' variable is incompatible with return type
+ // as an implicit `result' variable might be introduced to be used
+ // by Vala postconditions and implicit checks generated by the code generated
+ if (analyzer.current_return_type == null
+ || !variable_type.compatible (analyzer.current_return_type)) {
+ Report.warning (source_reference, "result variable type incompatible with return type");
+ }
+ }
+
if (initializer != null) {
if (initializer.value_type == null) {
if (!(initializer is MemberAccess) && !(initializer is LambdaExpression)) {
Modified: trunk/vala/valascanner.vala
==============================================================================
--- trunk/vala/valascanner.vala (original)
+++ trunk/vala/valascanner.vala Sat Jan 10 13:15:14 2009
@@ -859,15 +859,15 @@
return null;
}
- var result = new StringBuilder (_comment);
+ var result_builder = new StringBuilder (_comment);
_comment = null;
weak string index;
- while ((index = result.str.chr (-1, '\t')) != null) {
- result.erase (result.str.pointer_to_offset (index), 1);
+ while ((index = result_builder.str.chr (-1, '\t')) != null) {
+ result_builder.erase (result_builder.str.pointer_to_offset (index), 1);
}
- return result.str;
+ return result_builder.str;
}
}
Modified: trunk/vala/valasymbol.vala
==============================================================================
--- trunk/vala/valasymbol.vala (original)
+++ trunk/vala/valasymbol.vala Sat Jan 10 13:15:14 2009
@@ -1,6 +1,6 @@
/* valasymbol.vala
*
- * Copyright (C) 2006-2008 JÃrg Billeter
+ * Copyright (C) 2006-2009 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
@@ -205,7 +205,7 @@
* @return the specified string converted to lower case
*/
public static string camel_case_to_lower_case (string camel_case) {
- var result = new StringBuilder ("");
+ var result_builder = new StringBuilder ("");
weak string i = camel_case;
@@ -222,21 +222,21 @@
if (!prev_upper || (i.len () >= 2 && !next_upper)) {
/* previous character wasn't upper case or
* next character isn't upper case*/
- long len = result.str.len ();
- if (len != 1 && result.str.offset (len - 2).get_char () != '_') {
+ long len = result_builder.str.len ();
+ if (len != 1 && result_builder.str.offset (len - 2).get_char () != '_') {
/* we're not creating 1 character words */
- result.append_c ('_');
+ result_builder.append_c ('_');
}
}
}
- result.append_unichar (c.tolower ());
+ result_builder.append_unichar (c.tolower ());
first = false;
i = i.next_char ();
}
- return result.str;
+ return result_builder.str;
}
/**
@@ -246,7 +246,7 @@
* @return the specified string converted to camel case
*/
public static string lower_case_to_camel_case (string lower_case) {
- var result = new StringBuilder ("");
+ var result_builder = new StringBuilder ("");
weak string i = lower_case;
@@ -259,16 +259,16 @@
// original string is not lower_case, don't apply transformation
return lower_case;
} else if (last_underscore) {
- result.append_unichar (c.toupper ());
+ result_builder.append_unichar (c.toupper ());
last_underscore = false;
} else {
- result.append_unichar (c);
+ result_builder.append_unichar (c);
}
i = i.next_char ();
}
- return result.str;
+ return result_builder.str;
}
// get the top scope from where this symbol is still accessible
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]