aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Anderson <[email protected]>2011-04-11 20:21:28 -0400
committerBrian Anderson <[email protected]>2011-04-11 21:51:23 -0400
commitce85b9eb7be9a964460a71c8b30e35693df07340 (patch)
treefd25df88f041e101fd2c6240b2ea2cb3d6413f7d
parentMove extfmt parsing into standard library (diff)
downloadrust-ce85b9eb7be9a964460a71c8b30e35693df07340.tar.xz
rust-ce85b9eb7be9a964460a71c8b30e35693df07340.zip
Make ExtFmt call its own functions instead of others defined in std
-rw-r--r--src/comp/front/extfmt.rs10
-rw-r--r--src/lib/ExtFmt.rs11
2 files changed, 15 insertions, 6 deletions
diff --git a/src/comp/front/extfmt.rs b/src/comp/front/extfmt.rs
index aecd7934..f0ae31dc 100644
--- a/src/comp/front/extfmt.rs
+++ b/src/comp/front/extfmt.rs
@@ -168,15 +168,13 @@ fn pieces_to_expr(vec[piece] pieces, vec[@ast.expr] args) -> @ast.expr {
case (ty_int(?sign)) {
alt (sign) {
case (signed) {
- let vec[str] path = vec("std", "_int", "to_str");
- auto radix_expr = make_new_uint(arg.span, 10u);
- let vec[@ast.expr] args = vec(arg, radix_expr);
+ let vec[str] path = vec("std", "ExtFmt", "RT", "int_to_str");
+ let vec[@ast.expr] args = vec(arg);
ret make_call(arg.span, path, args);
}
case (unsigned) {
- let vec[str] path = vec("std", "_uint", "to_str");
- auto radix_expr = make_new_uint(arg.span, 10u);
- let vec[@ast.expr] args = vec(arg, radix_expr);
+ let vec[str] path = vec("std", "ExtFmt", "RT", "int_to_str");
+ let vec[@ast.expr] args = vec(arg);
ret make_call(arg.span, path, args);
}
}
diff --git a/src/lib/ExtFmt.rs b/src/lib/ExtFmt.rs
index f7487eec..144406cf 100644
--- a/src/lib/ExtFmt.rs
+++ b/src/lib/ExtFmt.rs
@@ -258,3 +258,14 @@ fn parse_type(str s, uint i, uint lim) -> tup(ty, uint) {
ret tup(t, i + 1u);
}
+
+// Functions used by the fmt extension at runtime
+mod RT {
+ fn int_to_str(int i) -> str {
+ ret _int.to_str(i, 10u);
+ }
+
+ fn uint_to_str(uint u) -> str {
+ ret _uint.to_str(u, 10u);
+ }
+}