Skip to content

Commit

Permalink
to_string -> ToString (properly this time)
Browse files Browse the repository at this point in the history
  • Loading branch information
smx-smx committed Feb 17, 2018
1 parent d769f37 commit b957b5e
Show file tree
Hide file tree
Showing 48 changed files with 123 additions and 112 deletions.
8 changes: 4 additions & 4 deletions CCodeGen/Modules/CCodeBaseModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4473,7 +4473,7 @@ void check_type_argument(DataType type_arg) {
Report.error(type_arg.source_reference, "Delegates with target are not supported as generic type arguments");
}
} else {
Report.error(type_arg.source_reference, "`%s' is not a supported generic type argument, use `?' to box value types".printf(type_arg.to_string()));
Report.error(type_arg.source_reference, "`%s' is not a supported generic type argument, use `?' to box value types".printf(type_arg.ToString()));
}
}

Expand Down Expand Up @@ -5773,7 +5773,7 @@ public TargetValue transform_value(TargetValue value, DataType target_type, Code
}
var type_id = get_ccode_type_id(type);
if (type_id == "") {
Report.error(node.source_reference, "GValue boxing of type `%s' is not supported".printf(type.to_string()));
Report.error(node.source_reference, "GValue boxing of type `%s' is not supported".printf(type.ToString()));
}
ccall.add_argument(new CCodeIdentifier(type_id));
ccode.add_expression(ccall);
Expand Down Expand Up @@ -6657,12 +6657,12 @@ public virtual void register_dbus_info(CCodeBlock block, ObjectTypeSymbol bindab
}

public virtual string get_dynamic_property_getter_cname(DynamicProperty node) {
Report.error(node.source_reference, "dynamic properties are not supported for %s".printf(node.dynamic_type.to_string()));
Report.error(node.source_reference, "dynamic properties are not supported for %s".printf(node.dynamic_type.ToString()));
return "";
}

public virtual string get_dynamic_property_setter_cname(DynamicProperty node) {
Report.error(node.source_reference, "dynamic properties are not supported for %s".printf(node.dynamic_type.to_string()));
Report.error(node.source_reference, "dynamic properties are not supported for %s".printf(node.dynamic_type.ToString()));
return "";
}

Expand Down
2 changes: 1 addition & 1 deletion CCodeGen/Modules/GDBusClientModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public override void generate_dynamic_method_wrapper(DynamicMethod method) {
if (dynamic_method.dynamic_type.data_type == dbus_proxy_type) {
generate_marshalling(method, CallType.SYNC, null, method.name, -1);
} else {
Report.error(method.source_reference, "dynamic methods are not supported for `%s'".printf(dynamic_method.dynamic_type.to_string()));
Report.error(method.source_reference, "dynamic methods are not supported for `%s'".printf(dynamic_method.dynamic_type.ToString()));
}

pop_function();
Expand Down
2 changes: 1 addition & 1 deletion CCodeGen/Modules/GObjectModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -791,7 +791,7 @@ public override void visit_method_call(MethodCall expr) {
break;
}
if (!arg.value_type.compatible(prop.property_type)) {
Report.error(arg.source_reference, "Cannot convert from `%s' to `%s'".printf(arg.value_type.to_string(), prop.property_type.to_string()));
Report.error(arg.source_reference, "Cannot convert from `%s' to `%s'".printf(arg.value_type.ToString(), prop.property_type.ToString()));
break;
}
}
Expand Down
4 changes: 2 additions & 2 deletions CCodeGen/Modules/GVariantModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -523,7 +523,7 @@ public override CCodeExpression deserialize_expression(DataType type, CCodeExpre
}

if (result == null) {
Report.error(type.source_reference, "GVariant deserialization of type `%s' is not supported".printf(type.to_string()));
Report.error(type.source_reference, "GVariant deserialization of type `%s' is not supported".printf(type.ToString()));
}

return result;
Expand Down Expand Up @@ -815,7 +815,7 @@ public override CCodeExpression serialize_expression(DataType type, CCodeExpress
}

if (result == null) {
Report.error(type.source_reference, "GVariant serialization of type `%s' is not supported".printf(type.to_string()));
Report.error(type.source_reference, "GVariant serialization of type `%s' is not supported".printf(type.ToString()));
}

return result;
Expand Down
2 changes: 1 addition & 1 deletion CCodeGen/Modules/GtkModule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ public override void visit_method(Method m) {
var signal_type = new SignalType(sig);
var delegate_type = signal_type.get_handler_type();
if (!method_type.compatible(delegate_type)) {
Report.error(m.source_reference, "method `%s' is incompatible with signal `%s', expected `%s'".printf(method_type.to_string(), delegate_type.to_string(), delegate_type.delegate_symbol.get_prototype_string(m.name)));
Report.error(m.source_reference, "method `%s' is incompatible with signal `%s', expected `%s'".printf(method_type.ToString(), delegate_type.ToString(), delegate_type.delegate_symbol.get_prototype_string(m.name)));
} else {
var wrapper = generate_delegate_wrapper(m, signal_type.get_handler_type(), m);

Expand Down
2 changes: 1 addition & 1 deletion Lang/Code/CodeNode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ public void set_attribute_cache(int index, AttributeCache cache) {
///
/// <returns>a string representation</returns>
/// </summary>
public virtual string to_string() {
public virtual string ToString() {
var str = new StringBuilder();

str.Append("/* ");
Expand Down
2 changes: 1 addition & 1 deletion Lang/Code/CodeWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1134,7 +1134,7 @@ public override void visit_try_statement(TryStatement stmt) {
}

public override void visit_catch_clause(CatchClause clause) {
var type_name = clause.error_type == null ? "GLib.Error" : clause.error_type.to_string();
var type_name = clause.error_type == null ? "GLib.Error" : clause.error_type.ToString();
var var_name = clause.variable_name == null ? "_" : clause.variable_name;
write_string(" catch (%s %s)".printf(type_name, var_name));
clause.body.accept(this);
Expand Down
2 changes: 1 addition & 1 deletion Lang/CodeNodes/CatchClause.cs
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public override bool check(CodeContext context) {

if (error_type != null) {
if (!(error_type is ErrorType)) {
Report.error(source_reference, "clause must catch a valid error type, found `%s' instead".printf(error_type.to_string()));
Report.error(source_reference, "clause must catch a valid error type, found `%s' instead".printf(error_type.ToString()));
error = true;
}

Expand Down
2 changes: 1 addition & 1 deletion Lang/CodeNodes/SwitchLabel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ public override bool check(CodeContext context) {
}
if (!expression.value_type.compatible(switch_statement.expression.value_type)) {
error = true;
Report.error(expression.source_reference, "Cannot convert from `%s' to `%s'".printf(expression.value_type.to_string(), switch_statement.expression.value_type.to_string()));
Report.error(expression.source_reference, "Cannot convert from `%s' to `%s'".printf(expression.value_type.ToString(), switch_statement.expression.value_type.ToString()));
return false;
}
}
Expand Down
2 changes: 1 addition & 1 deletion Lang/Constructor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ public override bool check(CodeContext context) {

foreach (DataType body_error_type in body.get_error_types()) {
if (!((ErrorType)body_error_type).dynamic_error) {
Report.warning(body_error_type.source_reference, "unhandled error `%s'".printf(body_error_type.to_string()));
Report.warning(body_error_type.source_reference, "unhandled error `%s'".printf(body_error_type.ToString()));
}
}

Expand Down
6 changes: 3 additions & 3 deletions Lang/Expressions/Assignment.cs
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ public override bool check(CodeContext context) {
var delegate_type = (DelegateType)right.target_type;

error = true;
Report.error(right.source_reference, "method `%s' is incompatible with signal `%s', expected `%s'".printf(right.value_type.to_string(), right.target_type.to_string(), delegate_type.delegate_symbol.get_prototype_string(m.name)));
Report.error(right.source_reference, "method `%s' is incompatible with signal `%s', expected `%s'".printf(right.value_type.ToString(), right.target_type.ToString(), delegate_type.delegate_symbol.get_prototype_string(m.name)));
return false;
} else if (right_ma != null && right_ma.prototype_access) {
error = true;
Expand Down Expand Up @@ -359,7 +359,7 @@ public override bool check(CodeContext context) {

if (!right.value_type.compatible(left.value_type)) {
error = true;
Report.error(source_reference, "Assignment: Cannot convert from `%s' to `%s'".printf(right.value_type.to_string(), left.value_type.to_string()));
Report.error(source_reference, "Assignment: Cannot convert from `%s' to `%s'".printf(right.value_type.ToString(), left.value_type.ToString()));
return false;
}

Expand Down Expand Up @@ -403,7 +403,7 @@ public override bool check(CodeContext context) {

if (!right.value_type.compatible(left.value_type)) {
error = true;
Report.error(source_reference, "Assignment: Cannot convert from `%s' to `%s'".printf(right.value_type.to_string(), left.value_type.to_string()));
Report.error(source_reference, "Assignment: Cannot convert from `%s' to `%s'".printf(right.value_type.ToString(), left.value_type.ToString()));
return false;
}

Expand Down
2 changes: 1 addition & 1 deletion Lang/Expressions/BaseAccess.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public override void accept(CodeVisitor visitor) {
visitor.visit_expression(this);
}

public override string to_string() {
public override string ToString() {
return "base";
}

Expand Down
63 changes: 37 additions & 26 deletions Lang/Expressions/BinaryExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -120,8 +120,8 @@ private string get_operator_string() {
return null;
}

public override string to_string() {
return _left.to_string() + get_operator_string() + _right.to_string();
public override string ToString() {
return _left.ToString() + get_operator_string() + _right.ToString();
}

public override bool is_constant() {
Expand Down Expand Up @@ -352,10 +352,12 @@ public override bool check(CodeContext context) {

value_type = array_type.copy();
value_type.value_owned = true;
} else if (Operator == BinaryOperator.PLUS
|| Operator == BinaryOperator.MINUS
|| Operator == BinaryOperator.MUL
|| Operator == BinaryOperator.DIV) {
} else if (
Operator == BinaryOperator.PLUS ||
Operator == BinaryOperator.MINUS ||
Operator == BinaryOperator.MUL ||
Operator == BinaryOperator.DIV
) {
// check for pointer arithmetic
if (left.value_type is PointerType) {
var pointer_type = (PointerType)left.value_type;
Expand Down Expand Up @@ -387,26 +389,29 @@ public override bool check(CodeContext context) {

if (value_type == null) {
error = true;
Report.error(source_reference, "Arithmetic operation not supported for types `%s' and `%s'".printf(left.value_type.to_string(), right.value_type.to_string()));
Report.error(source_reference, "Arithmetic operation not supported for types `%s' and `%s'".printf(left.value_type.ToString(), right.value_type.ToString()));
return false;
}
} else if (Operator == BinaryOperator.MOD
|| Operator == BinaryOperator.SHIFT_LEFT
|| Operator == BinaryOperator.SHIFT_RIGHT) {
} else if (
Operator == BinaryOperator.MOD ||
Operator == BinaryOperator.SHIFT_LEFT ||
Operator == BinaryOperator.SHIFT_RIGHT
) {
left.target_type.nullable = false;
right.target_type.nullable = false;

value_type = context.analyzer.get_arithmetic_result_type(left.target_type, right.target_type);

if (value_type == null) {
error = true;
Report.error(source_reference, "Arithmetic operation not supported for types `%s' and `%s'".printf(left.value_type.to_string(), right.value_type.to_string()));
Report.error(source_reference, "Arithmetic operation not supported for types `%s' and `%s'".printf(left.value_type.ToString(), right.value_type.ToString()));
return false;
}
} else if (Operator == BinaryOperator.LESS_THAN
|| Operator == BinaryOperator.GREATER_THAN
|| Operator == BinaryOperator.LESS_THAN_OR_EQUAL
|| Operator == BinaryOperator.GREATER_THAN_OR_EQUAL) {
} else if (Operator == BinaryOperator.LESS_THAN ||
Operator == BinaryOperator.GREATER_THAN ||
Operator == BinaryOperator.LESS_THAN_OR_EQUAL ||
Operator == BinaryOperator.GREATER_THAN_OR_EQUAL
) {
if (left.value_type.compatible(context.analyzer.string_type)
&& right.value_type.compatible(context.analyzer.string_type)) {
// string comparison
Expand All @@ -424,7 +429,7 @@ public override bool check(CodeContext context) {

if (resulting_type == null) {
error = true;
Report.error(source_reference, "Relational operation not supported for types `%s' and `%s'".printf(left.value_type.to_string(), right.value_type.to_string()));
Report.error(source_reference, "Relational operation not supported for types `%s' and `%s'".printf(left.value_type.ToString(), right.value_type.ToString()));
return false;
}

Expand All @@ -437,13 +442,15 @@ public override bool check(CodeContext context) {
}

value_type = context.analyzer.bool_type;
} else if (Operator == BinaryOperator.EQUALITY
|| Operator == BinaryOperator.INEQUALITY) {
} else if (
Operator == BinaryOperator.EQUALITY ||
Operator == BinaryOperator.INEQUALITY
) {
/* relational operation */

if (!right.value_type.compatible(left.value_type)
&& !left.value_type.compatible(right.value_type)) {
Report.error(source_reference, "Equality operation: `%s' and `%s' are incompatible".printf(right.value_type.to_string(), left.value_type.to_string()));
Report.error(source_reference, "Equality operation: `%s' and `%s' are incompatible".printf(right.value_type.ToString(), left.value_type.ToString()));
error = true;
return false;
}
Expand All @@ -468,16 +475,20 @@ public override bool check(CodeContext context) {
}

value_type = context.analyzer.bool_type;
} else if (Operator == BinaryOperator.BITWISE_AND
|| Operator == BinaryOperator.BITWISE_OR
|| Operator == BinaryOperator.BITWISE_XOR) {
} else if (
Operator == BinaryOperator.BITWISE_AND ||
Operator == BinaryOperator.BITWISE_OR ||
Operator == BinaryOperator.BITWISE_XOR
) {
// integer type or flags type
left.target_type.nullable = false;
right.target_type.nullable = false;

value_type = left.target_type.copy();
} else if (Operator == BinaryOperator.AND
|| Operator == BinaryOperator.OR) {
} else if (
Operator == BinaryOperator.AND ||
Operator == BinaryOperator.OR
) {
if (!left.value_type.compatible(context.analyzer.bool_type) || !right.value_type.compatible(context.analyzer.bool_type)) {
error = true;
Report.error(source_reference, "Operands must be boolean");
Expand All @@ -494,13 +505,13 @@ public override bool check(CodeContext context) {
right.target_type.nullable = false;
} else if (right.value_type is ArrayType) {
if (!left.value_type.compatible(((ArrayType)right.value_type).element_type)) {
Report.error(source_reference, "Cannot look for `%s' in `%s'".printf(left.value_type.to_string(), right.value_type.to_string()));
Report.error(source_reference, "Cannot look for `%s' in `%s'".printf(left.value_type.ToString(), right.value_type.ToString()));
}
} else {
// otherwise require a bool contains () method
var contains_method = right.value_type.get_member("contains") as Method;
if (contains_method == null) {
Report.error(source_reference, "`%s' does not have a `contains' method".printf(right.value_type.to_string()));
Report.error(source_reference, "`%s' does not have a `contains' method".printf(right.value_type.ToString()));
error = true;
return false;
}
Expand Down
2 changes: 1 addition & 1 deletion Lang/Expressions/ElementAccess.cs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ public override bool check(CodeContext context) {
}

error = true;
Report.error(source_reference, "The expression `%s' does not denote an array".printf(container.value_type.to_string()));
Report.error(source_reference, "The expression `%s' does not denote an array".printf(container.value_type.ToString()));
}

if (index_int_type_check) {
Expand Down
6 changes: 3 additions & 3 deletions Lang/Expressions/InitializerList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public override bool check(CodeContext context) {
while (field == null) {
if (!field_it.MoveNext()) {
this.error = true;
Report.error(e.source_reference, "too many expressions in initializer list for `%s'".printf(target_type.to_string()));
Report.error(e.source_reference, "too many expressions in initializer list for `%s'".printf(target_type.ToString()));
return false;
}
field = field_it.Current;
Expand All @@ -174,7 +174,7 @@ public override bool check(CodeContext context) {
}
} else {
this.error = true;
Report.error(source_reference, "initializer list used for `%s', which is neither array nor struct".printf(target_type.to_string()));
Report.error(source_reference, "initializer list used for `%s', which is neither array nor struct".printf(target_type.ToString()));
return false;
}

Expand All @@ -196,7 +196,7 @@ public override bool check(CodeContext context) {
} else if (!e.value_type.compatible(e.target_type)) {
error = true;
e.error = true;
Report.error(e.source_reference, "Expected initializer of type `%s' but got `%s'".printf(e.target_type.to_string(), e.value_type.to_string()));
Report.error(e.source_reference, "Expected initializer of type `%s' but got `%s'".printf(e.target_type.ToString(), e.value_type.ToString()));
}
}

Expand Down
2 changes: 1 addition & 1 deletion Lang/Expressions/LambdaExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ public override bool check(CodeContext context) {
if (!(target_type is DelegateType)) {
error = true;
if (target_type != null) {
Report.error(source_reference, "Cannot convert lambda expression to `%s'".printf(target_type.to_string()));
Report.error(source_reference, "Cannot convert lambda expression to `%s'".printf(target_type.ToString()));
} else {
Report.error(source_reference, "lambda expression not allowed in this context");
}
Expand Down
6 changes: 3 additions & 3 deletions Lang/Expressions/MemberAccess.cs
Original file line number Diff line number Diff line change
Expand Up @@ -118,12 +118,12 @@ public override void accept_children(CodeVisitor visitor) {
}
}

public override string to_string() {
public override string ToString() {
if (symbol_reference == null || symbol_reference.is_instance_member()) {
if (inner == null) {
return member_name;
} else {
return "%s.%s".printf(inner.to_string(), member_name);
return "%s.%s".printf(inner.ToString(), member_name);
}
} else {
// ensure to always use fully-qualified name
Expand Down Expand Up @@ -444,7 +444,7 @@ public override bool check(CodeContext context) {

string base_type_name = "(null)";
if (inner != null && inner.value_type != null) {
base_type_name = inner.value_type.to_string();
base_type_name = inner.value_type.ToString();
} else if (base_symbol != null) {
base_type_name = base_symbol.get_full_name();
}
Expand Down
2 changes: 1 addition & 1 deletion Lang/Expressions/SliceExpression.cs
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ public override bool check(CodeContext context) {
}

error = true;
Report.error(source_reference, "The expression `%s' does not denote an array".printf(container.value_type.to_string()));
Report.error(source_reference, "The expression `%s' does not denote an array".printf(container.value_type.ToString()));
}

return !error;
Expand Down
Loading

0 comments on commit b957b5e

Please sign in to comment.