Permalink
Browse files

implement Integer vtable init_int and use it in several places where …

…is never HLL mapped

git-svn-id: https://svn.parrot.org/parrot/trunk@46210 d31e2699-5ff4-0310-a27c-f18f2fbe73fe
  • Loading branch information...
1 parent dee89ae commit 75d112fd83089a7d4dffe3d8cf5a9fd7f7cc0afb @NotFound NotFound committed May 1, 2010
@@ -1082,10 +1082,9 @@ mk_multi_sig(PARROT_INTERP, ARGIN(const SymReg *r))
sig_pmc = Parrot_pmc_new(interp, enum_class_String);
VTABLE_set_string_native(interp, sig_pmc, type_name);
}
- else {
- sig_pmc = Parrot_pmc_new(interp, enum_class_Integer);
- VTABLE_set_integer_native(interp, sig_pmc, type_num);
- }
+ else
+ sig_pmc = Parrot_pmc_new_init_int(interp,
+ enum_class_Integer, type_num);
}
else {
PARROT_ASSERT(r->set == 'K');
@@ -208,8 +208,7 @@ EOA
}
elsif ($attrtype eq "INTVAL") {
$decl .= <<"EOA";
- PMC * const attr_value = Parrot_pmc_new(interp, enum_class_Integer); \\
- VTABLE_set_integer_native(interp, attr_value, value); \\
+ PMC * const attr_value = Parrot_pmc_new_init_int(interp, enum_class_Integer, value); \\
VTABLE_set_attr_str(interp, pmc, \\
Parrot_str_new_constant(interp, "$attrname"), attr_value); \\
EOA
View
@@ -97,8 +97,7 @@ new_hll_entry(PARROT_INTERP, ARGIN_NULLOK(STRING *entry_name))
else
VTABLE_push_pmc(interp, hll_info, entry);
- entry_id = Parrot_pmc_new_constant(interp, enum_class_Integer);
- VTABLE_set_integer_native(interp, entry_id, id);
+ entry_id = Parrot_pmc_new_constant_init_int(interp, enum_class_Integer, id);
VTABLE_set_pmc_keyed_int(interp, entry, e_HLL_id, entry_id);
return entry;
@@ -111,10 +111,9 @@ Parrot_mark_method_writes(PARROT_INTERP, int type, ARGIN(const char *name))
{
ASSERT_ARGS(Parrot_mark_method_writes)
STRING *const str_name = Parrot_str_new_constant(interp, name);
- PMC *const pmc_true = Parrot_pmc_new(interp, enum_class_Integer);
+ PMC *const pmc_true = Parrot_pmc_new_init_int(interp, enum_class_Integer, 1);
PMC *const method = VTABLE_get_pmc_keyed_str(
interp, interp->vtables[type]->_namespace, str_name);
- VTABLE_set_integer_native(interp, pmc_true, 1);
VTABLE_setprop(interp, method, CONST_STRING(interp, "write"), pmc_true);
}
View
@@ -648,11 +648,10 @@ Parrot_oo_register_type(PARROT_INTERP, ARGIN(PMC *name), ARGIN(PMC *_namespace))
}
{
if (!typeid_exists) {
- PMC * const classname_hash = interp->class_hash;
- PMC * const item = Parrot_pmc_new(interp, enum_class_Integer);
/* set entry in name->type hash */
- VTABLE_set_integer_native(interp, item, type);
-
+ PMC * const classname_hash = interp->class_hash;
+ PMC * const item = Parrot_pmc_new_init_int(interp,
+ enum_class_Integer, type);
VTABLE_set_pmc_keyed(interp, classname_hash, name, item);
}
}
View
@@ -4525,8 +4525,7 @@ make_annotation_value_pmc(PARROT_INTERP, ARGIN(PackFile_Annotations *self),
switch (type) {
case PF_ANNOTATION_KEY_TYPE_INT:
- result = Parrot_pmc_new(interp, enum_class_Integer);
- VTABLE_set_integer_native(interp, result, value);
+ result = Parrot_pmc_new_init_int(interp, enum_class_Integer, value);
break;
case PF_ANNOTATION_KEY_TYPE_NUM:
result = Parrot_pmc_new(interp, enum_class_Float);
View
@@ -1048,8 +1048,7 @@ Array of Class PMCs representing the direct parents of this class.
VTABLE_set_string_native(INTERP, found, _class->name);
}
else if (Parrot_str_equal(INTERP, what, CONST_STRING(INTERP, "id"))) {
- found = Parrot_pmc_new(INTERP, enum_class_Integer);
- VTABLE_set_integer_native(INTERP, found, _class->id);
+ found = Parrot_pmc_new_init_int(INTERP, enum_class_Integer, _class->id);
}
else if (Parrot_str_equal(INTERP, what, CONST_STRING(INTERP, "namespace"))) {
/* Should not clone this. */
@@ -1071,8 +1070,7 @@ Array of Class PMCs representing the direct parents of this class.
found = _class->roles;
}
else if (Parrot_str_equal(INTERP, what, CONST_STRING(INTERP, "flags"))) {
- found = Parrot_pmc_new(INTERP, enum_class_Integer);
- VTABLE_set_integer_native(INTERP, found,
+ found = Parrot_pmc_new_init_int(INTERP, enum_class_Integer,
(INTVAL)PObj_get_FLAGS(SELF));
}
else
View
@@ -242,8 +242,8 @@ propagate_std_props(PARROT_INTERP, ARGIN(PMC *self), ARGIN(PMC *prop_hash))
ASSERT_ARGS(propagate_std_props)
if (self->vtable->flags & (VTABLE_IS_CONST_FLAG | VTABLE_IS_READONLY_FLAG)){
- PMC * const pmc_true = Parrot_pmc_new(interp, enum_class_Integer);
- VTABLE_set_integer_native(interp, pmc_true, 1);
+ PMC * const pmc_true = Parrot_pmc_new_init_int(interp,
+ enum_class_Integer, 1);
VTABLE_set_pmc_keyed_str(interp, prop_hash, CONST_STRING(interp, "_ro"), pmc_true);
}
}
@@ -290,8 +290,8 @@ check_get_std_props(PARROT_INTERP, ARGIN(const PMC *self), ARGIN(const STRING *k
if ((self->vtable->flags & (VTABLE_IS_CONST_FLAG | VTABLE_IS_READONLY_FLAG))
&& Parrot_str_equal(interp, key, CONST_STRING(interp, "_ro"))) {
- PMC * const ret_val = Parrot_pmc_new(interp, enum_class_Integer);
- VTABLE_set_integer_native(interp, ret_val, 1);
+ PMC * const ret_val = Parrot_pmc_new_init_int(interp,
+ enum_class_Integer, 1);
return ret_val;
}
else
@@ -992,8 +992,7 @@ Provides introspection of a specific piece of information about the PMC.
VTABLE PMC *inspect_str(STRING *name) {
if (Parrot_str_equal(interp, name, CONST_STRING(interp, "flags"))) {
- PMC *found = Parrot_pmc_new(interp, enum_class_Integer);
- VTABLE_set_integer_native(interp, found,
+ PMC *found = Parrot_pmc_new_init_int(interp, enum_class_Integer,
(INTVAL)PObj_get_FLAGS(SELF));
return found;
}
View
@@ -545,26 +545,22 @@ Retrieve an attribute value for the exception object.
if (Parrot_str_equal(INTERP, name, CONST_STRING(INTERP, "type"))) {
INTVAL type;
GET_ATTR_type(interp, SELF, type);
- value = Parrot_pmc_new(interp, enum_class_Integer);
- VTABLE_set_integer_native(interp, value, type);
+ value = Parrot_pmc_new_init_int(interp, enum_class_Integer, type);
}
else if (Parrot_str_equal(INTERP, name, CONST_STRING(INTERP, "severity"))) {
INTVAL severity;
GET_ATTR_severity(interp, SELF, severity);
- value = Parrot_pmc_new(interp, enum_class_Integer);
- VTABLE_set_integer_native(interp, value, severity);
+ value = Parrot_pmc_new_init_int(interp, enum_class_Integer, severity);
}
else if (Parrot_str_equal(INTERP, name, CONST_STRING(INTERP, "exit_code"))) {
INTVAL exit_code;
GET_ATTR_exit_code(interp, SELF, exit_code);
- value = Parrot_pmc_new(interp, enum_class_Integer);
- VTABLE_set_integer_native(interp, value, exit_code);
+ value = Parrot_pmc_new_init_int(interp, enum_class_Integer, exit_code);
}
else if (Parrot_str_equal(INTERP, name, CONST_STRING(INTERP, "handled"))) {
INTVAL handled;
GET_ATTR_handled(interp, SELF, handled);
- value = Parrot_pmc_new(interp, enum_class_Integer);
- VTABLE_set_integer_native(interp, value, handled);
+ value = Parrot_pmc_new_init_int(interp, enum_class_Integer, handled);
}
else if (Parrot_str_equal(INTERP, name, CONST_STRING(INTERP, "message"))) {
STRING *message = SELF.get_string();
@@ -317,9 +317,8 @@ Returns the PMC value of the element at index C<key>.
*/
VTABLE PMC *get_pmc_keyed_int(INTVAL key) {
- PMC * const ret = Parrot_pmc_new(INTERP, enum_class_Integer);
const INTVAL val = SELF.get_integer_keyed_int(key);
- VTABLE_set_integer_native(INTERP, ret, val);
+ PMC * const ret = Parrot_pmc_new_init_int(INTERP, enum_class_Integer, val);
return ret;
}
View
@@ -102,6 +102,13 @@ Initializes the integer with a default value of C<0>.
attrs->iv = VTABLE_get_integer(INTERP, init);
}
+ VTABLE void init_int(INTVAL init) {
+ Parrot_Integer_attributes * const attrs =
+ (Parrot_Integer_attributes *)PMC_data(SELF);
+
+ attrs->iv = init;
+ }
+
/*
=item C<PMC *clone()>
View
@@ -883,11 +883,10 @@ Used to mark a PMC as read-only shared.
UNLOCK_INTERPRETER(master);
ret = SELF;
- _true = Parrot_pmc_new(INTERP, enum_class_Integer);
-
/* Setting the '_ro' property switches to the read-only vtable */
- VTABLE_set_integer_native(INTERP, _true, 1);
+ _true = Parrot_pmc_new_init_int(INTERP, enum_class_Integer, 1);
VTABLE_setprop(INTERP, ret, CONST_STRING(interp, "_ro"), _true);
+
SELF->vtable->pmc_class = master->vtables[type_num]->pmc_class;
Parrot_gc_add_pmc_sync(INTERP, ret);
PObj_is_PMC_shared_SET(ret);
View
@@ -907,8 +907,7 @@ The number of optional named arguments
EXCEPTION_INVALID_OPERATION,
"Unknown introspection value '%S'", what);
- retval = Parrot_pmc_new(INTERP, enum_class_Integer);
- VTABLE_set_integer_native(INTERP, retval, count_found);
+ retval = Parrot_pmc_new_init_int(INTERP, enum_class_Integer, count_found);
return retval;
}

0 comments on commit 75d112f

Please sign in to comment.