Ejemplo n.º 1
0
        //given a partially coloured graph and a node, attempts to integrate node
        public static List<List<string>> appendToAllocated(List<List<string>> alloc, Node n)
        {
            List<string> regs = getRegisters();
            Regex literal = new Regex(@"^[0-9]+");
            Regex str = new Regex(@"^"".+""");
            Regex memory = new Regex(@"[MEM.+]");

            if(literal.IsMatch(n.id)){
            alloc.Add(new List<string>(){n.id,"="+n.id});
            return alloc;
            }
            else if(str.IsMatch(n.id) || memory.IsMatch(n.id)){
            alloc.Add(new List<string>(){n.id, n.id});
            return alloc;
            }
            for(int i = 0; i < alloc.Count; i++){
            if(n.interferes(alloc[i][0])){
                regs.Remove(alloc[i][1]);
            }
            }
            if(regs.Count > 0){
            alloc.Add(new List<string>(){n.id,regs[0]});
            return alloc;
            }
            return null;
        }
Ejemplo n.º 2
0
 public void Remove(Node n)
 {
     interfere.Remove(n);
 }
Ejemplo n.º 3
0
 public void link(Node n)
 {
     if(this.id != n.id){
     if(!this.interferes(n.id)){
         this.interfere.Add(n);
     }
     if(!n.interferes(this.id)){
         n.interfere.Add(this);
     }
     }
 }
Ejemplo n.º 4
0
 public void Remove(Node n)
 {
     this.nodes.Remove(n);
     for(int i = 0; i < this.nodes.Count; i++){
     nodes[i].Remove(n);
     }
     Count--;
 }
Ejemplo n.º 5
0
 //returns a node given an id
 public Node getNode(string s)
 {
     for(int i = 0; i < this.nodes.Count; i++){
     if(this.nodes[i].id == s){
         return this.nodes[i];
     }
     }
     //if node does not exist create and add
     Node n = new Node(s);
     this.Add(n);
     return n;
 }
Ejemplo n.º 6
0
 public void Add(Node n)
 {
     this.nodes.Add(n);
     for(int i = 0; i < n.interfere.Count; i++){
     if(nodes.Contains(n.interfere[i])){
         n.interfere[i].link(n);
     }
     }
     Count++;
 }