debug!("resolving extern mod stmt. ident: {:?} path_opt: {:?}",
ident, path_opt);
let (name, version) = match path_opt {
- Some((path_str, _)) => {
- let crateid: Option<CrateId> = from_str(path_str);
+ Some((ref path_str, _)) => {
+ let crateid: Option<CrateId> = from_str(path_str.get());
match crateid {
None => (@"", @""),
Some(crateid) => {
let temp_scope = fcx.push_custom_cleanup_scope();
// Prepare the output operands
- let outputs = ia.outputs.map(|&(c, out)| {
- constraints.push(c);
+ let outputs = ia.outputs.map(|&(ref c, out)| {
+ constraints.push((*c).clone());
let out_datum = unpack_datum!(bcx, expr::trans(bcx, out));
output_types.push(type_of::type_of(bcx.ccx(), out_datum.ty));
});
// Now the input operands
- let inputs = ia.inputs.map(|&(c, input)| {
- constraints.push(c);
+ let inputs = ia.inputs.map(|&(ref c, input)| {
+ constraints.push((*c).clone());
unpack_result!(bcx, {
callee::trans_arg_expr(bcx,
// no failure occurred preparing operands, no need to cleanup
fcx.pop_custom_cleanup_scope(temp_scope);
- let mut constraints = constraints.connect(",");
+ let mut constraints = constraints.map(|s| s.get().to_str()).connect(",");
let mut clobbers = getClobbers();
- if !ia.clobbers.is_empty() && !clobbers.is_empty() {
- clobbers = format!("{},{}", ia.clobbers, clobbers);
+ if !ia.clobbers.get().is_empty() && !clobbers.is_empty() {
+ clobbers = format!("{},{}", ia.clobbers.get(), clobbers);
} else {
- clobbers.push_str(ia.clobbers);
+ clobbers.push_str(ia.clobbers.get());
}
// Add the clobbers to our constraints list
ast::AsmIntel => lib::llvm::AD_Intel
};
- let r = ia.asm.with_c_str(|a| {
+ let r = ia.asm.get().with_c_str(|a| {
constraints.with_c_str(|c| {
InlineAsmCall(bcx, a, c, inputs, output_type, ia.volatile, ia.alignstack, dialect)
})
#[deriving(Clone, Eq, Encodable, Decodable, IterBytes)]
pub struct InlineAsm {
- asm: @str,
+ asm: InternedString,
asm_str_style: StrStyle,
- clobbers: @str,
- inputs: ~[(@str, @Expr)],
- outputs: ~[(@str, @Expr)],
+ clobbers: InternedString,
+ inputs: ~[(InternedString, @Expr)],
+ outputs: ~[(InternedString, @Expr)],
volatile: bool,
alignstack: bool,
dialect: AsmDialect
// optional @str: if present, this is a location (containing
// arbitrary characters) from which to fetch the crate sources
// For example, extern mod whatever = "github.com/mozilla/rust"
- ViewItemExternMod(Ident, Option<(@str, StrStyle)>, NodeId),
+ ViewItemExternMod(Ident, Option<(InternedString,StrStyle)>, NodeId),
ViewItemUse(~[@ViewPath]),
}
let (constraint, _str_style) = p.parse_str();
- if constraint.starts_with("+") {
+ if constraint.get().starts_with("+") {
cx.span_unimpl(p.last_span,
"'+' (read+write) output operand constraint modifier");
- } else if !constraint.starts_with("=") {
+ } else if !constraint.get().starts_with("=") {
cx.span_err(p.last_span, "output operand constraint lacks '='");
}
let (constraint, _str_style) = p.parse_str();
- if constraint.starts_with("=") {
+ if constraint.get().starts_with("=") {
cx.span_err(p.last_span, "input operand constraint contains '='");
- } else if constraint.starts_with("+") {
+ } else if constraint.get().starts_with("+") {
cx.span_err(p.last_span, "input operand constraint contains '+'");
}
Options => {
let (option, _str_style) = p.parse_str();
- if "volatile" == option {
+ if option.equiv(&("volatile")) {
volatile = true;
- } else if "alignstack" == option {
+ } else if option.equiv(&("alignstack")) {
alignstack = true;
- } else if "intel" == option {
+ } else if option.equiv(&("intel")) {
dialect = ast::AsmIntel;
}
MRExpr(@ast::Expr {
id: ast::DUMMY_NODE_ID,
node: ast::ExprInlineAsm(ast::InlineAsm {
- asm: asm.get().to_managed(),
+ asm: token::intern_and_get_ident(asm.get()),
asm_str_style: asm_str_style.unwrap(),
- clobbers: cons.to_managed(),
+ clobbers: token::intern_and_get_ident(cons),
inputs: inputs,
outputs: outputs,
volatile: volatile,
}
ExprInlineAsm(ref a) => {
ExprInlineAsm(InlineAsm {
- inputs: a.inputs.map(|&(c, input)| (c, folder.fold_expr(input))),
- outputs: a.outputs.map(|&(c, out)| (c, folder.fold_expr(out))),
+ inputs: a.inputs.map(|&(ref c, input)| {
+ ((*c).clone(), folder.fold_expr(input))
+ }),
+ outputs: a.outputs.map(|&(ref c, out)| {
+ ((*c).clone(), folder.fold_expr(out))
+ }),
.. (*a).clone()
})
}
}
}
- pub fn parse_optional_str(&mut self) -> Option<(@str, ast::StrStyle)> {
+ pub fn parse_optional_str(&mut self)
+ -> Option<(InternedString, ast::StrStyle)> {
let (s, style) = match self.token {
- token::LIT_STR(s) => (s, ast::CookedStr),
- token::LIT_STR_RAW(s, n) => (s, ast::RawStr(n)),
+ token::LIT_STR(s) => (self.id_to_interned_str(s), ast::CookedStr),
+ token::LIT_STR_RAW(s, n) => {
+ (self.id_to_interned_str(s), ast::RawStr(n))
+ }
_ => return None
};
self.bump();
- Some((ident_to_str(&s), style))
+ Some((s, style))
}
- pub fn parse_str(&mut self) -> (@str, StrStyle) {
+ pub fn parse_str(&mut self) -> (InternedString, StrStyle) {
match self.parse_optional_str() {
Some(s) => { s }
_ => self.fatal("expected string literal")
word(&mut s.s, "asm!");
}
popen(s);
- print_string(s, a.asm, a.asm_str_style);
+ print_string(s, a.asm.get(), a.asm_str_style);
word_space(s, ":");
- for &(co, o) in a.outputs.iter() {
- print_string(s, co, ast::CookedStr);
+ for &(ref co, o) in a.outputs.iter() {
+ print_string(s, co.get(), ast::CookedStr);
popen(s);
print_expr(s, o);
pclose(s);
word_space(s, ",");
}
word_space(s, ":");
- for &(co, o) in a.inputs.iter() {
- print_string(s, co, ast::CookedStr);
+ for &(ref co, o) in a.inputs.iter() {
+ print_string(s, co.get(), ast::CookedStr);
popen(s);
print_expr(s, o);
pclose(s);
word_space(s, ",");
}
word_space(s, ":");
- print_string(s, a.clobbers, ast::CookedStr);
+ print_string(s, a.clobbers.get(), ast::CookedStr);
pclose(s);
}
ast::ExprMac(ref m) => print_mac(s, m),
space(&mut s.s);
word(&mut s.s, "=");
space(&mut s.s);
- print_string(s, *p, style);
+ print_string(s, p.get(), style);
}
}