Permalink
Browse files

[Builtins] Rename/rearrange a few builtins. We want to separate them …

…from Parrot opcodes and make more clear what they do
  • Loading branch information...
1 parent 6f0e006 commit ec859c9e84fb40707c4dbe1015901fb72e415f45 @Whiteknight committed Mar 29, 2012
@@ -98,7 +98,7 @@ class Rosella.Container.Option.Property : Rosella.Container.Option
var value = self.value;
if (value instanceof Rosella.Container.Argument)
value = value.get_value(container);
- setprop(instance, prop, value);
+ set_property(instance, prop, value);
}
}
View
@@ -138,11 +138,11 @@ class Rosella.Parrot.ExceptionFormatter : Rosella.StringFormatter
ns = join(".", ns_parts);
}
- if (contains(f, "NS")) f = f.replace("NS", ns);
- if (contains(f, "HLL")) f = f.replace("HLL", hll_ns);
- if (contains(f, "SUB")) f = f.replace("SUB", subname);
- if (contains(f, "FILE")) f = f.replace("FILE", filename);
- if (contains(f, "LINE")) f = f.replace("LINE", string(lineno));
+ if (contains_substr(f, "NS")) f = f.replace("NS", ns);
+ if (contains_substr(f, "HLL")) f = f.replace("HLL", hll_ns);
+ if (contains_substr(f, "SUB")) f = f.replace("SUB", subname);
+ if (contains_substr(f, "FILE")) f = f.replace("FILE", filename);
+ if (contains_substr(f, "LINE")) f = f.replace("LINE", string(lineno));
return sub, f;
}
View
@@ -37,7 +37,7 @@ namespace Rosella.Date
// Get a Date object representing the current instant
function now()
{
- return new Rosella.Date(time_i());
+ return new Rosella.Date(time_ticks());
}
// Get a Date object representing the minimum representable date. This
@@ -11,35 +11,35 @@ class Rosella.Date.DateFormatter : Rosella.StringFormatter
// TODO: Find an algorithm which isn't so slow and wasteful
function format(var obj, string f)
{
- if (contains(f, "yyyy")) f = f.replace("yyyy", format("%04d", obj.year()));
- if (contains(f, "MMMM")) f = f.replace("MMMM", obj.month_name());
- if (contains(f, "MMM")) f = f.replace("MMM", substr(obj.month_name(), 0, 3));
- if (contains(f, "MM")) f = f.replace("MM", format("%02d", obj.month()));
- if (contains(f, "dd")) f = f.replace("dd", format("%02d", obj.day()));
- if (contains(f, "AA")) {
+ if (contains_substr(f, "yyyy")) f = f.replace("yyyy", format_string("%04d", obj.year()));
+ if (contains_substr(f, "MMMM")) f = f.replace("MMMM", obj.month_name());
+ if (contains_substr(f, "MMM")) f = f.replace("MMM", substr(obj.month_name(), 0, 3));
+ if (contains_substr(f, "MM")) f = f.replace("MM", format_string("%02d", obj.month()));
+ if (contains_substr(f, "dd")) f = f.replace("dd", format_string("%02d", obj.day()));
+ if (contains_substr(f, "AA")) {
int hours = obj.hours();
if (hours > 12)
f = f.replace("AA", "PM");
else
f = f.replace("AA", "AM");
}
- if (contains(f, "HHH")) {
+ if (contains_substr(f, "HHH")) {
int hours = obj.hours();
if (hours > 12)
hours = hours - 12;
- f = f.replace("HHH", format("%2d", hours));
+ f = f.replace("HHH", format_string("%2d", hours));
}
- if (contains(f, "HH")) {
+ if (contains_substr(f, "HH")) {
int hours = obj.hours();
if (hours > 12)
hours = hours - 12;
- f = f.replace("HH", format("%d", hours));
+ f = f.replace("HH", format_string("%d", hours));
}
- if (contains(f, "ww")) f = f.replace("ww", format("%02d", obj.week_day()));
- if (contains(f, "WW")) f = f.replace("WW", obj.week_day_name());
- if (contains(f, "hh")) f = f.replace("hh", format("%02d", obj.hours()));
- if (contains(f, "mm")) f = f.replace("mm", format("%02d", obj.minutes()));
- if (contains(f, "ss")) f = f.replace("ss", format("%02d", obj.seconds()));
+ if (contains_substr(f, "ww")) f = f.replace("ww", format_string("%02d", obj.week_day()));
+ if (contains_substr(f, "WW")) f = f.replace("WW", obj.week_day_name());
+ if (contains_substr(f, "hh")) f = f.replace("hh", format_string("%02d", obj.hours()));
+ if (contains_substr(f, "mm")) f = f.replace("mm", format_string("%02d", obj.minutes()));
+ if (contains_substr(f, "ss")) f = f.replace("ss", format_string("%02d", obj.seconds()));
return f;
}
@@ -10,10 +10,10 @@ class Rosella.Date.TimeSpanFormatter : Rosella.StringFormatter
// Format the TimeSpan object
function format(var obj, string f)
{
- if (contains(f, "dd")) f = f.replace("dd", format("%02d", obj.days()));
- if (contains(f, "hh")) f = f.replace("hh", format("%02d", obj.hours()));
- if (contains(f, "mm")) f = f.replace("mm", format("%02d", obj.minutes()));
- if (contains(f, "ss")) f = f.replace("ss", format("%02d", obj.seconds()));
+ if (contains_substr(f, "dd")) f = f.replace("dd", format_string("%02d", obj.days()));
+ if (contains_substr(f, "hh")) f = f.replace("hh", format_string("%02d", obj.hours()));
+ if (contains_substr(f, "mm")) f = f.replace("mm", format_string("%02d", obj.minutes()));
+ if (contains_substr(f, "ss")) f = f.replace("ss", format_string("%02d", obj.seconds()));
return f;
}
View
@@ -51,7 +51,7 @@ class Rosella.Harness.View
function start_test(string name)
{
int diff = int(self.line_length) - length(name) + MIN_NUM_ELLIPSES;
- string elipses = repeat(".", diff);
+ string elipses = repeat_string(".", diff);
self.printf("%s %s ", name, elipses);
}
@@ -60,7 +60,7 @@ class Rosella.Harness.View
{
if (self.need_backspaces > 0) {
int num_b = int(self.need_backspaces);
- string b = repeat("\b", num_b);
+ string b = repeat_string("\b", num_b);
self.printf(b + " ");
self.need_backspaces = 0;
}
@@ -74,7 +74,7 @@ class Rosella.Harness.View
{
if (self.need_backspaces > 0) {
int num_b = int(self.need_backspaces);
- string b = repeat("\b", num_b);
+ string b = repeat_string("\b", num_b);
self.printf(b + " ");
self.need_backspaces = 0;
}
@@ -36,21 +36,21 @@ inline new_pmc(var class_obj) return var
return obj;
}
-inline newclass(string name) return var
+inline new_class(string name) return var
{
var c;
${ newclass c, name };
return c;
}
-inline defined(var obj) return int
+inline is_defined(var obj) return int
{
int value;
${ defined value, obj };
return value;
}
-inline cmp_p(var a, var b) return int
+inline compare_pmcs(var a, var b) return int
{
int value;
${ cmp value, a, b };
@@ -65,7 +65,7 @@ inline schedule(var task)
${ schedule task };
}
-inline time_i() return int
+inline time_ticks() return int
{
int t;
${ time t };
@@ -94,43 +94,43 @@ inline inspect(var obj) return var
return value;
}
-inline inspect_s(var obj, string property) return var
+inline inspect_named(var obj, string property) return var
{
var value;
${ inspect value, obj, property };
return value;
}
-inline getprop(var obj, string name) return var
+inline get_property(var obj, string name) return var
{
var value;
${ getprop value, name, obj };
return value;
}
-inline setprop(var obj, string name, var value)
+inline set_property(var obj, string name, var value)
{
${ setprop obj, name, value };
}
/* Aggregates and Arrays
*/
-inline shift_p(var obj) return var
+inline shift_pmc(var obj) return var
{
var value;
${ shift value, obj };
return value;
}
-inline pop_p(var obj) return var
+inline pop_pmc(var obj) return var
{
var value;
${ pop value, obj };
return value;
}
-inline iter(var obj) return var
+inline get_iterator(var obj) return var
{
var i;
${ iter i, obj };
@@ -166,42 +166,35 @@ inline find_cclass(int cclass, string s, int start_idx, int len) return int
return idx;
}
-inline repeat(string s, int c) return string
+inline repeat_string(string s, int c) return string
{
string value;
${ repeat value, s, c };
return value;
}
-inline index(string s, string n) return int
+inline index_of_substr(string s, string n) return int
{
int value;
${ index value, s, n };
return value;
}
-inline index_issi(string s, string n, int i) return int
+inline index_of_substr_from(string s, string n, int i) return int
{
int value;
${ index value, s, n, i };
return value;
}
-inline contains(string s, string n) return int
+inline contains_substr(string s, string n) return int
{
int value;
${ index value, s, n };
return value == -1 ? false : true;
}
-inline index_ssi(string s, string n, int idx) return int
-{
- int value;
- ${ index value, s, n, idx };
- return value;
-}
-
-inline format(string f, var v) return string
+inline format_string(string f, var v) return string
{
return sprintf(f, [v]);
}
@@ -212,42 +205,35 @@ inline string_has_prefix(string f, string p) return int
return length(f) > len_p && substr(f, 0, len_p) == p;
}
-inline find_encoding(string name) return int
+inline get_encoding_id(string name) return int
{
int value;
${ find_encoding value, name };
return value;
}
-inline encoding(string s) return int
+inline get_string_encoding(string s) return int
{
int value;
${ encoding value, s };
return value;
}
-inline trans_encoding(string s, int e) return string
+inline reencode_string(string s, int e) return string
{
string value;
${ trans_encoding value, s, e };
return value;
}
-inline chr(int i) return string
+inline codepoint_to_string(int i) return string
{
string value;
${ chr value, i };
return value;
}
-inline ord(string s) return int
-{
- int value;
- ${ ord value, s };
- return value;
-}
-
-inline ord_isi(string s, int i) return int
+inline get_codepoint(string s, int i) return int
{
int value;
${ ord value, s, i };
View
@@ -80,7 +80,7 @@ class Rosella.Proxy.Factory : Rosella.ObjectFactory
int id = Rosella.get_unique_count();
string proxy_class_name = sprintf("!!!PROXY_%s_%d", [string(target_class), id]);
- var proxy_class = newclass(proxy_class_name);
+ var proxy_class = new_class(proxy_class_name);
Rosella.Proxy.add_proxy_class_private_attr(proxy_class, "proxy_controller");
Rosella.Proxy.add_proxy_class_private_attr(proxy_class, "proxy_factory");
Rosella.Proxy.add_proxy_class_private_attr(proxy_class, "target_class");
View
@@ -48,7 +48,7 @@ namespace Rosella.Proxy
// Add a vtable override
function add_vtable_override(var proxy_class, string name, var override)
{
- var overrides = inspect_s(proxy_class, "vtable_overrides");
+ var overrides = inspect_named(proxy_class, "vtable_overrides");
overrides[name] = override;
}
}
@@ -257,7 +257,7 @@ class Rosella.Query.Queryable
// Get an iterator over the data
function get_iter[vtable]()
{
- return iter(self.data);
+ return get_iterator(self.data);
}
/*
View
@@ -92,15 +92,15 @@ namespace Rosella.Query.Sort
function get_default_comparer()
{
return function (var a, var b) {
- return cmp_p(a, b);
+ return compare_pmcs(a, b);
};
}
// Reverse sort routine
function get_reverse_comparer()
{
return function (var a, var b) {
- return -(cmp_p(a, b));
+ return -(compare_pmcs(a, b));
};
}
Oops, something went wrong.

0 comments on commit ec859c9

Please sign in to comment.