WARNING! Access to this system is limited to authorised users only.
Unauthorised users may be subject to prosecution.
Unauthorised access to this system is a criminal offence under Australian law (Federal Crimes Act 1914 Part VIA)
It is a criminal offence to:
(1) Obtain access to data without authority. -Penalty 2 years imprisonment.
(2) Damage, delete, alter or insert data without authority. -Penalty 10 years imprisonment.
User activity is monitored and recorded. Anyone using this system expressly consents to such monitoring and recording.

To protect your data, the CISO officer has suggested users to enable 2FA as soon as possible.
Currently 2.2% of users enabled 2FA.

Commit f66a2348 authored by qinsoon's avatar qinsoon
Browse files

use default debug info. move previous Debug impl as Display

parent 0b7c8424
This diff is collapsed.
......@@ -7,7 +7,7 @@ use std::sync::RwLock;
pub type MuType = MuType_;
#[derive(Clone, PartialEq, Eq)]
#[derive(Clone, PartialEq, Eq, Debug)]
pub enum MuType_ {
/// int <length>
Int (usize),
......@@ -56,25 +56,25 @@ pub enum MuType_ {
UFuncPtr (P<MuFuncSig>),
}
impl fmt::Debug for MuType_ {
impl fmt::Display for MuType_ {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
match self {
&MuType_::Int(n) => write!(f, "int<{}>", n),
&MuType_::Float => write!(f, "float"),
&MuType_::Double => write!(f, "double"),
&MuType_::Ref(ref ty) => write!(f, "ref<{:?}>", ty),
&MuType_::IRef(ref ty) => write!(f, "iref<{:?}>", ty),
&MuType_::WeakRef(ref ty) => write!(f, "weakref<{:?}>", ty),
&MuType_::UPtr(ref ty) => write!(f, "uptr<{:?}>", ty),
&MuType_::Array(ref ty, size) => write!(f, "array<{:?} {:?}>", ty, size),
&MuType_::Hybrid(ref fix_tys, ref var_ty) => write!(f, "hybrid<{:?} {:?}>", fix_tys, var_ty),
&MuType_::Ref(ref ty) => write!(f, "ref<{}>", ty),
&MuType_::IRef(ref ty) => write!(f, "iref<{}>", ty),
&MuType_::WeakRef(ref ty) => write!(f, "weakref<{}>", ty),
&MuType_::UPtr(ref ty) => write!(f, "uptr<{}>", ty),
&MuType_::Array(ref ty, size) => write!(f, "array<{} {}>", ty, size),
&MuType_::Hybrid(ref fix_tys, ref var_ty) => write!(f, "hybrid<[{}] {}>", type_vector_str(fix_tys), var_ty),
&MuType_::Void => write!(f, "void"),
&MuType_::ThreadRef => write!(f, "threadref"),
&MuType_::StackRef => write!(f, "stackref"),
&MuType_::Tagref64 => write!(f, "tagref64"),
&MuType_::Vector(ref ty, size) => write!(f, "vector<{:?} {:?}>", ty, size),
&MuType_::FuncRef(ref sig) => write!(f, "funcref<{:?}>", sig),
&MuType_::UFuncPtr(ref sig) => write!(f, "ufuncref<{:?}>", sig),
&MuType_::Vector(ref ty, size) => write!(f, "vector<{} {}>", ty, size),
&MuType_::FuncRef(ref sig) => write!(f, "funcref<{}>", sig),
&MuType_::UFuncPtr(ref sig) => write!(f, "ufuncref<{}>", sig),
&MuType_::Struct(tag) => write!(f, "{}(struct)", tag)
}
}
......@@ -85,17 +85,17 @@ lazy_static! {
pub static ref STRUCT_TAG_MAP : RwLock<HashMap<MuTag, StructType_>> = RwLock::new(HashMap::new());
}
#[derive(Clone, PartialEq, Eq)]
#[derive(Clone, PartialEq, Eq, Debug)]
pub struct StructType_ {
tys: Vec<P<MuType_>>
}
impl fmt::Debug for StructType_ {
impl fmt::Display for StructType_ {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "struct<").unwrap();
for i in 0..self.tys.len() {
let ty = &self.tys[i];
write!(f, "{:?}", ty).unwrap();
write!(f, "{}", ty).unwrap();
if i != self.tys.len() - 1 {
write!(f, " ").unwrap();
}
......@@ -293,14 +293,25 @@ macro_rules! is_type (
)
);
#[derive(Clone, PartialEq, Eq)]
#[derive(Clone, PartialEq, Eq, Debug)]
pub struct MuFuncSig {
pub ret_tys : Vec<P<MuType>>,
pub arg_tys: Vec<P<MuType>>
}
impl fmt::Debug for MuFuncSig {
impl fmt::Display for MuFuncSig {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{:?} -> {:?}", self.ret_tys, self.arg_tys)
write!(f, "[{}] -> [{}]", type_vector_str(&self.ret_tys), type_vector_str(&self.arg_tys))
}
}
fn type_vector_str(vec: &Vec<P<MuType>>) -> String {
let mut ret = String::new();
for i in 0..vec.len() {
ret.push_str(fmt::format(format_args!("{}", vec[i])).as_str());
if i != vec.len() - 1 {
ret.push_str(", ");
}
}
ret
}
\ No newline at end of file
......@@ -57,7 +57,7 @@ pub trait CompilerPass {
self.visit_block(vm_context, &mut func.context, block);
for inst in block.content.as_mut().unwrap().body.iter_mut() {
debug!("{:?}", inst);
debug!("{}", inst);
self.visit_inst(vm_context, &mut func.context, inst);
}
......
......@@ -63,7 +63,7 @@ impl CompilerPass for DefUse {
debug!("check use count for variables");
for entry in func.context.values.values() {
debug!("{}({}): {}", entry.tag, entry.id, entry.use_count.get())
debug!("{}#{}: {}", entry.tag, entry.id, entry.use_count.get())
}
}
}
\ No newline at end of file
......@@ -39,7 +39,7 @@ impl CompilerPass for TreeGen {
trace!("");
for node in body.into_iter() {
trace!("check inst: {:?}", node);
trace!("check inst: {}", node);
match &node.v {
&TreeNode_::Instruction(ref inst) => {
// check if any operands can be replaced by expression
......@@ -56,11 +56,11 @@ impl CompilerPass for TreeGen {
// replace the node with its expr
let expr = entry_value.expr.take().unwrap();
trace!("{:?} replaced by {:?}", ops[index], expr);
trace!("{} replaced by {}", ops[index], expr);
ops[index] = TreeNode::new_inst(expr);
}
} else {
trace!("{:?} cant be replaced", ops[index]);
trace!("{} cant be replaced", ops[index]);
}
}
}
......@@ -97,7 +97,7 @@ impl CompilerPass for TreeGen {
_ => panic!("expected an instruction node here")
}
trace!("add {:?} back to block {}", node, label);
trace!("add {} back to block {}", node, label);
trace!("");
new_body.push(node);
}
......@@ -123,7 +123,7 @@ impl CompilerPass for TreeGen {
debug!("block {}", entry.0);
for inst in entry.1.content.as_ref().unwrap().body.iter() {
debug!("{:?}", inst);
debug!("{}", inst);
}
}
}
......
......@@ -5,13 +5,13 @@ use self::mu::ast::types::*;
macro_rules! assert_type (
($test:expr, $expect: expr) => (
assert_eq!(format!("{:?}", $test), $expect)
assert_eq!(format!("{}", $test), $expect)
)
);
macro_rules! println_type (
($test:expr) => (
println!("{:?}", $test)
println!("{}", $test)
)
);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment