Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Fetching contributors…

Cannot retrieve contributors at this time

342 lines (286 sloc) 5.711 kB
/* PMC and Capability-based ops
*/
inline can(var obj, string method) return int
{
int can_do;
${ can can_do, obj, method };
return can_do;
}
inline isa(var obj, var class_obj) return int
{
int isa_class;
${ isa isa_class, obj, class_obj };
return isa_class;
}
inline isa_s(var obj, string type) return int
{
int isa_class;
${ isa isa_class, obj, type };
return isa_class;
}
inline does(var obj, string role) return int
{
int does_role;
${ does does_role, obj, role };
return does_role;
}
inline new_pmc(var class_obj) return var
{
var obj;
${ new obj, class_obj };
return obj;
}
inline new_class(string name) return var
{
var c;
${ newclass c, name };
return c;
}
inline is_defined(var obj) return int
{
int value;
${ defined value, obj };
return value;
}
inline compare_pmcs(var a, var b) return int
{
int value;
${ cmp value, a, b };
return value;
}
/* Time and Scheduling
*/
inline schedule(var task)
{
${ schedule task };
}
inline time_ticks() return int
{
int t;
${ time t };
return t;
}
/* Attributes, Properties and Objects
*/
inline getattribute_private(var obj, var target_class, string attr) return var
{
var value;
${ getattribute value, obj, target_class, attr };
return value;
}
inline setattribute_private(var obj, var target_class, string attr, var value)
{
${ setattribute obj, target_class, attr, value };
}
inline inspect(var obj) return var
{
var value;
${ inspect value, obj };
return value;
}
inline inspect_named(var obj, string property) return var
{
var value;
${ inspect value, obj, property };
return value;
}
inline get_property(var obj, string name) return var
{
var value;
${ getprop value, name, obj };
return value;
}
inline set_property(var obj, string name, var value)
{
${ setprop obj, name, value };
}
/* Aggregates and Arrays
*/
inline shift_pmc(var obj) return var
{
var value;
${ shift value, obj };
return value;
}
inline shift_int(var i) return int
{
int value;
${ shift value, i };
return value;
}
inline shift_string(var i) return string
{
string value;
${ shift value, i };
return value;
}
inline unshift_int(var s, int i)
{
${ unshift s, i };
}
inline pop_pmc(var obj) return var
{
var value;
${ pop value, obj };
return value;
}
inline pop_string(var obj) return string
{
string value;
${ pop value, obj };
return value;
}
inline get_iterator(var obj) return var
{
var i;
${ iter i, obj };
return i;
}
inline get_bool(var p) return int
{
return p ? true : false;
}
/* String Operations
*/
inline is_cclass(int cclass, string str, int start) return int
{
int is;
${ is_cclass is, cclass, str, start };
return is;
}
inline find_not_cclass(int cclass, string s, int start_idx, int len) return int
{
int idx;
${ find_not_cclass idx, cclass, s, start_idx, len };
return idx;
}
inline find_cclass(int cclass, string s, int start_idx, int len) return int
{
int idx;
${ find_cclass idx, cclass, s, start_idx, len };
return idx;
}
inline repeat_string(string s, int c) return string
{
string value;
${ repeat value, s, c };
return value;
}
inline index_of_substr(string s, string n) return int
{
int value;
${ index value, s, n };
return value;
}
inline index_of_substr_from(string s, string n, int i) return int
{
int value;
${ index value, s, n, i };
return value;
}
inline contains_substr(string s, string n) return int
{
int value;
${ index value, s, n };
return value == -1 ? false : true;
}
inline format_string(string f, var v) return string
{
return sprintf(f, [v]);
}
inline string_has_prefix(string f, string p) return int
{
int len_p = length(p);
return length(f) > len_p && substr(f, 0, len_p) == p;
}
inline get_encoding_id(string name) return int
{
int value;
${ find_encoding value, name };
return value;
}
inline get_string_encoding(string s) return int
{
int value;
${ encoding value, s };
return value;
}
inline reencode_string(string s, int e) return string
{
string value;
${ trans_encoding value, s, e };
return value;
}
inline string_to_lower(string s) return string
{
string value;
${ downcase value, s };
return value;
}
inline string_to_upper(string s) return string
{
string value;
${ upcase value, s };
return value;
}
// For ASCII-related things, look in src/include/Ascii.winxed
/* Namespaces
*/
inline get_namespace(var key) return var
{
var value;
${ get_namespace value, key };
return value;
}
inline get_hll_namespace(var key) return var
{
var value;
${ get_hll_namespace value, key };
return value;
}
/* Interp Stuff
*/
inline get_context() return var
{
var cc;
${ get_context cc };
return cc;
}
/* Data Structures
*/
$include_const "hash_key_type.pasm";
inline pmc_keyed_hash() return var
{
var h = new 'Hash';
//h =: Hash_key_type_PMC;
h.set_key_type(Hash_key_type_PMC);
return h;
}
inline int_keyed_hash() return var
{
var h = new 'Hash';
//h =: Hash_key_type_int;
h.set_key_type(Hash_key_type_int);
return h;
}
inline fixed_integer_array(int i) return var
{
var a = new 'FixedIntegerArray';
//a =: i;
${ assign a, i };
return a;
}
inline fixed_string_array(int i) return var
{
var a = new 'FixedStringArray';
//a =: i;
${ assign a, i };
return a;
}
inline fixed_pmc_array(int i) return var
{
var a = new 'FixedPMCArray';
//a =: i;
${ assign a, i };
return a;
}
Jump to Line
Something went wrong with that request. Please try again.