GitLab will continue to be upgraded from 11.4.5-ce.0 on November 25th 2019 at 4.00pm (AEDT) to 5.00pm (AEDT) due to Critical Security Patch Availability. During the update, GitLab and Mattermost services will not be available.

Commit 5e05fd11 authored by Isaac Oscar Gariano's avatar Isaac Oscar Gariano

Changed MuName and CName to Arc<String>

parent 2e8bb439
......@@ -37,7 +37,7 @@ gcc = "*"
mu_ast = {path = "src/ast"}
mu_utils = {path = "src/utils"}
#mu_gc = {path = "src/gc"}
rodal = { git = "https://gitlab.anu.edu.au/mu/rodal", version = ">= 0.0.5" }
rodal = { git = "https://gitlab.anu.edu.au/mu/rodal", version = ">= 0.0.10" }
#rodal = { path = "../rodal_test/rodal", version = ">= 0.0.5" }
libc="*"
......
......@@ -25,6 +25,6 @@ mu_utils = {path = "../utils"}
lazy_static = "*"
log = "*"
simple_logger = "*"
rodal = { git = "https://gitlab.anu.edu.au/mu/rodal", version = ">= 0.0.5" }
rodal = { git = "https://gitlab.anu.edu.au/mu/rodal", version = ">= 0.0.10" }
regex = "*"
#rodal = { path = "../../../rodal_test/rodal", version = ">= 0.0.5" }
......@@ -22,21 +22,22 @@ use utils::LinkedHashSet;
use std;
use std::fmt;
pub use std::sync::Arc;
use std::default;
use std::sync::atomic::{AtomicUsize, ATOMIC_USIZE_INIT, Ordering};
pub type WPID = usize;
pub type MuID = usize;
pub type MuName = String;
pub type MuName = Arc<String>;
pub type CName = MuName;
#[allow(non_snake_case)]
pub fn Mu(str: &'static str) -> MuName {
str.to_string()
Arc::new(str.to_string())
}
#[allow(non_snake_case)]
pub fn C(str: &'static str) -> CName {
str.to_string()
Arc::new(str.to_string())
}
pub type OpIndex = usize;
......@@ -460,7 +461,7 @@ impl FunctionContent {
}
}
pub fn get_block_by_name(&self, name: String) -> &Block {
pub fn get_block_by_name(&self, name: MuName) -> &Block {
for block in self.blocks.values() {
if block.name() == name {
return block;
......@@ -1466,7 +1467,7 @@ pub fn is_valid_c_identifier(name: &MuName) -> bool {
/// changes name to mangled name
/// This will always return a valid C identifier
pub fn mangle_name(name: MuName) -> MuName {
pub fn mangle_name(name: MuName) -> String {
let name = name.replace('@', "");
if name.starts_with("__mu_") {
// TODO: Get rid of this, since it will be triggered if a client provides a name
......@@ -1488,7 +1489,7 @@ pub fn mangle_name(name: MuName) -> MuName {
/// demangles a Mu name
// WARNING: This only reverses mangle_name above when no warning is issued)
pub fn demangle_name(mut name: MuName) -> MuName {
pub fn demangle_name(mut name: String) -> MuName {
let name = if cfg!(target_os = "macos") && name.starts_with("___mu_") {
name.split_off(1)
} else {
......@@ -1507,13 +1508,13 @@ pub fn demangle_name(mut name: MuName) -> MuName {
.replace("Zh", "-")
.replace("Zd", ".")
.replace("ZZ", "Z");
name
Arc::new(name)
}
extern crate regex;
/// identifies mu names and demangles them
pub fn demangle_text(text: String) -> String {
pub fn demangle_text(text: &String) -> String {
use self::regex::Regex;
lazy_static!{
......@@ -1539,14 +1540,14 @@ impl MuEntityHeader {
pub fn unnamed(id: MuID) -> MuEntityHeader {
MuEntityHeader {
id: id,
name: format!("#{}", id)
name: Arc::new(format!("#{}", id))
}
}
pub fn named(id: MuID, name: MuName) -> MuEntityHeader {
MuEntityHeader {
id: id,
name: name.replace('@', "")
name: Arc::new(name.replace('@', ""))
}
}
......@@ -1559,7 +1560,7 @@ impl MuEntityHeader {
}
/// an abbreviate (easy reading) version of the name
fn abbreviate_name(&self) -> MuName {
fn abbreviate_name(&self) -> String {
let split: Vec<&str> = self.name.split('.').collect();
let mut ret = "".to_string();
......@@ -1580,7 +1581,7 @@ impl MuEntityHeader {
pub fn clone_with_id(&self, new_id: MuID) -> MuEntityHeader {
let mut clone = self.clone();
clone.id = new_id;
clone.name = format!("{}-#{}", clone.name, clone.id);
clone.name = Arc::new(format!("{}-#{}", clone.name, clone.id));
clone
}
}
......
......@@ -3444,7 +3444,7 @@ pub fn emit_code(fv: &mut MuFunctionVersion, vm: &VM) {
{
let mut demangled_path = path::PathBuf::new();
demangled_path.push(&vm.vm_options.flag_aot_emit_dir);
demangled_path.push(func.name() + ".demangled.S");
demangled_path.push(*func.name() + ".demangled.S");
let mut demangled_file = match File::create(demangled_path.as_path()) {
Err(why) => {
......@@ -3577,7 +3577,7 @@ use std::collections::HashMap;
pub fn emit_context_with_reloc(
vm: &VM,
symbols: HashMap<Address, String>,
symbols: HashMap<Address, MuName>,
fields: HashMap<Address, String>
) {
use std::path;
......
......@@ -5957,7 +5957,7 @@ impl<'a> InstructionSelection {
self.backend.end_block(cur_block.clone());
}
fn start_block(&mut self, block: String) {
fn start_block(&mut self, block: MuName) {
self.current_block = Some(block.clone());
self.backend.start_block(block.clone());
}
......
......@@ -59,7 +59,7 @@ macro_rules! REGISTER {
($id:expr, $name: expr, $ty: ident) => {
{
P(Value {
hdr: MuEntityHeader::named($id, $name.to_string()),
hdr: MuEntityHeader::named($id, Arc::new($name.to_string())),
ty: $ty.clone(),
v: Value_::SSAVar($id)
})
......
......@@ -226,7 +226,7 @@ pub trait CodeGenerator {
// call
fn emit_call_near_rel32(
&mut self,
callsite: String,
callsite: MuName,
func: MuName,
pe: Option<MuName>,
uses: Vec<P<Value>>,
......@@ -235,7 +235,7 @@ pub trait CodeGenerator {
) -> ValueLocation;
fn emit_call_near_r64(
&mut self,
callsite: String,
callsite: MuName,
func: &P<Value>,
pe: Option<MuName>,
uses: Vec<P<Value>>,
......@@ -243,7 +243,7 @@ pub trait CodeGenerator {
) -> ValueLocation;
fn emit_call_near_mem64(
&mut self,
callsite: String,
callsite: MuName,
func: &P<Value>,
pe: Option<MuName>,
uses: Vec<P<Value>>,
......@@ -253,7 +253,7 @@ pub trait CodeGenerator {
// sometimes we use jmp as a call (but without pushing return address)
fn emit_call_jmp(
&mut self,
callsite: String,
callsite: MuName,
func: MuName,
pe: Option<MuName>,
uses: Vec<P<Value>>,
......@@ -262,7 +262,7 @@ pub trait CodeGenerator {
) -> ValueLocation;
fn emit_call_jmp_indirect(
&mut self,
callsite: String,
callsite: MuName,
func: &P<Value>,
pe: Option<MuName>,
uses: Vec<P<Value>>,
......
......@@ -46,7 +46,7 @@ use utils::{BitSize, ByteSize};
use std::collections::HashMap;
use std::collections::LinkedList;
use std::sync::Arc;
use std::any::Any;
lazy_static! {
......@@ -176,7 +176,7 @@ impl<'a> InstructionSelection {
backend: Box::new(ASMCodeGen::new()),
current_fv_id: 0,
current_fv_name: String::new(),
current_fv_name: Arc::new(String::new()),
current_sig: None,
current_callsite_id: 0,
current_frame: None,
......@@ -4850,7 +4850,7 @@ impl<'a> InstructionSelection {
f_context: &mut FunctionContext,
vm: &VM
) {
let block_name = format!("{}:{}", self.current_fv_name, PROLOGUE_BLOCK_NAME);
let block_name = Arc::new(format!("{}:{}", self.current_fv_name, PROLOGUE_BLOCK_NAME));
self.backend.start_block(block_name.clone());
// push rbp
......@@ -6367,7 +6367,7 @@ impl<'a> InstructionSelection {
}
/// creates a callsite label that is globally unique
fn new_callsite_label(&mut self, cur_node: Option<&TreeNode>) -> String {
fn new_callsite_label(&mut self, cur_node: Option<&TreeNode>) -> MuName {
let ret = {
if cur_node.is_some() {
make_block_name(
......@@ -6375,11 +6375,11 @@ impl<'a> InstructionSelection {
format!("callsite_{}", self.current_callsite_id).as_str()
)
} else {
format!(
Arc::new(format!(
"{}:callsite_{}",
self.current_fv_name,
self.current_callsite_id
)
))
}
};
self.current_callsite_id += 1;
......@@ -6510,7 +6510,7 @@ impl<'a> InstructionSelection {
}
/// starts a new block
fn start_block(&mut self, block: String) {
fn start_block(&mut self, block: MuName) {
self.current_block = Some(block.clone());
self.backend.start_block(block);
}
......
......@@ -46,6 +46,7 @@ use ast::ir::*;
use ast::types::*;
use compiler::backend::RegGroup;
use vm::VM;
use std::sync::Arc;
use utils::LinkedHashMap;
use std::collections::HashMap;
......@@ -96,7 +97,7 @@ macro_rules! GPR {
($id:expr, $name: expr, $ty: ident) => {
{
P(Value {
hdr: MuEntityHeader::named($id, $name.to_string()),
hdr: MuEntityHeader::named($id, Arc::new($name.to_string())),
ty: $ty.clone(),
v: Value_::SSAVar($id)
})
......@@ -109,7 +110,7 @@ macro_rules! FPR {
($id:expr, $name: expr) => {
{
P(Value {
hdr: MuEntityHeader::named($id, $name.to_string()),
hdr: MuEntityHeader::named($id, Arc::new($name.to_string())),
ty: DOUBLE_TYPE.clone(),
v: Value_::SSAVar($id)
})
......
......@@ -146,7 +146,7 @@ fn emit_mc_dot(func: &MuFunctionVersion, vm: &VM) {
// create emit directory/file
create_emit_directory(vm);
let mut file = create_emit_file(func_name.clone() + ".mc.dot", &vm);
let mut file = create_emit_file((*func_name).clone() + ".mc.dot", &vm);
// diagraph func {
writeln!(file, "digraph {} {{", mangle_name(func_name)).unwrap();
......
......@@ -541,5 +541,5 @@ impl RegGroup {
}
fn make_block_name(inst: &MuName, label: &str) -> MuName {
format!("{}:{}", inst, label)
Arc::new(format!("{}:{}", inst, label))
}
......@@ -494,7 +494,7 @@ fn build_global_liveness(cf: &mut CompiledFunction, func: &MuFunctionVersion) {
/// CFGBlockNode represents a basic block as a whole for global liveness analysis
#[derive(Clone, Debug)]
struct CFGBlockNode {
block: String,
block: MuName,
pred: Vec<String>,
succ: Vec<String>,
uses: Vec<MuID>,
......@@ -507,7 +507,7 @@ struct CFGBlockNode {
/// * successors
/// * uses
/// * defs
fn build_cfg_nodes(cf: &mut CompiledFunction) -> LinkedHashMap<String, CFGBlockNode> {
fn build_cfg_nodes(cf: &mut CompiledFunction) -> LinkedHashMap<MuName, CFGBlockNode> {
info!("---local liveness analysis---");
let mc = cf.mc();
let mut ret = LinkedHashMap::new();
......@@ -634,7 +634,7 @@ fn build_cfg_nodes(cf: &mut CompiledFunction) -> LinkedHashMap<String, CFGBlockN
/// global analysis, the iterative algorithm to compute livenss until livein/out reaches a fix point
fn global_liveness_analysis(
blocks: LinkedHashMap<String, CFGBlockNode>,
blocks: LinkedHashMap<MuName, CFGBlockNode>,
cf: &mut CompiledFunction,
func: &MuFunctionVersion
) {
......@@ -642,14 +642,14 @@ fn global_liveness_analysis(
info!("{} blocks", blocks.len());
// init live in and live out
let mut livein: LinkedHashMap<String, LinkedHashSet<MuID>> = {
let mut livein: LinkedHashMap<MuName, LinkedHashSet<MuID>> = {
let mut ret = LinkedHashMap::new();
for name in blocks.keys() {
ret.insert(name.clone(), LinkedHashSet::new());
}
ret
};
let mut liveout: LinkedHashMap<String, LinkedHashSet<MuID>> = {
let mut liveout: LinkedHashMap<MuName, LinkedHashSet<MuID>> = {
let mut ret = LinkedHashMap::new();
for name in blocks.keys() {
ret.insert(name.clone(), LinkedHashSet::new());
......
......@@ -74,7 +74,7 @@ pub fn validate_regalloc(
let mut work_queue: LinkedHashMap<MuName, AliveEntries> = LinkedHashMap::new();
let mut visited: LinkedHashMap<MuName, AliveEntries> = LinkedHashMap::new();
// push entry block
work_queue.insert(PROLOGUE_BLOCK_NAME.to_string(), alive.clone());
work_queue.insert(Arc::new(PROLOGUE_BLOCK_NAME.to_string()), alive.clone());
while !work_queue.is_empty() {
// fetch next block
......
......@@ -73,7 +73,7 @@ fn emit_muir(suffix: &str, func: &MuFunctionVersion, vm: &VM) {
let mut file_path = path::PathBuf::new();
file_path.push(&vm.vm_options.flag_aot_emit_dir);
file_path.push(func_name.clone() + suffix + ".muir");
file_path.push((*func_name).clone() + suffix + ".muir");
let mut file = match File::create(file_path.as_path()) {
Err(why) => {
panic!(
......@@ -96,7 +96,7 @@ fn emit_muir_dot(suffix: &str, func: &MuFunctionVersion, vm: &VM) {
let mut file_path = path::PathBuf::new();
file_path.push(&vm.vm_options.flag_aot_emit_dir);
file_path.push(func_name.clone() + suffix + ".dot");
file_path.push((*func_name).clone() + suffix + ".dot");
let mut file = match File::create(file_path.as_path()) {
Err(why) => {
......@@ -112,7 +112,7 @@ fn emit_muir_dot(suffix: &str, func: &MuFunctionVersion, vm: &VM) {
emit_muir_dot_inner(&mut file, func_name.clone(), func.content.as_ref().unwrap());
}
fn emit_muir_dot_inner(file: &mut File, f_name: String, f_content: &FunctionContent) {
fn emit_muir_dot_inner(file: &mut File, f_name: MuName, f_content: &FunctionContent) {
use utils::vec_utils;
// digraph func {
......
......@@ -403,7 +403,7 @@ fn process_dest(
blocks_to_insert.push(IntermediateBlockInfo {
blk_id: new_blk_id,
blk_name: format!("{}:{}:#{}-#{}", inst, label, new_blk_id, target),
blk_name: Arc::new(format!("{}:{}:#{}-#{}", inst, label, new_blk_id, target)),
target: target,
from_args: from_args
});
......
......@@ -239,7 +239,7 @@ impl Inlining {
// which will receive results from inlined function
let old_name = cur_block.name();
let new_name =
format!("{}_cont_after_inline_{}", old_name, inst_id);
Arc::new(format!("{}_cont_after_inline_{}", old_name, inst_id));
trace!("create continue block for EXPRCALL/CCALL: {}", &new_name);
cur_block =
Block::new(MuEntityHeader::named(vm.next_id(), new_name));
......@@ -307,7 +307,8 @@ impl Inlining {
inlined_fv_guard.sig.ret_tys.len()
{
debug!("need an extra block for passing normal dest arguments");
let int_block_name = format!("inline_{}_arg_pass", inst_id);
let int_block_name =
Arc::new(format!("inline_{}_arg_pass", inst_id));
let mut intermediate_block = Block::new(
MuEntityHeader::named(vm.next_id(), int_block_name)
);
......@@ -420,7 +421,7 @@ fn copy_inline_blocks(
let mut block = Block {
hdr: MuEntityHeader::named(
new_id,
format!("{}:inlinedblock.#{}", old_block.name(), new_id)
Arc::new(format!("{}:inlinedblock.#{}", old_block.name(), new_id))
),
content: Some(old_block.content.as_ref().unwrap().clone_empty()),
trace_hint: TraceHint::None,
......
......@@ -50,7 +50,7 @@ impl CompilerPass for RetSink {
// create a return sink
let return_sink = {
let block_name = format!("{}:{}", func.name(), EPILOGUE_BLOCK_NAME);
let block_name = Arc::new(format!("{}:{}", func.name(), EPILOGUE_BLOCK_NAME));
trace!("created return sink {}", block_name);
let mut block = Block::new(MuEntityHeader::named(vm.next_id(), block_name));
......
......@@ -437,7 +437,8 @@ fn branch_adjustment(func: &mut MuFunctionVersion, vm: &VM) {
// Lnew_false (arg list):
// BRANCH Lfalse (arg list)
let new_false_block = {
let block_name = format!("{}:#{}:false", func.name(), node.id());
let block_name =
Arc::new(format!("{}:#{}:false", func.name(), node.id()));
let mut block =
Block::new(MuEntityHeader::named(vm.next_id(), block_name));
vm.set_name(block.as_entity());
......
......@@ -39,5 +39,5 @@ simple_logger = "*"
aligned_alloc = "*"
crossbeam = "*"
field-offset = "*"
rodal = { git = "https://gitlab.anu.edu.au/mu/rodal", version = ">= 0.0.5" }
rodal = { git = "https://gitlab.anu.edu.au/mu/rodal", version = ">= 0.0.10" }
#rodal = { path = "../../../rodal_test/rodal", version = ">= 0.0.5" }
// Copyright 2017 The Australian National University
//
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//
// http://www.apache.org/licenses/LICENSE-2.0
//
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
......
......@@ -377,7 +377,7 @@ pub fn compile_fncs<'a>(
/// gets the path for the generated code of a Mu function
fn get_path_for_mu_func(f: MuName, vm: &VM) -> PathBuf {
let mut ret = PathBuf::from(&vm.vm_options.flag_aot_emit_dir);
ret.push(f + ".S");
ret.push((*f).clone() + ".S");
ret
}
......@@ -393,7 +393,10 @@ fn get_path_for_mu_context(vm: &VM) -> PathBuf {
pub fn run_test(vm: &VM, test_name: &str, tester_name: &str) {
let output_name = test_name.to_string() + "_" + tester_name;
let executable = link_test_primordial(
vec![test_name.to_string(), tester_name.to_string()],
vec![
Arc::new(test_name.to_string()),
Arc::new(tester_name.to_string()),
],
output_name.as_str(),
vm
);
......@@ -655,9 +658,9 @@ pub fn run_test_2f(vm: &VM, test_name: &str, dep_name: &str, tester_name: &str)
let output_name = test_name.to_string() + "_" + tester_name;
let executable = link_test_primordial(
vec![
dep_name.to_string(),
test_name.to_string(),
tester_name.to_string(),
Arc::new(dep_name.to_string()),
Arc::new(test_name.to_string()),
Arc::new(tester_name.to_string()),
],
output_name.as_str(),
vm
......
This diff is collapsed.
......@@ -42,7 +42,9 @@ pub mod entrypoints;
/// exception handling
pub mod exception;
lazy_static!{
static ref UNKNOWN_FUNCTION_NAME : CName = Arc::new("UNKOWN".to_string());
}
/// returns name for a function address
// FIXME: this actually returns the name and address of the nearest symbol (of any type)
// that starts before function_addr (instead we want the nearest function symbol)
......@@ -62,14 +64,19 @@ pub fn get_function_info(function_addr: Address) -> (CName, Address) {
}
if !info.dli_sname.is_null() {
(
unsafe { CStr::from_ptr(info.dli_sname) }
.to_str()
.unwrap()
.to_string(),
Arc::new(
unsafe { CStr::from_ptr(info.dli_sname) }
.to_str()
.unwrap()
.to_string()
),
Address::from_ptr(info.dli_saddr)
)
} else {
("UNKOWN".to_string(), Address::from_ptr(info.dli_saddr))
(
UNKNOWN_FUNCTION_NAME.clone(),
Address::from_ptr(info.dli_saddr)
)
}
}
......
......@@ -24,7 +24,7 @@ crate-type = ["rlib"]
memmap = "*"
memsec = "0.1.9"
byteorder = "*"
rodal = { git = "https://gitlab.anu.edu.au/mu/rodal", version = ">= 0.0.5" }
rodal = { git = "https://gitlab.anu.edu.au/mu/rodal", version = ">= 0.0.10" }
#rodal = { path = "../../../rodal_test/rodal", version = ">= 0.0.5" }
log = "*"
doubly = "1.1.3"
......@@ -29,7 +29,7 @@ use std::ptr;
use std::os::raw::*;
use std::ffi::CStr;
use std::slice;
use std::sync::Arc;
use super::api_c::*;
use super::api_impl::*;
use super::deps::*;
......@@ -69,7 +69,7 @@ fn from_MuIRBuilder_ptr<'c>(ptr: *mut CMuIRBuilder) -> *mut MuIRBuilder {
#[inline(always)]
fn from_MuName(cname: CMuName) -> MuName {
from_MuCString(cname)
Arc::new(from_MuCString(cname))
}
#[inline(always)]
......@@ -89,6 +89,15 @@ fn from_MuCString_optional(cstring: CMuCString) -> Option<String> {
}
}
#[inline(always)]
fn from_MuName_optional(cstring: CMuName) -> Option<MuName> {
if cstring.is_null() {
None
} else {
Some(from_MuName(cstring))
}
}
#[inline(always)]
fn from_MuID(cmuid: CMuID) -> MuID {
debug_assert!(cmuid != 0);
......@@ -183,6 +192,13 @@ fn from_MuCString_array<'a>(ptr: *const CMuCString, len: usize) -> Vec<String> {
slc.iter().map(|&e| from_MuCString(e)).collect::<Vec<_>>()
}
#[inline(always)]
fn from_MuName_array<'a>(ptr: *const CMuName, len: usize) -> Vec<MuName> {
let slc = from_array_direct(ptr, len);
slc.iter().map(|&e| from_MuName(e)).collect::<Vec<_>>()
}
// The following functions `to_*` converts high-level types to C-like types.
#[inline(always)]
......@@ -1189,9 +1205,9 @@ extern "C" fn _forwarder__MuCtx__make_boot_image(
let mut _arg_primordial_stack = from_handle_optional(primordial_stack);
let mut _arg_primordial_threadlocal = from_handle_optional(primordial_threadlocal);
let mut _arg_sym_fields = from_handle_array(sym_fields, nsyms);
let mut _arg_sym_strings = from_MuCString_array(sym_strings, nsyms);
let mut _arg_sym_strings = from_MuName_array(sym_strings, nsyms);
let mut _arg_reloc_fields = from_handle_array(reloc_fields, nrelocs);
let mut _arg_reloc_strings = from_MuCString_array(reloc_strings, nrelocs);
let mut _arg_reloc_strings = from_MuName_array(reloc_strings, nrelocs);
let mut _arg_output_file = from_MuCString(output_file);
unsafe {
(*_arg_ctx).make_boot_image(
......@@ -1220,7 +1236,7 @@ extern "C" fn _forwarder__MuIRBuilder__abort(b: *mut CMuIRBuilder) {
extern "C" fn _forwarder__MuIRBuilder__gen_sym(b: *mut CMuIRBuilder, name: CMuCString) -> CMuID {
let mut _arg_b = from_MuIRBuilder_ptr(b);
let mut _arg_name = from_MuCString_optional(name);
let mut _arg_name = from_MuName_optional(name);
let _rv = unsafe { (*_arg_b).gen_sym(_arg_name) };
let _rv_prep = to_MuID(_rv);
_rv_prep
......@@ -1501,7 +1517,7 @@ extern "C" fn _forwarder__MuIRBuilder__new_const_extern(
let mut _arg_b = from_MuIRBuilder_ptr(b);
let mut _arg_id = from_MuID(id);
let mut _arg_ty = from_MuID(ty);
let mut _arg_symbol = from_MuCString(symbol);
let mut _arg_symbol = from_MuName(symbol);
unsafe { (*_arg_b).new_const_extern(_arg_id, _arg_ty, _arg_symbol) };
}
......
......@@ -121,7 +121,7 @@ pub enum NodeConst {
ConstExtern {
id: MuID,
ty: MuTypeNode,
symbol: String
symbol: CName
}
}
......
......@@ -517,9 +517,9 @@ impl MuCtx {
primordial_stack: Option<&APIHandle>,
primordial_threadlocal: Option<&APIHandle>,
sym_fields: Vec<&APIHandle>,
sym_strings: Vec<String>,
sym_strings: Vec<MuName>,
reloc_fields: Vec<&APIHandle>,
reloc_strings: Vec<String>,
reloc_strings: Vec<MuName>,
output_file: String
) {
self.get_mvm().vm.make_boot_image(
......
......@@ -124,7 +124,7 @@ impl MuIRBuilder {
self.deallocate();
}
pub fn gen_sym(&mut self, name: Option<String>) -> MuID {
pub fn gen_sym(&mut self, name: Option<MuName>) -> MuID {
let my_id = self.next_id();
trace!("gen_sym({:?}) -> {}", name, my_id);
......@@ -351,7 +351,7 @@ impl MuIRBuilder {
);
}
pub fn new_const_extern(&mut self, id: MuID, ty: MuID, symbol: String) {
pub fn new_const_extern(&mut self, id: MuID, ty: MuID, symbol: MuName) {
self.bundle.consts.insert(
id,
Box::new(NodeConst::ConstExtern {
......@@ -1705,13 +1705,13 @@ impl<'lb, 'lvm> BundleLoader<'lb, 'lvm> {
fn ensure_name(&mut self, id: MuID, parent_id: Option<MuID>) {
let prefix = match parent_id {
Some(parent_id) => self.get_name(parent_id) + ".",
Some(parent_id) => (*self.get_name(parent_id)).clone() + ".",
None => "".to_string()
};
self.id_name_map.entry(id).or_insert_with(|| {
let name = format!("{}#{}", prefix, id);
trace!("Making name for ID {} : {}", id, name);
name
Arc::new(name)
});
}
......@@ -1830,11 +1830,11 @@ impl<'lb, 'lvm> BundleLoader<'lb, 'lvm> {
}
}
fn get_name(&self, id: MuID) -> String {
fn get_name(&self, id: MuID) -> MuName {
self.id_name_map.get(&id).unwrap().clone()
}
fn maybe_get_name(&self, id: MuID) -> Option<String> {
fn maybe_get_name(&self, id: MuID) -> Option<MuName> {
self.id_name_map.get(&id).cloned()
}
......@@ -2183,7 +2183,7 @@ impl<'lb, 'lvm> BundleLoader<'lb, 'lvm> {
let hdr = self.make_mu_entity_header(id);
let impl_ty = self.ensure_type_rec(global.ty); // global type