Beispiel #1
0
/**	Fetches the property requested and uses the appropriate op on the value.
	@return boolean value
**/
static int compare_property_alt(OBJECT *obj, char *propname, FINDOP op, void *value){
	complex *complex_target = NULL;
	char *char_target = NULL;
	int16 *int16_target = NULL;
	int32 *int32_target = NULL;
	int64 *int64_target = NULL;
	PROPERTY *prop = object_get_property(obj, propname);

	if(prop == NULL){
		/* property not found in object ~ normal operation */
		return 0;
	}

	switch(prop->ptype){
		case PT_void:
			return 0;	/* no comparsion to be made */
		case PT_double:
			break;
		case PT_complex:
			complex_target = object_get_complex(obj, prop);
			if(complex_target == NULL)
				return 0; /* error value */
			break;
		case PT_enumeration:
		case PT_set:
			break;		/* not 100% sure how to make these cooperate yet */
		case PT_int16:
			int16_target = (int16 *)object_get_int16(obj, prop);
			if(int16_target == NULL)
				return 0;
			return compare_int16(*int16_target, op, *(int64 *)value);
		case PT_int32:
			int32_target = (int32 *)object_get_int32(obj, prop);
			return compare_int32(*int32_target, op, *(int64 *)value);
			break;
		case PT_int64:
			int64_target = (int64 *)object_get_int64(obj, prop);
			return compare_int64(*int64_target, op, *(int64 *)value);
			break;
		case PT_char8:
		case PT_char32:
		case PT_char256:
		case PT_char1024:
			char_target = (char *)object_get_string(obj, prop);
			if(char_target == NULL)
				return 0;
			return compare_string(char_target, op, value);
			break;
		case PT_object:

			break;
		case PT_bool:
			break;
		case PT_timestamp:
		case PT_double_array:
		case PT_complex_array:
			break;
#ifdef USE_TRIPLETS
		case PT_triple:
		case PT_triplex:
			break;
#endif
		default:
			output_error("comparison operators not supported for property type %s", class_get_property_typename(prop->ptype));
			/* TROUBLESHOOT
				This error is caused when an object find procedure uses a comparison operator
			that isn't allowed on a that type of property.  Make sure the property type
			and the comparison operator are compatible and try again.  If your GLM file
			isn't the cause of the problem, try reducing the complexity of the GLM file 
			you are using to isolate which module is causing the error and file a report 
			with the GLM file attached.
			 */
			return 0;
	}
}
Beispiel #2
0
INTERNAL cList *add_op_arg(cList * out, Int type, Long op, Method * method)
{
    Obj *obj = method->object;
    cData d;

    switch (type) {
    case INTEGER:
        d.type = INTEGER;
        d.u.val = op;
        break;
    case FLOAT:
        d.type = FLOAT;
        d.u.fval = *((Float *) (&op));
        break;
    case T_ERROR:
        if (op == -1) {
            d.type = INTEGER;
            d.u.val = -1;
        } else {
            d.type = T_ERROR;
            d.u.error = object_get_ident(obj, op);
        }
        break;
    case IDENT:
        d.type = SYMBOL;
        d.u.symbol = object_get_ident(obj, op);
        break;
    case VAR:
        {
            Long id;

            d.type = SYMBOL;

            if (op < method->num_args) {
                op = method->num_args - op - 1;
                id = object_get_ident(obj, method->argnames[op]);
                d.u.symbol = id;
                break;
            }
            op -= method->num_args;

            if (method->rest != -1) {
                if (op == 0) {
                    id = object_get_ident(obj, method->rest);
                    d.u.symbol = id;
                    break;
                }
                op--;
            }

            id = object_get_ident(obj, method->varnames[op]);
            d.u.symbol = id;
            break;
        }
    case STRING:
        d.type = STRING;
        d.u.str = object_get_string(obj, op);
        break;
        /* case JUMP: *//* ignore JUMP */
    default:
        return out;
#if DISABLED                    /* none of these are used as args in op_table */
    case LIST:
    case FROB:
    case DICT:
    case BUFFER:
#endif
    }

    out = list_add(out, &d);
    /* do not discard, we were not using duped data */

    return out;
}

COLDC_FUNC(method_bytecode)
{
    cData *args, d;
    Method *method;
    cList *list;
    register Int x;
    Long *ops;
    Op_info *info;
    Long opcode;

    /* Accept a list of lines of code and a symbol for the name. */
    if (!func_init_1(&args, SYMBOL))
        return;

    method = object_find_method(cur_frame->object->objnum, args[0].u.symbol, FROB_ANY);

    /* keep these for later reference, if its already around */
    if (!method)
        THROW((methodnf_id, "Method %D not found.", &args[0]))

    list = list_new(method->num_opcodes);
    d.type = SYMBOL;
    ops = method->opcodes;
    x = 0;
    while (x < method->num_opcodes) {
        opcode = ops[x];
        info = &op_table[opcode];
        d.type = SYMBOL;
        d.u.symbol = info->symbol;
        list = list_add(list, &d);
        /* dont bother discarding, we didnt dup twice */
        x++;

        if (info->arg1) {
            list = add_op_arg(list, info->arg1, ops[x], method);
            x++;
        }

        if (info->arg2) {
            list = add_op_arg(list, info->arg1, ops[x], method);
            x++;
        }
    }

    pop(1);
    push_list(list);
    list_discard(list);
}