Beispiel #1
0
extent_list init_extent(const_extent_list ranges,
			const_index_entry_list quantifier_indices,
			const_user_type_entry_list user_type_table)
{
    register unsigned int ix;

    extent_list extent = new_extent_list();
    for (ix = 0; ix < ranges->sz; ix++) {
	int v = eval_int_expr(ranges->arr[ix]->from, quantifier_indices, user_type_table);
	append_extent_list(extent,
			   new_extent(to_expr(new_expr_int(to_type(new_int_type()), v)),
				      to_expr(new_expr_int(to_type(new_int_type()), v))));
    }
    return extent;
}
Beispiel #2
0
static int infer_types_quantifier_index(expr_variable var,
                                        orig_symbol_list var_name,
                                        extent_list_list var_ranges,
                                        lydia_symbol location,
                                        int fg_function)
{
    if (var_ranges->arr[0] != extent_listNIL) {
        leh_error(ERR_TYPE_NOT_ARRAY,
                  fg_function,
                  var_name->arr[0]->org,
                  location->name,
                  var_name->arr[0]->sym->name);
        return 0;
    }
    if (var_name->sz > 1) {
        leh_error(ERR_TYPE_NOT_STRUCT,
                  fg_function,
                  var_name->arr[0]->org,
                  location->name,
                  var_name->arr[0]->sym->name);
        return 0;
    }
    var->type = to_type(new_int_type());

    return 1;
}
Beispiel #3
0
int bmfs_size_parse(struct BMFSSize *size, const char *str)
{
	if ((size == NULL) || (str == NULL))
		return -EFAULT;

	bmfs_uint64 value = 0;

	while (*str)
	{
		char c = *str;
		if ((c < '0') || (c > '9'))
			break;

		value *= 10;

		value += (c - '0');

		str++;
	}

	int err = to_type(str, &size->Suffix);
	if (err != 0)
		return err;

	size->Value = value;

	return 0;
}
Beispiel #4
0
static int infer_types_enum_constant(expr_variable var,
                                     orig_symbol_list var_name,
                                     extent_list_list var_ranges,
                                     enum_user_type_entry enum_type_entry,
                                     lydia_symbol location,
                                     int fg_function)
{
    if (var_name->sz == 1) {
/* There is no selector. */
        leh_error(ERR_TYPE_ENUM_NOSEL,
                  fg_function,
                  var_name->arr[0]->org,
                  location->name,
                  var_name->arr[0]->sym->name);
        return 0;
    }
    if (var_ranges->arr[0] != extent_listNIL) {
        leh_error(ERR_TYPE_NOT_ARRAY,
                  fg_function,
                  var_name->arr[0]->org,
                  location->name,
                  var_name->arr[0]->sym->name);
        return 0;
    }
    if (var_name->sz != 2 ||
        !member_orig_symbol_list(enum_type_entry->entries,
                                 var_name->arr[1]->sym)) {
        leh_error(ERR_TYPE_ENUM_BADSEL,
                  fg_function,
                  var_name->arr[0]->org,
                  location->name,
                  var_name->arr[0]->sym->name);
        return 0;
    }
    if (var_ranges->arr[1] != extent_listNIL) {
        leh_error(ERR_TYPE_NOT_ARRAY,
                  fg_function,
                  var_name->arr[1]->org,
                  location->name,
                  var_name->arr[1]->sym->name);
        return 0;
    }
    var->type = to_type(new_user_type(rdup_orig_symbol(var_name->arr[0])));

    return 1;
}
Beispiel #5
0
extent_list advance_extent(extent_list extent,
			   const_extent_list ranges,
			   const_index_entry_list quantifier_indices,
			   const_user_type_entry_list user_type_table)
{
    register unsigned int ix;

    assert(extent->sz == ranges->sz);

    for (ix = extent->sz - 1; ix < extent->sz; ix--) {
	int p = eval_int_expr(extent->arr[ix]->from, quantifier_indices, user_type_table);
	int s = eval_int_expr(extent->arr[ix]->to, quantifier_indices, user_type_table);
	int r = eval_int_expr(ranges->arr[ix]->from, quantifier_indices, user_type_table);
	int q = eval_int_expr(ranges->arr[ix]->to, quantifier_indices, user_type_table);

	rfre_expr(extent->arr[ix]->from);
	rfre_expr(extent->arr[ix]->to);
	if (r < q) {
	    if (p < q) {
		p += 1;
		s += 1;
		extent->arr[ix]->from = to_expr(new_expr_int(to_type(new_int_type()), p));
		extent->arr[ix]->to = to_expr(new_expr_int(to_type(new_int_type()), s));
		break;
	    }
	} else {
	    if (p > q) {
		p -= 1;
		s -= 1;
		extent->arr[ix]->from = to_expr(new_expr_int(to_type(new_int_type()), p));
		extent->arr[ix]->to = to_expr(new_expr_int(to_type(new_int_type()), s));
		break;
	    }
	}
	extent->arr[ix]->from = to_expr(new_expr_int(to_type(new_int_type()), r));
	extent->arr[ix]->to = to_expr(new_expr_int(to_type(new_int_type()), r));
    }

    if (ix >= extent->sz) {
	rfre_extent_list(extent);
	return extent_listNIL;
    }

    return extent;
}
Beispiel #6
0
	void store(lua_State* L, int n)
	{
		this->value_ = boost::shared_ptr<T>(to_type(L, n));
	}
Beispiel #7
0
map <Type::InputType, vector< vector<Integer> > > readNormalizInput (istream& in, OptionsHandler& options) {

    string type_string;
    long i,j;
    long nr_rows,nr_columns;
    InputType input_type;
    Integer number;
    ConeProperty::Enum cp;

    map<Type::InputType, vector< vector<Integer> > > input_map;
    typename map<Type::InputType, vector< vector<Integer> > >::iterator it;

    in >> std::ws;  // eat up any leading white spaces
    int c = in.peek();
    if ( c == EOF ) {
        cerr << "Error: Empty input file!" << endl;
        throw BadInputException();
    }
    bool new_input_syntax = !std::isdigit(c);

    if (new_input_syntax) {
        long dim;
        while (in.peek() == '/') {
            skip_comment(in);
            in >> std::ws;
        }
        in >> type_string;
        if (!in.good() || type_string != "amb_space") {
            cerr << "Error: First entry must be \"amb_space\"!" << endl;
            throw BadInputException();
        }
        in >> dim;
        if (!in.good() || dim <= 0) {
            cerr << "Error: Bad amb_space value!" << endl;
            throw BadInputException();
        }
        while (in.good()) {
            in >> std::ws;  // eat up any leading white spaces
            c = in.peek();
            if (c == EOF) break;
            if (c == '/') {
                skip_comment(in);
            } else {
                in >> type_string;
                if (in.fail()) {
                    cerr << "Error: Could not read type string!" << endl;
                    throw BadInputException();
                }
                if (std::isdigit(c)) {
                    cerr << "Error: Unexpected number "<< type_string << " when expecting a type !" << endl;
                    throw BadInputException();
                }
                if (isConeProperty(cp, type_string)) {
                    options.activateInputFileConeProperty(cp);
                    continue;
                }
                if (type_string == "BigInt") {
                    options.activateInputFileBigInt();
                    continue;
                }
                if (type_string == "total_degree") {
                    input_type = Type::grading;
                    save_matrix(input_map, input_type, type_string, vector< vector<Integer> >(1,vector<Integer>(dim+type_nr_columns_correction(input_type),1)));
                    continue;
                }
                if (type_string == "nonnegative") {
                    input_type = Type::signs;
                    save_matrix(input_map, input_type, type_string, vector< vector<Integer> >(1,vector<Integer>(dim+type_nr_columns_correction(input_type),1)));
                    continue;
                }


                input_type = to_type(type_string);

                if (type_is_vector(input_type)) {
                    nr_rows = 1;
                    in >> std::ws;  // eat up any leading white spaces
                    c = in.peek();
                    if (!std::isdigit(c) && c != '-') {
                        string vec_kind;
                        in >> vec_kind;
                        if (vec_kind == "unit_vector") {
                            long pos = 0;
                            in >> pos;
                            if (in.fail()) {
                                cerr << "Error while reading " << type_string << " as a unit_vector form the input!" << endl;
                                throw BadInputException();
                            }

                            vector< vector<Integer> > e_i = vector< vector<Integer> >(1,vector<Integer>(dim+type_nr_columns_correction(input_type),0));
                            if (pos < 1 || pos > static_cast<long>(e_i[0].size())) {
                                cerr << "Error while reading " << type_string << " as a unit_vector "<< pos <<" form the input!" << endl;
                                throw BadInputException();
                            }
                            pos--; // in input file counting starts from 1
                            e_i[0].at(pos) = 1;
                            save_matrix(input_map, input_type, type_string, e_i);
                            continue;
                        }
                    }
                } else {
                    in >> nr_rows;
                }
                nr_columns = dim + type_nr_columns_correction(input_type);
                if(in.fail() || nr_rows < 0) {
                    cerr << "Error while reading " << type_string << " (a "<<nr_rows<<"x"<<nr_columns<<" matrix) form the input!" << endl;
                    throw BadInputException();
                }
                vector< vector<Integer> > M(nr_rows,vector<Integer>(nr_columns));
                for(i=0; i<nr_rows; i++){
                    for(j=0; j<nr_columns; j++) {
                        in >> M[i][j];
                    }
                }
                save_matrix(input_map, input_type, type_string, M);
            }
Beispiel #8
0
	void store(lua_State* L, int n)
	{
		this->value_ = std::shared_ptr<T>(to_type(L, lua_absindex(L, n)));
	}