GitLab will be upgraded to the 12.10.14-ce.0 on 28 Sept 2020 at 2.00pm (AEDT) to 2.30pm (AEDT). During the update, GitLab and Mattermost services will not be available. If you have any concerns with this, please talk to us at N110 (b) CSIT building.

Commit 16930fc7 authored by qinsoon's avatar qinsoon

fix broken tests

parent ddef13d8
......@@ -38,28 +38,28 @@ impl MuFunction {
self.values.insert(id, ValueEntry{id: id, tag: tag, ty: ty.clone(), use_count: Cell::new(0)});
P(TreeNode {
v: TreeNode_::Value(P(Value{
tag: tag,
ty: ty,
v: Value_::SSAVar(id)
}))
v: TreeNode_::Value(P(Value{
tag: tag,
ty: ty,
v: Value_::SSAVar(id)
}))
})
}
pub fn new_constant(&mut self, id: MuID, tag: MuTag, ty: P<MuType>, v: Constant) -> P<TreeNode> {
pub fn new_constant(&mut self, tag: MuTag, ty: P<MuType>, v: Constant) -> P<TreeNode> {
P(TreeNode{
v: TreeNode_::Value(P(Value{
tag: tag,
ty: ty,
v: Value_::Constant(v)
}))
})
v: TreeNode_::Value(P(Value{
tag: tag,
ty: ty,
v: Value_::Constant(v)
}))
})
}
pub fn new_value(&mut self, v: P<Value>) -> P<TreeNode> {
P(TreeNode{
v: TreeNode_::Value(v)
})
v: TreeNode_::Value(v)
})
}
}
......
......@@ -8,7 +8,7 @@ use std::sync::RwLock;
pub type MuType = MuType_;
#[derive(Clone, PartialEq, Eq)]
enum MuType_ {
pub enum MuType_ {
/// int <length>
Int (usize),
/// float
......@@ -59,31 +59,23 @@ enum MuType_ {
impl fmt::Debug 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_::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_::Struct(tag) => {
write!(f, "<struct<").unwrap();
let struct_tag_map_lock = STRUCT_TAG_MAP.read().unwrap();
let struct_ty = struct_tag_map_lock.get(tag);
for ty in struct_ty {
write!(f, "{:?}", ty).unwrap()
}
write!(f, ">>")
}
&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_::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_::Struct(tag) => write!(f, "{}(struct)", tag)
}
}
}
......@@ -100,10 +92,15 @@ pub struct StructType_ {
impl fmt::Debug for StructType_ {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
for ty in self.tys.iter() {
write!(f, "struct<").unwrap();
for i in 0..self.tys.len() {
let ty = &self.tys[i];
write!(f, "{:?}", ty).unwrap();
if i != self.tys.len() - 1 {
write!(f, " ").unwrap();
}
}
write!(f, "")
write!(f, ">")
}
}
......
use ast::ir::*;
use ast::ptr::*;
use vm::context::VMContext;
use std::cell::RefCell;
......
......@@ -5,7 +5,7 @@ use compiler::CompilerPass;
pub struct TreeGenerationPass {
name: &'static str,
}
}
impl TreeGenerationPass {
pub fn new(name: &'static str) -> TreeGenerationPass {
......
......@@ -4,7 +4,6 @@ use ast::ptr::P;
use ast::ir::*;
use ast::types::*;
use std::cell::Cell;
use std::cell::RefCell;
pub struct VMContext {
......
......@@ -80,28 +80,28 @@ fn create_types() -> Vec<P<MuType>> {
fn test_type_constructors() {
let types = create_types();
assert_type!(*types[0], "Int(8)");
assert_type!(*types[1], "Float");
assert_type!(*types[2], "Double");
assert_type!(*types[3], "Ref(Int(8))");
assert_type!(*types[4], "IRef(Int(8))");
assert_type!(*types[5], "WeakRef(Int(8))");
assert_type!(*types[6], "UPtr(Int(8))");
assert_type!(*types[7], "Struct(\"MyStructTag1\")");
assert_type!(*types[0], "int<8>");
assert_type!(*types[1], "float");
assert_type!(*types[2], "double");
assert_type!(*types[3], "ref<int<8>>");
assert_type!(*types[4], "iref<int<8>>");
assert_type!(*types[5], "weakref<int<8>>");
assert_type!(*types[6], "uptr<int<8>>");
assert_type!(*types[7], "MyStructTag1(struct)");
{
let map = STRUCT_TAG_MAP.read().unwrap();
let t7_struct_ty = map.get("MyStructTag1").unwrap();
assert_type!(t7_struct_ty, "StructType_ { tys: [Int(8), Float] }");
assert_type!(t7_struct_ty, "struct<int<8> float>");
}
assert_type!(*types[8], "Array(Int(8), 5)");
assert_type!(*types[9], "Hybrid([Struct(\"MyStructTag1\"), Float], Int(8))");
assert_type!(*types[10], "Void");
assert_type!(*types[11], "ThreadRef");
assert_type!(*types[12], "StackRef");
assert_type!(*types[13], "Tagref64");
assert_type!(*types[14], "Vector(Int(8), 5)");
assert_type!(*types[15], "FuncRef(MuFuncSig { ret_tys: [Void], arg_tys: [Int(8), Int(8)] })");
assert_type!(*types[16], "UFuncPtr(MuFuncSig { ret_tys: [Void], arg_tys: [Int(8), Int(8)] })");
assert_type!(*types[8], "array<int<8> 5>");
assert_type!(*types[9], "hybrid<[MyStructTag1(struct), float] int<8>>");
assert_type!(*types[10], "void");
assert_type!(*types[11], "threadref");
assert_type!(*types[12], "stackref");
assert_type!(*types[13], "tagref64");
assert_type!(*types[14], "vector<int<8> 5>");
assert_type!(*types[15], "funcref<[void] -> [int<8>, int<8>]>");
assert_type!(*types[16], "ufuncref<[void] -> [int<8>, int<8>]>");
}
#[test]
......@@ -118,7 +118,7 @@ fn test_cyclic_struct() {
let map = STRUCT_TAG_MAP.read().unwrap();
let struct_ty = map.get("MyStructTag2").unwrap();
assert_type!(struct_ty, "StructType_ { tys: [Ref(Struct(\"MyStructTag2\")), Int(32)] }");
assert_type!(struct_ty, "struct<ref<MyStructTag2(struct)> int<32>>");
}
#[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