import lib::llvm::False;
import util::filesearch;
-tag output_type {
+enum output_type {
output_type_none;
output_type_bitcode;
output_type_assembly;
} as handler
}
-tag level {
+enum level {
fatal;
error;
warning;
import getopts::{optopt, optmulti, optflag, optflagopt, opt_present};
import back::{x86, x86_64};
-tag pp_mode { ppm_normal; ppm_expanded; ppm_typed; ppm_identified; }
+enum pp_mode { ppm_normal; ppm_expanded; ppm_typed; ppm_identified; }
fn default_configuration(sess: session, argv0: str, input: str) ->
ast::crate_cfg {
bug and need to present an error.
*/
fn monitor(f: fn~(diagnostic::emitter)) {
- tag monitor_msg {
+ enum monitor_msg {
fatal;
done;
};
import back::target_strs;
import middle::lint;
-tag os { os_win32; os_macos; os_linux; os_freebsd; }
+enum os { os_win32; os_macos; os_linux; os_freebsd; }
-tag arch { arch_x86; arch_x86_64; arch_arm; }
+enum arch { arch_x86; arch_x86_64; arch_arm; }
-tag crate_type { bin_crate; lib_crate; unknown_crate; }
+enum crate_type { bin_crate; lib_crate; unknown_crate; }
type config =
{os: os,
// Consts for the LLVM CallConv type, pre-cast to uint.
// FIXME: figure out a way to merge these with the native
-// typedef and/or a tag type in the native module below.
+// typedef and/or a enum type in the native module below.
const LLVMCCallConv: uint = 0u;
const LLVMFastCallConv: uint = 8u;
-// EBML tag definitions and utils shared by the encoder and decoder
+// EBML enum definitions and utils shared by the encoder and decoder
import str;
cnum: ast::crate_num};
// This is a bit of an experiment at encapsulating the data in cstore. By
-// keeping all the data in a non-exported tag variant, it's impossible for
+// keeping all the data in a non-exported enum variant, it's impossible for
// other modules to access the cstore's private data. This could also be
// achieved with an obj, but at the expense of a vtable. Not sure if this is a
// good pattern or not.
-tag cstore { private(cstore_private); }
+enum cstore { private(cstore_private); }
type cstore_private =
@{metas: map::hashmap<ast::crate_num, crate_metadata>,
ty::ty_fn(f) {
for a: ty::arg in f.inputs { arg_tys += [a.ty]; }
}
- _ { /* Nullary tag variant. */ }
+ _ { /* Nullary enum variant. */ }
}
alt variant_disr_val(item) {
some(val) { disr_val = val; }
't' { ret "type"; }
'm' { ret "mod"; }
'n' { ret "native mod"; }
- 'v' { ret "tag"; }
+ 'v' { ret "enum"; }
'i' { ret "impl"; }
'I' { ret "iface"; }
}
// Whatever format you choose should not contain pipe characters.
type ty_abbrev = {pos: uint, len: uint, s: @str};
-tag abbrev_ctxt { ac_no_abbrevs; ac_use_abbrevs(hashmap<ty::t, ty_abbrev>); }
+enum abbrev_ctxt { ac_no_abbrevs; ac_use_abbrevs(hashmap<ty::t, ty_abbrev>); }
fn cx_uses_abbrevs(cx: @ctxt) -> bool {
alt cx.abbrevs {
// getting input from one, to be more precise). It is a pass that checks
// whether aliases are used in a safe way.
-tag copied { not_allowed; copied; not_copied; }
-tag invalid_reason { overwritten; val_taken; }
+enum copied { not_allowed; copied; not_copied; }
+enum invalid_reason { overwritten; val_taken; }
type invalid = {reason: invalid_reason,
node_id: node_id,
sp: span, path: @ast::path};
-tag unsafe_ty { contains(ty::t); mut_contains(ty::t); }
+enum unsafe_ty { contains(ty::t); mut_contains(ty::t); }
type binding = @{node_id: node_id,
span: span,
mutable copied: not_copied};
}
-tag local_info { local(uint); }
+enum local_info { local(uint); }
type copy_map = std::map::hashmap<node_id, ()>;
type ref_map = std::map::hashmap<node_id, node_id>;
import syntax::ast_util;
import syntax::{visit, codemap};
-tag ast_node {
+enum ast_node {
node_item(@item);
node_native_item(@native_item);
node_method(@method);
export cap_drop;
export cap_ref;
-tag capture_mode {
+enum capture_mode {
cap_copy; //< Copy the value into the closure.
cap_move; //< Move the value into the closure.
cap_drop; //< Drop value after creating closure.
type metadata_cache = hashmap<int, [debug_metadata]>;
-tag debug_metadata {
+enum debug_metadata {
file_metadata(@metadata<file_md>);
compile_unit_metadata(@metadata<compile_unit_md>);
subprogram_metadata(@metadata<subprogram_md>);
// Marks expr_paths that are last uses.
type last_uses = std::map::hashmap<node_id, ()>;
-tag seen { unset; seen(node_id); }
-tag block_type { func; loop; }
+enum seen { unset; seen(node_id); }
+enum block_type { func; loop; }
type set = [{def: node_id, exprs: list<node_id>}];
type bl = @{type: block_type, mutable second: bool, mutable exits: [set]};
import syntax::ast_util;
import driver::session::session;
-tag deref_t { unbox; field; index; }
+enum deref_t { unbox; field; index; }
type deref = @{mut: bool, kind: deref_t, outer_t: ty::t};
ret cx.mut_map;
}
-tag msg { msg_assign; msg_move_out; msg_mut_ref; }
+enum msg { msg_assign; msg_move_out; msg_mut_ref; }
fn mk_err(cx: @ctx, span: syntax::codemap::span, msg: msg, name: str) {
cx.tcx.sess.span_err(span, alt msg {
// locates all names (in expressions, types, and alt patterns) and resolves
// them, storing the resulting def in the AST nodes.
-tag scope {
+enum scope {
scope_crate;
scope_item(@ast::item);
scope_bare_fn(ast::fn_decl, node_id, [ast::ty_param]);
type scopes = list<scope>;
-tag import_state {
+enum import_state {
todo(ast::node_id, ast::ident, @[ast::ident], codemap::span, scopes);
is_glob(@[ast::ident], scopes, codemap::span);
resolving(span);
ast::ident, codemap::span);
}
-tag glob_import_state {
+enum glob_import_state {
glob_resolving(span);
glob_resolved(option::t<def>, /* value */
option::t<def>, /* type */
ret std::map::mk_hashmap::<key, def>(hash, eq);
}
-tag mod_index_entry {
+enum mod_index_entry {
mie_view_item(@ast::view_item);
mie_import_ident(node_id, codemap::span);
mie_item(@ast::item);
mie_native_item(@ast::native_item);
- mie_tag_variant(/* tag item */@ast::item, /* variant index */uint);
+ mie_tag_variant(/* enum item */@ast::item, /* variant index */uint);
}
type mod_index = hashmap<ident, list<mod_index_entry>>;
// Used to distinguish between lookups from outside and from inside modules,
// since export restrictions should only be applied for the former.
-tag dir { inside; outside; }
+enum dir { inside; outside; }
-// There are two types of ns_value tag: "definitely a tag";
+// There are two types of ns_value enum: "definitely a enum";
// and "any value". This is so that lookup can behave differently
// when looking up a variable name that's not yet in scope to check
-// if it's already bound to a tag.
-tag namespace { ns_val(ns_value_type); ns_type; ns_module; }
-tag ns_value_type { ns_a_tag; ns_any_value; }
+// if it's already bound to a enum.
+enum namespace { ns_val(ns_value_type); ns_type; ns_module; }
+enum ns_value_type { ns_a_tag; ns_any_value; }
fn resolve_crate(sess: session, amap: ast_map::map, crate: @ast::crate) ->
{def_map: def_map, exp_map: exp_map, impl_map: impl_map} {
resolve_names(e, crate);
resolve_impls(e, crate);
// check_for_collisions must happen after resolve_names so we
- // don't complain if a pattern uses the same nullary tag twice
+ // don't complain if a pattern uses the same nullary enum twice
check_for_collisions(e, *crate);
if sess.opts.warn_unused_imports {
check_unused_imports(e);
}
_ {
e.sess.span_err(p.span,
- "not a tag variant: " +
+ "not a enum variant: " +
ast_util::path_name(p));
}
}
}
/* Here we determine whether a given pat_ident binds a new
- variable a refers to a nullary tag. */
+ variable a refers to a nullary enum. */
ast::pat_ident(p, none) {
let fnd = lookup_in_scope(*e, sc, p.span, path_to_ident(p),
ns_val(ns_a_tag));
}
// This is only for irrefutable patterns (e.g. ones that appear in a let)
-// So if x occurs, and x is already known to be a tag, that's always an error
+// So if x occurs, and x is already known to be a enum, that's always an error
fn visit_local_with_scope(e: @env, loc: @local, sc:scopes, v:vt<scopes>) {
- // Check whether the given local has the same name as a tag that's
+ // Check whether the given local has the same name as a enum that's
// in scope
// We disallow this, in order to make alt patterns consisting of
// a single identifier unambiguous (does the pattern "foo" refer
- // to tag foo, or is it binding a new name foo?)
+ // to enum foo, or is it binding a new name foo?)
alt loc.node.pat.node {
pat_ident(an_ident,_) {
// Be sure to pass ns_a_tag to lookup_in_scope so that
alt lookup_in_scope(*e, sc, loc.span,
path_to_ident(an_ident), ns_val(ns_a_tag)) {
some(ast::def_variant(tag_id,variant_id)) {
- // Declaration shadows a tag that's in scope.
+ // Declaration shadows a enum that's in scope.
// That's an error.
e.sess.span_err(loc.span,
- #fmt("Declaration of %s shadows a tag that's in scope",
+ #fmt("Declaration of %s shadows a enum that's in scope",
path_to_ident(an_ident)));
}
_ {}
ns_val(v) {
alt (v) {
ns_any_value { "name" }
- ns_a_tag { "tag" }
+ ns_a_tag { "enum" }
}
}
ns_module { ret "modulename" }
}
}
-tag ctxt { in_mod(def); in_scope(scopes); }
+enum ctxt { in_mod(def); in_scope(scopes); }
fn unresolved_err(e: env, cx: ctxt, sp: span, name: ident, kind: str) {
fn find_fn_or_mod_scope(sc: scopes) -> option::t<scope> {
}
ns_val(v) {
alt(v) {
- /* If we were looking for a tag, at this point
- we know it's bound to a non-tag value, and
+ /* If we were looking for a enum, at this point
+ we know it's bound to a non-enum value, and
we can return none instead of failing */
ns_a_tag { ret none; }
_ { "attempted dynamic environment-capture" }
}
// if we're searching for a value, it's ok if we found
-// a tag
+// a enum
fn ns_ok(wanted:namespace, actual:namespace) -> bool {
alt actual {
ns_val(ns_a_tag) {
}
-// Computes a set of variants of a tag that are guaranteed to have size and
-// alignment at least as large as any other variant of the tag. This is an
+// Computes a set of variants of a enum that are guaranteed to have size and
+// alignment at least as large as any other variant of the enum. This is an
// important performance optimization.
//
// TODO: Use this in dynamic_size_of() as well.
ret result;
}
-// Computes the static size of a tag, without using mk_tup(), which is
+// Computes the static size of a enum, without using mk_tup(), which is
// bad for performance.
//
// TODO: Migrate trans over to use this.
if max_align < variant_align { max_align = variant_align; }
}
- // Add space for the tag if applicable.
- // FIXME (issue #792): This is wrong. If the tag starts with an 8 byte
+ // Add space for the enum if applicable.
+ // FIXME (issue #792): This is wrong. If the enum starts with an 8 byte
// aligned quantity, we don't align it.
if vec::len(*variants) > 1u {
let variant_t = T_tag_variant(ccx);
ret {size: max_size, align: max_align};
}
-tag tag_kind { tk_unit; tk_enum; tk_complex; }
+enum tag_kind { tk_unit; tk_enum; tk_complex; }
fn tag_kind(ccx: @crate_ctxt, did: ast::def_id) -> tag_kind {
let variants = ty::tag_variants(ccx.tcx, did);
//}
fn gen_tag_shapes(ccx: @crate_ctxt) -> ValueRef {
- // Loop over all the tag variants and write their shapes into a data
+ // Loop over all the enum variants and write their shapes into a data
// buffer. As we do this, it's possible for us to discover new tags, so we
// must do this first.
let i = 0u;
}
// Now calculate the sizes of the header space (which contains offsets to
- // info records for each tag) and the info space (which contains offsets
+ // info records for each enum) and the info space (which contains offsets
// to each variant shape). As we do so, build up the header.
let header = [];
}
// Construct the info tables, which contain offsets to the shape of each
- // variant. Also construct the largest-variant table for each tag, which
+ // variant. Also construct the largest-variant table for each enum, which
// contains the variants that the size-of operation needs to look at.
let lv_table = [];
add_u16(lv_table, vec::len(lv) as u16);
for v: uint in lv { add_u16(lv_table, v as u16); }
- // Determine whether the tag has dynamic size.
+ // Determine whether the enum has dynamic size.
let dynamic = false;
for variant: ty::variant_info in *variants {
for typ: ty::t in variant.args {
}
}
- // If we can, write in the static size and alignment of the tag.
+ // If we can, write in the static size and alignment of the enum.
// Otherwise, write a placeholder.
let size_align;
if dynamic {
}
-// Computes the size of the data part of a non-dynamically-sized tag.
+// Computes the size of the data part of a non-dynamically-sized enum.
fn static_size_of_tag(cx: @crate_ctxt, sp: span, t: ty::t)
: type_has_static_size(cx, t) -> uint {
if cx.tag_sizes.contains_key(t) { ret cx.tag_sizes.get(t); }
ret max_size;
}
_ {
- cx.tcx.sess.span_fatal(sp, "non-tag passed to static_size_of_tag()");
+ cx.tcx.sess.span_fatal(sp, "non-enum passed to static_size_of_tag()");
}
}
}
}
-// Replacement for the LLVM 'GEP' instruction when field indexing into a tag.
+// Replacement for the LLVM 'GEP' instruction when field indexing into a enum.
// This function uses GEP_tup_like() above and automatically performs casts as
-// appropriate. @llblobptr is the data part of a tag value; its actual type is
+// appropriate. @llblobptr is the data part of a enum value; its actual type is
// meaningless, as it will be cast away.
fn GEP_tag(cx: @block_ctxt, llblobptr: ValueRef, tag_id: ast::def_id,
variant_id: ast::def_id, ty_substs: [ty::t],
// Used only for creating scalar comparison glue.
-tag scalar_type { nil_type; signed_int; unsigned_int; floating_point; }
+enum scalar_type { nil_type; signed_int; unsigned_int; floating_point; }
fn compare_scalar_types(cx: @block_ctxt, lhs: ValueRef, rhs: ValueRef,
// NB: we must hit the discriminant first so that structural
// comparison know not to proceed when the discriminants differ.
cx = f(cx, lldiscrim_a_ptr, ty::mk_int(bcx_tcx(cx)));
- let unr_cx = new_sub_block_ctxt(cx, "tag-iter-unr");
+ let unr_cx = new_sub_block_ctxt(cx, "enum-iter-unr");
Unreachable(unr_cx);
let llswitch = Switch(cx, lldiscrim_a, unr_cx.llbb, n_variants);
- let next_cx = new_sub_block_ctxt(cx, "tag-iter-next");
+ let next_cx = new_sub_block_ctxt(cx, "enum-iter-next");
for variant: ty::variant_info in *variants {
let variant_cx =
new_sub_block_ctxt(cx,
- "tag-iter-variant-" +
+ "enum-iter-variant-" +
int::to_str(variant.disr_val, 10u));
AddCase(llswitch, C_int(ccx, variant.disr_val), variant_cx.llbb);
variant_cx =
ret call_memmove(bcx, dst, src, llsz).bcx;
}
-tag copy_action { INIT; DROP_EXISTING; }
+enum copy_action { INIT; DROP_EXISTING; }
// These are the types that are passed by pointer.
fn type_is_structural_or_param(tcx: ty::ctxt, t: ty::t) -> bool {
t1 = mt.ty;
// Since we're changing levels of box indirection, we may have
- // to cast this pointer, since statically-sized tag types have
+ // to cast this pointer, since statically-sized enum types have
// different types depending on whether they're behind a box
// or not.
if check type_has_static_size(ccx, t1) {
}
}
-tag dest {
+enum dest {
by_val(@mutable ValueRef);
save_in(ValueRef);
ignore;
origins: option::t<typeck::dict_res>
};
-tag lval_kind {
+enum lval_kind {
temporary; //< Temporary value passed by value if of immediate type
owned; //< Non-temporary value passed by pointer
owned_imm; //< Non-temporary value passed by value
}
type local_var_result = {val: ValueRef, kind: lval_kind};
type lval_result = {bcx: @block_ctxt, val: ValueRef, kind: lval_kind};
-tag callee_env {
+enum callee_env {
null_env;
is_closure;
self_env(ValueRef);
check (type_has_static_size(ccx, t_out));
let ll_t_out = type_of(ccx, e.span, t_out);
- tag kind { pointer; integral; float; tag_; other; }
+ enum kind { pointer; integral; float; tag_; other; }
fn t_kind(tcx: ty::ctxt, t: ty::t) -> kind {
ret if ty::type_is_fp(tcx, t) {
float
ret trans_ret(bcx, ex);
}
ast::expr_be(ex) {
- // Ideally, the expr_be tag would have a precondition
+ // Ideally, the expr_be enum would have a precondition
// that is_call_expr(ex) -- but we don't support that
// yet
// FIXME
RetVoid(ret_cx);
}
-tag self_arg { impl_self(ty::t); no_self; }
+enum self_arg { impl_self(ty::t); no_self; }
// trans_closure: Builds an LLVM function out of a source function.
// If the function closes over its environment a closure will be
let lltop = bcx.llbb;
bcx = copy_args_to_allocas(fcx, bcx, fn_args, arg_tys);
- // Cast the tag to a type we can GEP into.
+ // Cast the enum to a type we can GEP into.
let llblobptr =
if is_degen {
fcx.llretptr
let rslt = GEP_tag(bcx, llblobptr, t_id, v_id, ty_param_substs, i);
bcx = rslt.bcx;
let lldestptr = rslt.val;
- // If this argument to this function is a tag, it'll have come in to
+ // If this argument to this function is a enum, it'll have come in to
// this function as an opaque blob due to the way that type_of()
// works. So we have to cast to the destination's view of the type.
let llarg = alt fcx.llargs.find(va.id) { some(local_mem(x)) { x } };
for variant in variants {
if vec::len(variant.node.args) != 0u {
register_fn(ccx, i.span, new_pt + [variant.node.name],
- "tag", tps, variant.node.id);
+ "enum", tps, variant.node.id);
}
}
}
import trans_common::*;
-// An option identifying a branch (either a literal, a tag variant or a range)
-tag opt {
+// An option identifying a branch (either a literal, a enum variant or a range)
+enum opt {
lit(@ast::expr);
var(/* disr val */int, /* variant dids */{tg: def_id, var: def_id});
range(@ast::expr, @ast::expr);
}
}
-tag opt_result {
+enum opt_result {
single_result(result);
range_result(result, result);
}
let r =
// invariant needed:
// how do we know it even makes sense to pass in ty_param_substs
- // here? What if it's [] and the tag type has variables in it?
+ // here? What if it's [] and the enum type has variables in it?
trans::GEP_tag(bcx, blobptr, vdefs_tg, vdefs_var, ty_param_substs,
i);
bcx = r.bcx;
// Decide what kind of branch we need
let opts = get_options(ccx, m, col);
- tag branch_kind { no_branch; single; switch; compare; }
+ enum branch_kind { no_branch; single; switch; compare; }
let kind = no_branch;
let test_val = val;
if vec::len(opts) > 0u {
//
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
-tag environment_value {
+enum environment_value {
// Evaluate expr and store result in env (used for bind).
env_expr(@ast::expr);
type derived_tydesc_info = {lltydesc: ValueRef, escapes: bool};
-tag tydesc_kind {
+enum tydesc_kind {
tk_static; // Static (monomorphic) type descriptor
tk_param; // Type parameter.
tk_derived; // Derived from a typaram or another derived tydesc.
// Types used for llself.
type val_self_pair = {v: ValueRef, t: ty::t};
-tag local_val { local_mem(ValueRef); local_imm(ValueRef); }
+enum local_val { local_mem(ValueRef); local_imm(ValueRef); }
type fn_ty_param = {desc: ValueRef, dicts: option::t<[ValueRef]>};
sp: span,
lcx: @local_ctxt};
-tag cleanup {
+enum cleanup {
clean(fn@(@block_ctxt) -> @block_ctxt);
clean_temp(ValueRef, fn@(@block_ctxt) -> @block_ctxt);
}
did), f_t);
}
-tag block_kind {
+enum block_kind {
// A scope block is a basic block created by translating a block { ... }
fcx: @fn_ctxt};
// FIXME: we should be able to use option::t<@block_parent> here but
-// the infinite-tag check in rustboot gets upset.
-tag block_parent { parent_none; parent_some(@block_ctxt); }
+// the infinite-enum check in rustboot gets upset.
+enum block_parent { parent_none; parent_some(@block_ctxt); }
type result = {bcx: @block_ctxt, val: ValueRef};
type result_t = {bcx: @block_ctxt, val: ValueRef, ty: ty::t};
}
// Used to identify cached dictionaries
-tag dict_param {
+enum dict_param {
dict_param_dict(dict_id);
dict_param_ty(ty::t);
}
// Used to communicate which operands should be invalidated
// to helper functions
-tag oper_type {
+enum oper_type {
oper_move;
oper_swap;
oper_assign;
// for this local.
type constr_arg_use = spanned<constr_arg_general_<inst>>;
-tag constraint {
+enum constraint {
cinit(uint, span, ident);
// FIXME: really only want it to be mutable during collect_locals.
// predicate need not be local.
// FIXME: would be nice to give both a def_id field,
// and give ninit a constraint saying it's local.
-tag tsconstr {
+enum tsconstr {
ninit(node_id, ident);
npred(@path, def_id, [@constr_arg_use]);
}
ret rslt;
}
-tag if_ty { if_check; plain_if; }
+enum if_ty { if_check; plain_if; }
fn local_node_id_to_def_id_strict(fcx: fn_ctxt, sp: span, i: node_id) ->
def_id {
*/
type t = {uncertain: bitv::t, val: bitv::t, nbits: uint};
-tag trit { ttrue; tfalse; dont_care; }
+enum trit { ttrue; tfalse; dont_care; }
fn create_tritv(len: uint) -> t {
ret {uncertain: bitv::create(len, true),
type t = uint;
-tag closure_kind {
+enum closure_kind {
ck_any;
ck_block;
ck_box;
// NB: If you change this, you'll probably want to change the corresponding
// AST structure in front/ast::rs as well.
-tag sty {
+enum sty {
ty_nil;
ty_bot;
ty_bool;
ty_tup([t]);
ty_var(int); // type variable
- ty_param(uint, def_id); // fn/tag type param
+ ty_param(uint, def_id); // fn/enum type param
ty_type; // type_desc*
ty_send_type; // type_desc* that has been cloned into exchange heap
type constr = constr_general<uint>;
// Data structures used in type unification
-tag type_err {
+enum type_err {
terr_mismatch;
terr_ret_style_mismatch(ast::ret_style, ast::ret_style);
terr_box_mutability;
terr_constr_mismatch(@type_constr, @type_constr);
}
-tag param_bound {
+enum param_bound {
bound_copy;
bound_send;
bound_iface(t);
walker(ty);
}
-tag fold_mode {
+enum fold_mode {
fm_var(fn@(int) -> t);
fm_param(fn@(uint, def_id) -> t);
fm_general(fn@(t) -> t);
ret result;
}
-tag kind { kind_sendable; kind_copyable; kind_noncopyable; }
+enum kind { kind_sendable; kind_copyable; kind_noncopyable; }
// Using these query functons is preferable to direct comparison or matching
// against the kind constants, as we may modify the kind hierarchy in the
}
}
-// Whether a type is enum like, that is a tag type with only nullary
+// Whether a type is enum like, that is a enum type with only nullary
// constructors
fn type_is_c_like_enum(cx: ctxt, ty: t) -> bool {
alt struct(cx, ty) {
export var_bindings;
export precise, in_bindings;
- tag result { ures_ok(t); ures_err(type_err); }
- tag union_result { unres_ok; unres_err(type_err); }
- tag fixup_result {
+ enum result { ures_ok(t); ures_err(type_err); }
+ enum union_result { unres_ok; unres_err(type_err); }
+ enum fixup_result {
fix_ok(t); // fixup succeeded
fix_err(int); // fixup failed because a type variable was unresolved
}
type var_bindings =
{sets: ufind::ufind, types: smallintmap::smallintmap<t>};
- tag unify_style {
+ enum unify_style {
precise;
in_bindings(@var_bindings);
}
}
// Specifies the allowable subtyping between expected and actual types
- tag variance {
+ enum variance {
// Actual may be a subtype of expected
covariant;
// Actual may be a supertype of expected
}
-// Returns information about the tag variant with the given ID:
+// Returns information about the enum variant with the given ID:
fn tag_variant_with_id(cx: ctxt, tag_id: ast::def_id, variant_id: ast::def_id)
-> variant_info {
let variants = tag_variants(cx, tag_id);
export method_map, method_origin, method_static, method_param, method_iface;
export dict_map, dict_res, dict_origin, dict_static, dict_param, dict_iface;
-tag method_origin {
+enum method_origin {
method_static(ast::def_id);
// iface id, method num, param num, bound num
method_param(ast::def_id, uint, uint, uint);
// Resolutions for bounds of all parameters, left to right, for a given path.
type dict_res = @[dict_origin];
-tag dict_origin {
+enum dict_origin {
dict_static(ast::def_id, [ty::t], dict_res);
// Param number, bound number
dict_param(uint, uint);
type ty_table = hashmap<ast::def_id, ty::t>;
// Used for typechecking the methods of an impl
-tag self_info {
+enum self_info {
self_impl(ty::t);
}
}
}
-tag mode { m_collect; m_check; m_check_tyvar(@fn_ctxt); }
+enum mode { m_collect; m_check; m_check_tyvar(@fn_ctxt); }
fn ast_ty_to_ty(tcx: ty::ctxt, mode: mode, &&ast_ty: @ast::ty) -> ty::t {
fn getter(tcx: ty::ctxt, mode: mode, id: ast::def_id)
some(none) {
tcx.sess.span_fatal(ast_ty.span,
"illegal recursive type \
- insert a tag in the cycle, \
+ insert a enum in the cycle, \
if this is desired)");
}
none { }
// Create a set of parameter types shared among all the variants.
for variant: ast::variant in variants {
- // Nullary tag constructors get turned into constants; n-ary tag
+ // Nullary enum constructors get turned into constants; n-ary enum
// constructors get turned into functions.
let result_ty = if vec::len(variant.node.args) == 0u {
}
-// Returns the types of the arguments to a tag variant.
+// Returns the types of the arguments to a enum variant.
fn variant_arg_types(ccx: @crate_ctxt, _sp: span, vid: ast::def_id,
tag_ty_params: [ty::t]) -> [ty::t] {
let result: [ty::t] = [];
let tag_tpt = ty::lookup_item_type(fcx.ccx.tcx, v_def_ids.tg);
let path_tpot = instantiate_path(fcx, path, tag_tpt, pat.span);
- // Take the tag type params out of `expected`.
+ // Take the enum type params out of `expected`.
alt structure_of(fcx, pat.span, expected) {
ty::ty_tag(_, expected_tps) {
- // Unify with the expected tag type.
+ // Unify with the expected enum type.
let ctor_ty =
ty::ty_param_substs_opt_and_ty_to_monotype(fcx.ccx.tcx,
path_tpot);
path_tpot =
{substs: some::<[ty::t]>(path_tpt.substs), ty: path_tpt.ty};
- // Get the number of arguments in this tag variant.
+ // Get the number of arguments in this enum variant.
let arg_types =
variant_arg_types(fcx.ccx, pat.span, v_def_ids.var,
expected_tps);
let arg_len = vec::len::<ty::t>(arg_types);
if arg_len != subpats_len {
- // TODO: note definition of tag variant
+ // TODO: note definition of enum variant
// TODO (issue #448): Wrap a #fmt string over multiple
// lines...
let s =
i += 1u;
}
} else if subpats_len > 0u {
- // TODO: note definition of tag variant
+ // TODO: note definition of enum variant
fcx.ccx.tcx.sess.span_fatal
(pat.span,
#fmt["this pattern has %u field%s, \
// can never tell.
fcx.ccx.tcx.sess.span_fatal
(pat.span,
- #fmt["mismatched types: expected `%s` but found tag",
+ #fmt["mismatched types: expected `%s` but found enum",
ty_to_str(fcx.ccx.tcx, expected)]);
}
}
const local_crate: crate_num = 0;
const crate_node_id: node_id = 0;
-tag ty_param_bound {
+enum ty_param_bound {
bound_copy;
bound_send;
bound_iface(@ty);
type ty_param = {ident: ident, id: node_id, bounds: @[ty_param_bound]};
-tag def {
+enum def {
def_fn(def_id, purity);
def_self(def_id);
def_mod(def_id);
def_const(def_id);
def_arg(def_id, mode);
def_local(def_id, let_style);
- def_variant(def_id /* tag */, def_id /* variant */);
+ def_variant(def_id /* enum */, def_id /* variant */);
def_ty(def_id);
def_ty_param(def_id, uint);
def_binding(def_id);
attrs: [attribute],
config: crate_cfg};
-tag crate_directive_ {
+enum crate_directive_ {
cdir_src_mod(ident, [attribute]);
cdir_dir_mod(ident, [@crate_directive], [attribute]);
// NB: cdir_view_item is *not* processed by the rest of the compiler; the
// attached view_items are sunk into the crate's module during parsing,
- // and processed (resolved, imported, etc.) there. This tag-variant exists
+ // and processed (resolved, imported, etc.) there. This enum-variant exists
// only to preserve the view items in order in case we decide to
// pretty-print crates in the future.
cdir_view_item(@view_item);
type meta_item = spanned<meta_item_>;
-tag meta_item_ {
+enum meta_item_ {
meta_word(ident);
meta_list(ident, [@meta_item]);
meta_name_value(ident, lit);
type field_pat = {ident: ident, pat: @pat};
-tag pat_ {
+enum pat_ {
pat_wild;
// A pat_ident may either be a new bound variable,
- // or a nullary tag (in which case the second field
+ // or a nullary enum (in which case the second field
// is none).
- // In the nullary tag case, the parser can't determine
+ // In the nullary enum case, the parser can't determine
// which it is. The resolver determines this, and
// records this pattern's node_id in an auxiliary
// set (of "pat_idents that refer to nullary tags")
pat_range(@expr, @expr);
}
-tag mutability { mut; imm; maybe_mut; }
+enum mutability { mut; imm; maybe_mut; }
-tag proto {
+enum proto {
proto_bare; // native fn
proto_any; // fn
proto_uniq; // fn~
}
}
-tag binop {
+enum binop {
add;
subtract;
mul;
gt;
}
-tag unop {
+enum unop {
box(mutability);
uniq(mutability);
deref; not; neg;
}
-tag mode { by_ref; by_val; by_mut_ref; by_move; by_copy; mode_infer; }
+enum mode { by_ref; by_val; by_mut_ref; by_move; by_copy; mode_infer; }
type stmt = spanned<stmt_>;
-tag stmt_ {
+enum stmt_ {
stmt_decl(@decl, node_id);
// expr without trailing semi-colon (must have unit type):
stmt_semi(@expr, node_id);
}
-tag init_op { init_assign; init_move; }
+enum init_op { init_assign; init_move; }
type initializer = {op: init_op, expr: @expr};
type decl = spanned<decl_>;
-tag let_style { let_copy; let_ref; }
+enum let_style { let_copy; let_ref; }
-tag decl_ { decl_local([(let_style, @local)]); decl_item(@item); }
+enum decl_ { decl_local([(let_style, @local)]); decl_item(@item); }
type arm = {pats: [@pat], guard: option::t<@expr>, body: blk};
type field = spanned<field_>;
-tag blk_check_mode { default_blk; unchecked_blk; unsafe_blk; }
+enum blk_check_mode { default_blk; unchecked_blk; unsafe_blk; }
-tag expr_check_mode { claimed_expr; checked_expr; }
+enum expr_check_mode { claimed_expr; checked_expr; }
type expr = {id: node_id, node: expr_, span: span};
-tag expr_ {
+enum expr_ {
expr_vec([@expr], mutability);
expr_rec([field], option::t<@expr>);
expr_call(@expr, [@expr], bool);
/*
// Says whether this is a block the user marked as
// "unchecked"
-tag blk_sort {
+enum blk_sort {
blk_unchecked; // declared as "exception to effect-checking rules"
blk_checked; // all typing rules apply
}
type mac = spanned<mac_>;
-tag mac_ {
+enum mac_ {
mac_invoc(@path, @expr, option::t<str>);
mac_embed_type(@ty);
mac_embed_block(blk);
type lit = spanned<lit_>;
-tag lit_ {
+enum lit_ {
lit_str(str);
lit_int(i64, int_ty);
lit_uint(u64, uint_ty);
type ty_method = {ident: ident, decl: fn_decl, tps: [ty_param], span: span};
-tag int_ty { ty_i; ty_char; ty_i8; ty_i16; ty_i32; ty_i64; }
+enum int_ty { ty_i; ty_char; ty_i8; ty_i16; ty_i32; ty_i64; }
-tag uint_ty { ty_u; ty_u8; ty_u16; ty_u32; ty_u64; }
+enum uint_ty { ty_u; ty_u8; ty_u16; ty_u32; ty_u64; }
-tag float_ty { ty_f; ty_f32; ty_f64; }
+enum float_ty { ty_f; ty_f32; ty_f64; }
type ty = spanned<ty_>;
-tag ty_ {
+enum ty_ {
ty_nil;
ty_bot; /* return type of ! functions and type of
ret/fail/break/cont. there is no syntax
So, the constr_arg type is parameterized: it's instantiated with uint for
declarations, and ident for uses.
*/
-tag constr_arg_general_<T> { carg_base; carg_ident(T); carg_lit(@lit); }
+enum constr_arg_general_<T> { carg_base; carg_ident(T); carg_lit(@lit); }
type fn_constr_arg = constr_arg_general_<uint>;
type sp_constr_arg<T> = spanned<constr_arg_general_<T>>;
cf: ret_style,
constraints: [@constr]};
-tag purity {
+enum purity {
pure_fn; // declared with "pure fn"
unsafe_fn; // declared with "unsafe fn"
impure_fn; // declared with "fn"
}
-tag ret_style {
+enum ret_style {
noreturn; // functions with return type _|_ that always
// raise an error or exit (i.e. never return to the caller)
return_val; // everything else
type _mod = {view_items: [@view_item], items: [@item]};
-tag native_abi {
+enum native_abi {
native_abi_rust_intrinsic;
native_abi_cdecl;
native_abi_stdcall;
type import_ident = spanned<import_ident_>;
-tag view_item_ {
+enum view_item_ {
view_item_use(ident, [@meta_item], node_id);
view_item_import(ident, @simple_path, node_id);
view_item_import_glob(@simple_path, node_id);
// Distinguishes between attributes that decorate items and attributes that
// are contained as statements within items. These two cases need to be
// distinguished for pretty-printing.
-tag attr_style { attr_outer; attr_inner; }
+enum attr_style { attr_outer; attr_inner; }
type attribute_ = {style: attr_style, value: meta_item};
type item = {ident: ident, attrs: [attribute],
id: node_id, node: item_, span: span};
-tag item_ {
+enum item_ {
item_const(@ty, @expr);
item_fn(fn_decl, [ty_param], blk);
item_mod(_mod);
id: node_id,
span: span};
-tag native_item_ {
+enum native_item_ {
native_item_ty;
native_item_fn(fn_decl, [ty_param]);
}
// FIXME this doesn't handle big integer/float literals correctly (nor does
// the rest of our literal handling)
-tag const_val {
+enum const_val {
const_float(float);
const_int(i64);
const_uint(u64);
ret lookup_pos(map, pos, lookup);
}
-tag opt_span {
+enum opt_span {
//hack (as opposed to option::t), to make `span` compile
os_none;
type macro_definer =
fn@(ext_ctxt, span, @ast::expr, option::t<str>) -> macro_def;
-tag syntax_extension {
+enum syntax_extension {
normal(syntax_expander);
macro_defining(macro_definer);
}
type clause = {params: binders, body: @expr};
/* logically, an arb_depth should contain only one kind of matchable */
-tag arb_depth<T> { leaf(T); seq(@[arb_depth<T>], span); }
+enum arb_depth<T> { leaf(T); seq(@[arb_depth<T>], span); }
-tag matchable {
+enum matchable {
match_expr(@expr);
match_path(@path);
match_ident(ast::spanned<ident>);
}
}
-tag cmnt_style {
+enum cmnt_style {
isolated; // No code on either side of each line of the comment
trailing; // Code exists to the left of the comment
mixed; // Code before /* foo */ and after the comment
import lexer::reader;
import driver::diagnostic;
-tag restriction {
+enum restriction {
UNRESTRICTED;
RESTRICT_STMT_EXPR;
RESTRICT_NO_CALL_EXPRS;
RESTRICT_NO_BAR_OP;
}
-tag file_type { CRATE_FILE; SOURCE_FILE; }
+enum file_type { CRATE_FILE; SOURCE_FILE; }
type parse_sess = @{
cm: codemap::codemap,
"cont", "ret", "be", "fail", "type", "resource", "check",
"assert", "claim", "native", "fn", "pure",
"unsafe", "block", "import", "export", "let", "const",
- "log", "copy", "sendfn", "impl", "iface", "enum"] {
+ "log", "copy", "sendfn", "impl", "iface", "tag", "enum"] {
words.insert(word, ());
}
words
// parsing because `(while{...})+3` parses differently from `while{...}+3`.
//
// To reflect the fact that the @ast::expr is not a true expr that should be
-// part of the AST, we wrap such expressions in the pexpr tag. They
+// part of the AST, we wrap such expressions in the pexpr enum. They
// can then be converted to true expressions by a call to `to_expr()`.
-tag pexpr {
+enum pexpr {
pexpr(@ast::expr);
}
}
_ { args = []; }
}
- // at this point, we're not sure whether it's a tag or a bind
+ // at this point, we're not sure whether it's a enum or a bind
if vec::len(args) == 0u &&
vec::len(tag_path.node.idents) == 1u {
pat = ast::pat_ident(tag_path, none);
// Newtype syntax
if p.token == token::EQ {
if p.bad_expr_words.contains_key(id) {
- p.fatal("found " + id + " in tag constructor position");
+ p.fatal("found " + id + " in enum constructor position");
}
p.bump();
let ty = parse_ty(p, false);
type str_num = uint;
-tag binop {
+enum binop {
PLUS;
MINUS;
STAR;
ASR;
}
-tag token {
+enum token {
/* Expression-operator symbols. */
EQ;
LT;
* line (which it can't) and so naturally place the content on its own line to
* avoid combining it with other lines and making matters even worse.
*/
-tag breaks { consistent; inconsistent; }
+enum breaks { consistent; inconsistent; }
type break_t = {offset: int, blank_space: int};
type begin_t = {offset: int, breaks: breaks};
-tag token { STRING(str, int); BREAK(break_t); BEGIN(begin_t); END; EOF; }
+enum token { STRING(str, int); BREAK(break_t); BEGIN(begin_t); END; EOF; }
fn tok_str(t: token) -> str {
alt t {
ret s;
}
-tag print_stack_break { fits; broken(breaks); }
+enum print_stack_break { fits; broken(breaks); }
type print_stack_elt = {offset: int, pbreak: print_stack_break};
import driver::diagnostic;
// The ps is stored here to prevent recursive type.
-// FIXME use a nominal tag instead
-tag ann_node {
+// FIXME use a nominal enum instead
+enum ann_node {
node_block(ps, ast::blk);
node_item(ps, @ast::item);
node_expr(ps, @ast::expr);
print_possibly_embedded_block_(s, blk, block_normal, indent_unit, attrs);
}
-tag embed_type { block_macro; block_block_fn; block_normal; }
+enum embed_type { block_macro; block_block_fn; block_normal; }
fn print_possibly_embedded_block(s: ps, blk: ast::blk, embedded: embed_type,
indented: uint) {
// override the context), or prevent deeper traversal by doing nothing.
// Our typesystem doesn't do circular types, so the visitor record can not
-// hold functions that take visitors. A vt tag is used to break the cycle.
-tag vt<E> { mk_vt(visitor<E>); }
+// hold functions that take visitors. A vt enum is used to break the cycle.
+enum vt<E> { mk_vt(visitor<E>); }
-tag fn_kind {
+enum fn_kind {
fk_item_fn(ident, [ty_param]); //< an item declared with fn()
fk_method(ident, [ty_param]);
fk_res(ident, [ty_param]);