Пример #1
0
 internal void AddCreator(Node upNode, Variable var)
 {
     this.crtrs[new VariablePrimitiveCreator(upNode, var)] = true;
 }
Пример #2
0
 public LoadVarAddr(Variable var)
     : base(var)
 {
 }
Пример #3
0
 private LocalBuilder GetLocal(Variable var)
 {
     return((LocalBuilder)locals[var]);
 }
Пример #4
0
 internal VariablePrimitiveCreator(Node upNode, Variable var)
     : base(upNode)
 {
     this.Variable = var;
 }
Пример #5
0
 internal void Remove(Variable var)
 {
     map.Remove(var);
 }
Пример #6
0
        public Variable CreateVar(Type type, VariableKind kind)
        {
            Variable var = new Variable(type,kind);
            vars.Add(var.Index,var);

            if (var.Kind != VariableKind.Local)
                mapper.Add(var);

            return var;
        }
Пример #7
0
 internal NodeAndVariables(Node upNode, Variable[] vars)
 {
     this.Node = upNode;
     this.Variables = vars;
 }
Пример #8
0
        private void setVarByIndex()
        {
            Block block = Parent;

            if (var != null)
                var.removeUser(this);

            if (block == null)
                var = null;
            else
            {
            while (! (block is MethodBodyBlock))
                if (block != null)
                    block = block.Parent;
                else
                    throw new MbbNotAvailableException(this);

                var = (block as MethodBodyBlock).Variables.getVarByIndex(varIndex);

                if (var == null)
                    throw new VariableNotInMbbException(this);

                var.addUser(this);
            }
        }
Пример #9
0
 private static PointerToNode initVariable(Variable varUp, PointerToNode ptrUp)
 {
     // Postprocessor dows not support LoadVarAddr
     return ptrUp;
     if (varUp.Type.IsValueType)
     {
         ptrUp = new PointerToNode(ptrUp.Node = new LoadVarAddr(varUp));
         return new PointerToNode(ptrUp.Node = new InitValue(varUp.Type));
     }
     else
     {
         ptrUp = new PointerToNode(ptrUp.Node = new LoadConst(null));
         return new PointerToNode(ptrUp.Node = new StoreVar(varUp));
     }
 }
Пример #10
0
 private void getUpNode(Node downNode, MemoSpecState memo, out Variable[] vars1, out Node upNode, out Variable[] vars2)
 {
     NodeAndVariables nodeVars = this.getUpNodes(downNode)[memo.MemoState] as NodeAndVariables;
     if (nodeVars == null)
     {
         vars1 = null;
         upNode = null;
         vars2 = null;
     }
     else
     {
         vars1 = memo.Variables;
         upNode = nodeVars.Node;
         vars2 = nodeVars.Variables;
     }
 }
Пример #11
0
        private static void createSubstitution(Variable[] vars1, Variable[] vars2, PointerToNode ptrUpNode, Node upNode)
        {
            if (vars1.Length != vars2.Length)
                throw new InternalException();
            int length = vars1.Length;
            Hashtable hash12 = new Hashtable();
            Hashtable hash21 = new Hashtable();
            Hashtable processed = new Hashtable();

            for (int i=0; i<length; i++)
            {
                hash12[vars1[i]] = vars2[i];
                hash21[vars2[i]] = vars1[i];
            }

            for (int i=0; i<length; i++)
            {
                Variable var1 = vars1[i];
                Variable var2 = hash12[var1] as Variable;
                if (var2 == var1)
                    continue;
                if (processed.ContainsKey(var1))
                    continue;

                Variable Var = var1;
                bool isLoop = false;
                //Searching for the beginning of the chain
                for (;;)
                {
                    if (hash21[var1] == null)
                        break; //the beginning of the chain;
                    var2 = var1;
                    var1 = hash21[var2] as Variable;
                    if(var1 == Var)//the loop
                    {
                        isLoop = true;
                        ptrUpNode = new PointerToNode(ptrUpNode.Node = new LoadVar(Var));
                        Var = hash21[Var] as Variable;
                        hash12.Remove(Var);
                        //we break the loop at 'Var' to have a chain
                        break;
                    }
                }

                //processing the chain, loops are already broken
                for ( ;var2 != null; )
                {
                    ptrUpNode = new PointerToNode(ptrUpNode.Node = new LoadVar(var2));
                    ptrUpNode = new PointerToNode(ptrUpNode.Node = new StoreVar(var1));
                    processed[var1] = null; //mark var1 as 'processed'
                    var1 = var2;
                    var2 = hash12[var1] as Variable;
                }

                if (isLoop)
                {
                    //restore the loop
                    ptrUpNode = new PointerToNode(ptrUpNode.Node = new StoreVar(Var));
                    processed[Var] = null; //mark Var as 'processed'
                }
            }

            ptrUpNode.Node = upNode;
        }
Пример #12
0
 internal MemoSpecState(MemoState memo, Variable[] vars)
 {
     this.MemoState = memo;
     this.Variables = vars;
 }
Пример #13
0
 internal VariableLiftTask(Variable var)
 {
     this.Variable = var;
 }
Пример #14
0
 public ManageVar(Variable var)
     : base(1)
 {
     this.varIndex = var.Index;
     this.var = null;
 }
Пример #15
0
        internal MemoSpecState Memorize(VariablesHashtable varsHash, out ObjectHashtable objHash)
        {
            MemoState memo = this.state.Memorize(out objHash);
            PointerValue[] ptrs = varsHash.GetPointers(objHash);

            Variable[] vars = new Variable[ptrs.Length];
            for (int i=0; i < vars.Length; i++)
                vars[i] = varsHash[ptrs[i] as PointerValue] as Variable;

            return new MemoSpecState(memo, vars);
        }
Пример #16
0
 protected ManageVar(int varIndex)
     : base(1)
 {
     this.varIndex = varIndex;
     var = null;
 }
Пример #17
0
 private static bool varIsNotReferenced(Variable var)
 {
     return (bool)(var.Options[VAR_CATEGORY_OPTION]);
 }
Пример #18
0
 internal void Add(Variable var)
 {
     map.Add(var);
 }
Пример #19
0
        private VarUsage analyseVariable(Variable var)
        {
            BasicBlockStub[] stubArray = new BasicBlockStub[BlockList.Count];
            Hashtable hash = new Hashtable();
            for (int i = 0; i < BlockList.Count; i++)
            {
                stubArray[i] = new BasicBlockStub(var,BlockList[i]);
                hash.Add(BlockList[i],stubArray[i]);
            }

            for (int i = 0; i < BlockList.Count; i++)
                foreach (BasicBlock block in BlockList[i].Next)
                    stubArray[i].AddNext(hash[block] as BasicBlockStub);

            foreach (BasicBlockStub stub in stubArray)
                stub.Reduce();

            VarUsage result = new VarUsage();
            foreach (BasicBlockStub stub in stubArray)
                stub.AddToUsage(result);

            return result;
        }
Пример #20
0
 public StoreVar(Variable var)
     : base(var)
 {
 }
Пример #21
0
            public BasicBlockStub(Variable var, BasicBlock block)
            {
                prev = new ArrayList();
                next = new ArrayList();

                isEmpty = true;
                foreach (ManageVar node in var.UsersArray)
                    isEmpty &= (node.Options[BasicBlock.BASIC_BLOCK_OPTION] as BasicBlock) != block;

                usageArray = new NodeArray();
                if (! isEmpty)
                {
                    foreach (Node node in block.Body)
                        if (node is ManageVar)
                        {
                            ManageVar usage = node as ManageVar;
                            if (usage.Var == var)
                                usageArray.Add(usage);
                        }
                }
            }
Пример #22
0
        public void Remove(Variable var)
        {
            if (var.UsersArray.Count > 0)
                throw new VarRemovalProhibitedException();

            vars.Remove(var.Index);

            if (var.Kind != VariableKind.Local)
                mapper.Remove(var);
        }
Пример #23
0
 private int GetArgIndex(Variable var)
 {
     for(int i=0;i<paramMapper.Count;i++)
         if(var == paramMapper[i])
             return(i);
     //Andrew: Great idea...  :(
     throw new EmissionException();
 }