else if (lhs_type->is_slice_type() && rhs_type->is_nil_type())
{
// Assigning nil to a slice.
- mpz_t zval;
- mpz_init_set_ui(zval, 0UL);
- Expression* zero = Expression::make_integer(&zval, NULL, location);
- mpz_clear(zval);
Expression* nil = Expression::make_nil(location);
+ Expression* zero = Expression::make_integer_ul(0, NULL, location);
return Expression::make_slice_value(lhs_type, nil, zero, zero, location);
}
else if (rhs_type->is_nil_type())
Expression* index_overflows = Expression::make_boolean(false, loc);
if (!val_is_unsigned)
{
- mpz_t zval;
- mpz_init_set_ui(zval, 0UL);
- Expression* zero = Expression::make_integer(&zval, val_type, loc);
- mpz_clear(zval);
-
+ Expression* zero = Expression::make_integer_ul(0, val_type, loc);
negative_index = Expression::make_binary(OPERATOR_LT, val, zero, loc);
}
mpz_init(maxval);
mpz_mul_2exp(maxval, one, bound_type_size - 1);
mpz_sub_ui(maxval, maxval, 1);
- Expression* max = Expression::make_integer(&maxval, val_type, loc);
+ Expression* max = Expression::make_integer_z(&maxval, val_type, loc);
mpz_clear(one);
mpz_clear(maxval);
return Expression::make_character(&this->val_, this->type_,
this->location());
else
- return Expression::make_integer(&this->val_, this->type_,
- this->location());
+ return Expression::make_integer_z(&this->val_, this->type_,
+ this->location());
}
void
if (is_character_constant)
ret = Expression::make_character(&val, NULL, imp->location());
else
- ret = Expression::make_integer(&val, NULL, imp->location());
+ ret = Expression::make_integer_z(&val, NULL, imp->location());
mpz_clear(val);
return ret;
}
ast_dump_context->ostream() << '\'';
}
-// Build a new integer value.
+// Build a new integer value from a multi-precision integer.
Expression*
-Expression::make_integer(const mpz_t* val, Type* type, Location location)
+Expression::make_integer_z(const mpz_t* val, Type* type, Location location)
{
return new Integer_expression(val, type, false, location);
}
+// Build a new integer value from an unsigned long.
+
+Expression*
+Expression::make_integer_ul(unsigned long val, Type *type, Location location)
+{
+ mpz_t zval;
+ mpz_init_set_ui(zval, val);
+ Expression* ret = Expression::make_integer_z(&zval, type, location);
+ mpz_clear(zval);
+ return ret;
+}
+
+// Build a new integer value from a signed long.
+
+Expression*
+Expression::make_integer_sl(long val, Type *type, Location location)
+{
+ mpz_t zval;
+ mpz_init_set_si(zval, val);
+ Expression* ret = Expression::make_integer_z(&zval, type, location);
+ mpz_clear(zval);
+ return ret;
+}
+
// Build a new character constant value.
Expression*
"iota is only defined in const declarations");
iota_value = 0;
}
- mpz_t val;
- mpz_init_set_ui(val, static_cast<unsigned long>(iota_value));
- Expression* ret = Expression::make_integer(&val, NULL,
- this->location());
- mpz_clear(val);
- return ret;
+ return Expression::make_integer_ul(iota_value, NULL, this->location());
}
// Make sure that the constant itself has been lowered.
p != s.end();
p++)
{
- mpz_t val;
- mpz_init_set_ui(val, static_cast<unsigned char>(*p));
- Expression* v = Expression::make_integer(&val,
- element_type,
- location);
- vals->push_back(v);
- mpz_clear(val);
+ unsigned char c = static_cast<unsigned char>(*p);
+ vals->push_back(Expression::make_integer_ul(c,
+ element_type,
+ location));
}
}
else
adv = 1;
}
p += adv;
- mpz_t val;
- mpz_init_set_ui(val, c);
- Expression* v = Expression::make_integer(&val,
- element_type,
- location);
- vals->push_back(v);
- mpz_clear(val);
+ vals->push_back(Expression::make_integer_ul(c,
+ element_type,
+ location));
}
}
TYPE_INFO_SIZE);
Expression* call = Runtime::make_call(Runtime::MEMCMP, loc, 3, a1, a2, len);
-
- mpz_t zval;
- mpz_init_set_ui(zval, 0);
- Expression* zero = Expression::make_integer(&zval, NULL, loc);
- mpz_clear(zval);
-
+ Expression* zero = Expression::make_integer_ul(0, NULL, loc);
return Expression::make_binary(this->op_, call, zero, loc);
}
if (mpz_sgn(val) < 0)
{
this->report_error(_("negative shift count"));
- mpz_set_ui(val, 0);
Location rloc = this->right_->location();
- this->right_ = Expression::make_integer(&val, right_type,
- rloc);
+ this->right_ = Expression::make_integer_ul(0, right_type,
+ rloc);
}
mpz_clear(val);
}
Type* left_type = left->type();
Type* right_type = right->type();
- mpz_t zval;
- mpz_init_set_ui(zval, 0UL);
- Expression* zexpr = Expression::make_integer(&zval, NULL, location);
- mpz_clear(zval);
+ Expression* zexpr = Expression::make_integer_ul(0, NULL, location);
if (left_type->is_string_type() && right_type->is_string_type())
{
this->report_error(_("length required when allocating a slice"));
return Expression::make_error(this->location());
}
-
- mpz_t zval;
- mpz_init_set_ui(zval, 0);
- len_arg = Expression::make_integer(&zval, NULL, loc);
- mpz_clear(zval);
+ len_arg = Expression::make_integer_ul(0, NULL, loc);
}
else
{
mpz_t ival;
nc.get_int(&ival);
Expression* int_cst =
- Expression::make_integer(&ival, uintptr_type, location);
+ Expression::make_integer_z(&ival, uintptr_type, location);
mpz_clear(ival);
return int_cst->get_backend(context);
}
Type* element_type = at->element_type();
Btype* element_btype = element_type->get_backend(gogo);
-
- mpz_t size;
- size_t element_size = gogo->backend()->type_size(element_btype);
- mpz_init_set_ui(size, element_size);
- Expression* size_expr = Expression::make_integer(&size, length->type(), location);
- mpz_clear(size);
-
+ size_t element_size = gogo->backend()->type_size(element_btype);
+ Expression* size_expr = Expression::make_integer_ul(element_size,
+ length->type(),
+ location);
Expression* bytecount =
Expression::make_binary(OPERATOR_MULT, size_expr, length, location);
Expression* copy = Runtime::make_call(Runtime::COPY, location, 3,
go_assert(arg2->is_variable());
Expression* arg2_val;
Expression* arg2_len;
- mpz_t size;
+ unsigned long size;
if (arg2->type()->is_string_type()
&& element_type->integer_type() != NULL
&& element_type->integer_type()->is_byte())
location);
arg2_len = Expression::make_string_info(arg2, STRING_INFO_LENGTH,
location);
- mpz_init_set_ui(size, 1UL);
+ size = 1;
}
else
{
arg2_val = at->get_value_pointer(gogo, arg2);
arg2_len = at->get_length(gogo, arg2);
Btype* element_btype = element_type->get_backend(gogo);
- size_t element_size = gogo->backend()->type_size(element_btype);
- mpz_init_set_ui(size, element_size);
+ size = gogo->backend()->type_size(element_btype);
}
Expression* element_size =
- Expression::make_integer(&size, NULL, location);
- mpz_clear(size);
+ Expression::make_integer_ul(size, NULL, location);
Expression* append = Runtime::make_call(Runtime::APPEND, location, 4,
arg1, arg2_val, arg2_len,
Expression* end = NULL;
if (this->end_->is_nil_expression())
- {
- mpz_t neg_one;
- mpz_init_set_si(neg_one, -1);
- end = Expression::make_integer(&neg_one, int_type, loc);
- mpz_clear(neg_one);
- }
+ end = Expression::make_integer_sl(-1, int_type, loc);
else
{
Expression* bounds_check = Expression::check_bounds(this->end_, loc);
// string, it won't garbage collect the bytes. So we use a
// [...]byte.
- mpz_t val;
- mpz_init_set_ui(val, s.length());
- Expression* length_expr = Expression::make_integer(&val, NULL, loc);
- mpz_clear(val);
+ Expression* length_expr = Expression::make_integer_ul(s.length(), NULL, loc);
Type* byte_type = gogo->lookup_global("byte")->type_value();
Type* array_type = Type::make_array_type(byte_type, length_expr);
Expression_list* bytes = new Expression_list();
for (std::string::const_iterator p = s.begin(); p != s.end(); p++)
{
- mpz_init_set_ui(val, *p);
- Expression* byte = Expression::make_integer(&val, NULL, loc);
- mpz_clear(val);
- bytes->push_back(byte);
+ unsigned char c = static_cast<unsigned char>(*p);
+ bytes->push_back(Expression::make_integer_ul(c, NULL, loc));
}
Expression* e = Expression::make_composite_literal(array_type, 0, false,
{
go_assert(type->is_slice_type());
- mpz_t lenval;
+ unsigned long lenval;
Expression* length;
if (vals == NULL || vals->empty())
- mpz_init_set_ui(lenval, 0);
+ lenval = 0;
else
{
if (this->indexes() == NULL)
- mpz_init_set_ui(lenval, vals->size());
+ lenval = vals->size();
else
- mpz_init_set_ui(lenval, indexes->back() + 1);
+ lenval = indexes->back() + 1;
}
Type* int_type = Type::lookup_integer_type("int");
- length = Expression::make_integer(&lenval, int_type, location);
- mpz_clear(lenval);
+ length = Expression::make_integer_ul(lenval, int_type, location);
Type* element_type = type->array_type()->element_type();
this->valtype_ = Type::make_array_type(element_type, length);
}
key_value_pair, loc));
}
- mpz_t lenval;
- mpz_init_set_ui(lenval, i);
- Expression* element_count = Expression::make_integer(&lenval, NULL, loc);
- mpz_clear(lenval);
-
+ Expression* element_count = Expression::make_integer_ul(i, NULL, loc);
Type* ctor_type =
Type::make_array_type(this->element_type_, element_count);
Expression* constructor =
Expression* descriptor = Expression::make_map_descriptor(mt, loc);
Type* uintptr_t = Type::lookup_integer_type("uintptr");
- mpz_t countval;
- mpz_init_set_ui(countval, i);
- Expression* count = Expression::make_integer(&countval, uintptr_t, loc);
- mpz_clear(countval);
+ Expression* count = Expression::make_integer_ul(i, uintptr_t, loc);
Expression* entry_size =
Expression::make_type_info(this->element_type_, TYPE_INFO_SIZE);
}
}
- mpz_t vlen;
- mpz_init_set_ui(vlen, size);
- Expression* elen = Expression::make_integer(&vlen, NULL, location);
- mpz_clear(vlen);
+ Expression* elen = Expression::make_integer_ul(size, NULL, location);
at = Type::make_array_type(at->element_type(), elen);
type = at;
}
Btype* btype = this->type_->get_backend(gogo);
size_t offset = gogo->backend()->type_field_offset(btype, i);
- mpz_t offsetval;
- mpz_init_set_ui(offsetval, offset);
Type* uptr_type = Type::lookup_integer_type("uintptr");
- Expression* ret = Expression::make_integer(&offsetval, uptr_type,
- Linemap::predeclared_location());
- mpz_clear(offsetval);
+ Expression* ret =
+ Expression::make_integer_ul(offset, uptr_type,
+ Linemap::predeclared_location());
return ret->get_backend(context);
}
switch (this->classification_)
{
case NC_INT:
- return Expression::make_integer(&this->u_.int_val, this->type_, loc);
+ return Expression::make_integer_z(&this->u_.int_val, this->type_, loc);
case NC_RUNE:
return Expression::make_character(&this->u_.int_val, this->type_, loc);
case NC_FLOAT:
static Expression*
make_character(const mpz_t*, Type*, Location);
- // Make a constant integer expression. TYPE should be NULL for an
- // abstract type.
+ // Make a constant integer expression from a multi-precision
+ // integer. TYPE should be NULL for an abstract type.
+ static Expression*
+ make_integer_z(const mpz_t*, Type*, Location);
+
+ // Make a constant integer expression from an unsigned long. TYPE
+ // should be NULL for an abstract type.
+ static Expression*
+ make_integer_ul(unsigned long, Type*, Location);
+
+ // Make a constant integer expression from a signed long. TYPE
+ // should be NULL for an abstract type.
static Expression*
- make_integer(const mpz_t*, Type*, Location);
+ make_integer_sl(long, Type*, Location);
// Make a constant float expression. TYPE should be NULL for an
// abstract type.
// We will change the type later, when we know the size.
Type* byte_type = this->lookup_global("byte")->type_value();
- mpz_t val;
- mpz_init_set_ui(val, 0);
- Expression* zero = Expression::make_integer(&val, NULL, bloc);
- mpz_clear(val);
-
+ Expression* zero = Expression::make_integer_ul(0, NULL, bloc);
Type* array_type = Type::make_array_type(byte_type, zero);
Variable* var = new Variable(array_type, NULL, true, false, false, bloc);
"__size", uint_type);
Location builtin_loc = Linemap::predeclared_location();
- size_t count = var_gc.size();
- mpz_t lenval;
- mpz_init_set_ui(lenval, count);
- Expression* length = Expression::make_integer(&lenval, NULL, builtin_loc);
- mpz_clear(lenval);
+ Expression* length = Expression::make_integer_ul(var_gc.size(), NULL,
+ builtin_loc);
Array_type* root_array_type = Type::make_array_type(root_type, length);
Type* ptdt = Type::make_type_descriptor_ptr_type();
Expression* nil = Expression::make_nil(builtin_loc);
null_init->push_back(nil);
- mpz_t zval;
- mpz_init_set_ui(zval, 0UL);
- Expression* zero = Expression::make_integer(&zval, NULL, builtin_loc);
- mpz_clear(zval);
+ Expression *zero = Expression::make_integer_ul(0, NULL, builtin_loc);
null_init->push_back(zero);
Expression* null_root_ctor =
Expression* fn = Expression::make_func_reference(builtin_return_address,
NULL, location);
- mpz_t zval;
- mpz_init_set_ui(zval, 0UL);
- Expression* zexpr = Expression::make_integer(&zval, NULL, location);
- mpz_clear(zval);
+ Expression* zexpr = Expression::make_integer_ul(0, NULL, location);
Expression_list *args = new Expression_list();
args->push_back(zexpr);
Gogo::runtime_error(int code, Location location)
{
Type* int32_type = Type::lookup_integer_type("int32");
- mpz_t val;
- mpz_init_set_ui(val, code);
- Expression* code_expr = Expression::make_integer(&val, int32_type, location);
- mpz_clear(val);
+ Expression* code_expr = Expression::make_integer_ul(code, int32_type,
+ location);
return Runtime::make_call(Runtime::RUNTIME_ERROR, location, 1, code_expr);
}
return ret;
case Token::TOKEN_INTEGER:
- ret = Expression::make_integer(token->integer_value(), NULL,
- token->location());
+ ret = Expression::make_integer_z(token->integer_value(), NULL,
+ token->location());
this->advance_token();
return ret;
if (!this->peek_token()->is_op(OPERATOR_COLON))
start = this->expression(PRECEDENCE_NORMAL, false, true, NULL, NULL);
else
- {
- mpz_t zero;
- mpz_init_set_ui(zero, 0);
- start = Expression::make_integer(&zero, NULL, location);
- mpz_clear(zero);
- }
+ start = Expression::make_integer_ul(0, NULL, location);
Expression* end = NULL;
if (this->peek_token()->is_op(OPERATOR_COLON))
Runtime::map_iteration_type()
{
const unsigned long map_iteration_size = 4;
-
- mpz_t ival;
- mpz_init_set_ui(ival, map_iteration_size);
- Expression* iexpr = Expression::make_integer(&ival, NULL,
- Linemap::predeclared_location());
- mpz_clear(ival);
-
+ Expression* iexpr =
+ Expression::make_integer_ul(map_iteration_size, NULL,
+ Linemap::predeclared_location());
return Type::make_array_type(runtime_function_type(RFT_POINTER), iexpr);
}
Inc_dec_statement::do_lower(Gogo*, Named_object*, Block*, Statement_inserter*)
{
Location loc = this->location();
-
- mpz_t oval;
- mpz_init_set_ui(oval, 1UL);
- Expression* oexpr = Expression::make_integer(&oval, this->expr_->type(), loc);
- mpz_clear(oval);
-
+ Expression* oexpr = Expression::make_integer_ul(1, this->expr_->type(), loc);
Operator op = this->is_inc_ ? OPERATOR_PLUSEQ : OPERATOR_MINUSEQ;
return Statement::make_assignment_operation(op, this->expr_, oexpr, loc);
}
continue;
}
go_assert(nc.type() != NULL);
- e = Expression::make_integer(&ival, nc.type(), e->location());
+ e = Expression::make_integer_z(&ival, nc.type(), e->location());
mpz_clear(ival);
}
Expression* selref = Expression::make_temporary_reference(sel, loc);
- mpz_t ival;
- mpz_init_set_ui(ival, this->index_);
- Expression* index_expr = Expression::make_integer(&ival, NULL, loc);
- mpz_clear(ival);
+ Expression* index_expr = Expression::make_integer_ul(this->index_, NULL,
+ loc);
if (this->is_default_)
{
++p, ++i)
{
int index = p->index();
- mpz_t ival;
- mpz_init_set_ui(ival, index);
- Expression* index_expr = Expression::make_integer(&ival, int32_type,
- location);
- mpz_clear(ival);
+ Expression* index_expr = Expression::make_integer_ul(index, int32_type,
+ location);
cases[i].push_back(index_expr->get_backend(context));
Bstatement* s = p->get_statements_backend(context);
go_assert(this->sel_ == NULL);
- mpz_t ival;
- mpz_init_set_ui(ival, this->clauses_->size());
- Expression* size_expr = Expression::make_integer(&ival, NULL, loc);
- mpz_clear(ival);
-
+ Expression* size_expr = Expression::make_integer_ul(this->clauses_->size(),
+ NULL, loc);
Expression* call = Runtime::make_call(Runtime::NEWSELECT, loc, 1, size_expr);
this->sel_ = Statement::make_temporary(NULL, call, loc);
len_call, loc);
init->add_statement(len_temp);
- mpz_t zval;
- mpz_init_set_ui(zval, 0UL);
- Expression* zexpr = Expression::make_integer(&zval, NULL, loc);
- mpz_clear(zval);
+ Expression* zexpr = Expression::make_integer_ul(0, NULL, loc);
Temporary_reference_expression* tref =
Expression::make_temporary_reference(index_temp, loc);
len_call, loc);
init->add_statement(len_temp);
- mpz_t zval;
- mpz_init_set_ui(zval, 0UL);
- Expression* zexpr = Expression::make_integer(&zval, NULL, loc);
- mpz_clear(zval);
+ Expression* zexpr = Expression::make_integer_ul(0, NULL, loc);
Temporary_reference_expression* tref =
Expression::make_temporary_reference(index_temp, loc);
Statement::make_temporary(index_temp->type(), NULL, loc);
init->add_statement(next_index_temp);
- mpz_t zval;
- mpz_init_set_ui(zval, 0UL);
- Expression* zexpr = Expression::make_integer(&zval, NULL, loc);
+ Expression* zexpr = Expression::make_integer_ul(0, NULL, loc);
Temporary_reference_expression* ref =
Expression::make_temporary_reference(index_temp, loc);
iter_init->add_statement(s);
ref = Expression::make_temporary_reference(next_index_temp, loc);
- zexpr = Expression::make_integer(&zval, NULL, loc);
- mpz_clear(zval);
+ zexpr = Expression::make_integer_ul(0, NULL, loc);
Expression* equals = Expression::make_binary(OPERATOR_EQEQ, ref, zexpr, loc);
Block* then_block = new Block(iter_init, loc);
// hiter[0] != nil
ref = Expression::make_temporary_reference(hiter, loc);
-
- mpz_t zval;
- mpz_init_set_ui(zval, 0UL);
- Expression* zexpr = Expression::make_integer(&zval, NULL, loc);
- mpz_clear(zval);
-
+ Expression* zexpr = Expression::make_integer_ul(0, NULL, loc);
Expression* index = Expression::make_index(ref, zexpr, NULL, NULL, loc);
-
Expression* ne = Expression::make_binary(OPERATOR_NOTEQ, index,
Expression::make_nil(loc),
loc);
-
*pcond = ne;
// Set *PITER_INIT to
runtime_type_kind |= RUNTIME_TYPE_KIND_NO_POINTERS;
Struct_field_list::const_iterator p = fields->begin();
go_assert(p->is_field_name("kind"));
- mpz_t iv;
- mpz_init_set_ui(iv, runtime_type_kind);
- vals->push_back(Expression::make_integer(&iv, p->type(), bloc));
+ vals->push_back(Expression::make_integer_ul(runtime_type_kind, p->type(),
+ bloc));
++p;
go_assert(p->is_field_name("align"));
h = name->hash_for_method(gogo);
else
h = this->hash_for_method(gogo);
- mpz_set_ui(iv, h);
- vals->push_back(Expression::make_integer(&iv, p->type(), bloc));
+ vals->push_back(Expression::make_integer_ul(h, p->type(), bloc));
++p;
go_assert(p->is_field_name("hashfn"));
++p;
go_assert(p == fields->end());
- mpz_clear(iv);
-
return Expression::make_struct_composite_literal(td_type, vals, bloc);
}
vals->push_back(Expression::make_type_info(this,
Expression::TYPE_INFO_SIZE));
- mpz_t off;
- mpz_init_set_ui(off, 0UL);
- Expression* offset = Expression::make_integer(&off, uintptr_t, bloc);
- mpz_clear(off);
+ Expression* offset = Expression::make_integer_ul(0, uintptr_t, bloc);
this->do_gc_symbol(gogo, &vals, &offset, 0);
- mpz_t end;
- mpz_init_set_ui(end, GC_END);
- vals->push_back(Expression::make_integer(&end, uintptr_t, bloc));
- mpz_clear(end);
-
- mpz_t lenval;
- mpz_init_set_ui(lenval, vals->size() + 1);
- Expression* len = Expression::make_integer(&lenval, NULL, bloc);
- mpz_clear(lenval);
+ vals->push_back(Expression::make_integer_ul(GC_END, uintptr_t, bloc));
+ Expression* len = Expression::make_integer_ul(vals->size() + 1, NULL,
+ bloc);
Array_type* gc_symbol_type = Type::make_array_type(uintptr_t, len);
return Expression::make_array_composite_literal(gc_symbol_type, vals, bloc);
}
{
Location bloc = Linemap::predeclared_location();
Type* uintptr_type = Type::lookup_integer_type("uintptr");
- mpz_t opval;
- mpz_init_set_ui(opval, GC_STRING);
- (*vals)->push_back(Expression::make_integer(&opval, uintptr_type, bloc));
- mpz_clear(opval);
+ (*vals)->push_back(Expression::make_integer_ul(GC_STRING, uintptr_type,
+ bloc));
(*vals)->push_back(*offset);
this->advance_gc_offset(offset);
}
// We use GC_APTR here because we do not currently have a way to describe the
// the type of the possible function closure. FIXME.
- mpz_t opval;
- mpz_init_set_ui(opval, GC_APTR);
- (*vals)->push_back(Expression::make_integer(&opval, uintptr_type, bloc));
- mpz_clear(opval);
+ (*vals)->push_back(Expression::make_integer_ul(GC_APTR, uintptr_type, bloc));
(*vals)->push_back(*offset);
this->advance_gc_offset(offset);
}
Location loc = Linemap::predeclared_location();
Type* uintptr_type = Type::lookup_integer_type("uintptr");
- mpz_t opval;
- mpz_init_set_ui(opval, this->to_type_->has_pointer() ? GC_PTR : GC_APTR);
- (*vals)->push_back(Expression::make_integer(&opval, uintptr_type, loc));
- mpz_clear(opval);
+ unsigned long opval = this->to_type_->has_pointer() ? GC_PTR : GC_APTR;
+ (*vals)->push_back(Expression::make_integer_ul(opval, uintptr_type, loc));
(*vals)->push_back(*offset);
if (this->to_type_->has_pointer())
Type* uintptr_type = Type::lookup_integer_type("uintptr");
// Get a 0.
- mpz_t ival;
- mpz_init_set_ui(ival, 0);
- Expression* zero = Expression::make_integer(&ival, uintptr_type, bloc);
- mpz_clear(ival);
+ Expression* zero = Expression::make_integer_ul(0, uintptr_type, bloc);
// Make a temporary to hold the return value, initialized to 0.
Temporary_statement* retval = Statement::make_temporary(uintptr_type, zero,
else
{
// Multiply retval by 33.
- mpz_init_set_ui(ival, 33);
- Expression* i33 = Expression::make_integer(&ival, uintptr_type,
- bloc);
- mpz_clear(ival);
-
+ Expression* i33 = Expression::make_integer_ul(33, uintptr_type,
+ bloc);
ref = Expression::make_temporary_reference(retval, bloc);
Statement* s = Statement::make_assignment_operation(OPERATOR_MULTEQ,
ref, i33, bloc);
Type* uintptr_type = Type::lookup_integer_type("uintptr");
// Get a 0.
- mpz_t ival;
- mpz_init_set_ui(ival, 0);
- Expression* zero = Expression::make_integer(&ival, uintptr_type, bloc);
- mpz_clear(ival);
+ Expression* zero = Expression::make_integer_ul(0, uintptr_type, bloc);
// Make a temporary to hold the return value, initialized to 0.
Temporary_statement* retval = Statement::make_temporary(uintptr_type, zero,
gogo->start_block(bloc);
// Multiply retval by 33.
- mpz_init_set_ui(ival, 33);
- Expression* i33 = Expression::make_integer(&ival, uintptr_type, bloc);
- mpz_clear(ival);
+ Expression* i33 = Expression::make_integer_ul(33, uintptr_type, bloc);
ref = Expression::make_temporary_reference(retval, bloc);
Statement* s = Statement::make_assignment_operation(OPERATOR_MULTEQ, ref,
size_t element_size = gogo->backend()->type_size(ebtype);
Type* uintptr_type = Type::lookup_integer_type("uintptr");
- mpz_t opval;
- mpz_init_set_ui(opval, element_size == 0 ? GC_APTR : GC_SLICE);
- (*vals)->push_back(Expression::make_integer(&opval, uintptr_type, bloc));
- mpz_clear(opval);
+ unsigned long opval = element_size == 0 ? GC_APTR : GC_SLICE;
+ (*vals)->push_back(Expression::make_integer_ul(opval, uintptr_type, bloc));
(*vals)->push_back(*offset);
if (element_size != 0)
{
Type* uintptr_type = Type::lookup_integer_type("uintptr");
- mpz_t op;
if (stack_size < GC_STACK_CAPACITY)
{
- mpz_init_set_ui(op, GC_ARRAY_START);
- (*vals)->push_back(Expression::make_integer(&op, uintptr_type, bloc));
- mpz_clear(op);
+ (*vals)->push_back(Expression::make_integer_ul(GC_ARRAY_START,
+ uintptr_type, bloc));
(*vals)->push_back(*offset);
Expression* uintptr_len =
Expression::make_cast(uintptr_type, this->length_, bloc);
Expression::TYPE_INFO_SIZE);
(*vals)->push_back(width);
- mpz_t zero;
- mpz_init_set_ui(zero, 0UL);
- Expression* offset2 =
- Expression::make_integer(&zero, uintptr_type, bloc);
- mpz_clear(zero);
+ Expression* offset2 = Expression::make_integer_ul(0, uintptr_type,
+ bloc);
Type::gc_symbol(gogo, element_type, vals, &offset2, stack_size + 1);
- mpz_init_set_ui(op, GC_ARRAY_NEXT);
- (*vals)->push_back(Expression::make_integer(&op, uintptr_type, bloc));
+ (*vals)->push_back(Expression::make_integer_ul(GC_ARRAY_NEXT,
+ uintptr_type, bloc));
}
else
{
- mpz_init_set_ui(op, GC_REGION);
- (*vals)->push_back(Expression::make_integer(&op, uintptr_type, bloc));
+ (*vals)->push_back(Expression::make_integer_ul(GC_REGION,
+ uintptr_type, bloc));
(*vals)->push_back(*offset);
Expression* width =
(*vals)->push_back(width);
(*vals)->push_back(Expression::make_gc_symbol(this));
}
- mpz_clear(op);
this->advance_gc_offset(offset);
}
}
Location bloc = Linemap::predeclared_location();
Type* uintptr_type = Type::lookup_integer_type("uintptr");
- mpz_t opval;
- mpz_init_set_ui(opval, GC_APTR);
- (*vals)->push_back(Expression::make_integer(&opval, uintptr_type, bloc));
- mpz_clear(opval);
+ (*vals)->push_back(Expression::make_integer_ul(GC_APTR, uintptr_type, bloc));
(*vals)->push_back(*offset);
this->advance_gc_offset(offset);
}
val |= 1;
if (this->may_send_)
val |= 2;
- mpz_t iv;
- mpz_init_set_ui(iv, val);
- vals->push_back(Expression::make_integer(&iv, p->type(), bloc));
- mpz_clear(iv);
+ vals->push_back(Expression::make_integer_ul(val, p->type(), bloc));
++p;
go_assert(p == fields->end());
Location bloc = Linemap::predeclared_location();
Type* uintptr_type = Type::lookup_integer_type("uintptr");
- mpz_t opval;
- mpz_init_set_ui(opval, GC_CHAN_PTR);
- (*vals)->push_back(Expression::make_integer(&opval, uintptr_type, bloc));
- mpz_clear(opval);
+ (*vals)->push_back(Expression::make_integer_ul(GC_CHAN_PTR, uintptr_type,
+ bloc));
(*vals)->push_back(*offset);
Type* unsafeptr_type = Type::make_pointer_type(Type::make_void_type());
Location bloc = Linemap::predeclared_location();
Type* uintptr_type = Type::lookup_integer_type("uintptr");
- mpz_t opval;
- mpz_init_set_ui(opval, this->is_empty() ? GC_EFACE : GC_IFACE);
- (*vals)->push_back(Expression::make_integer(&opval, uintptr_type,
- bloc));
- mpz_clear(opval);
+ unsigned long opval = this->is_empty() ? GC_EFACE : GC_IFACE;
+ (*vals)->push_back(Expression::make_integer_ul(opval, uintptr_type, bloc));
(*vals)->push_back(*offset);
this->advance_gc_offset(offset);
}