Beispiel #1
0
 public void Visit(StoreLocalVariableEntry entry)
 {
     Print($"STORE_LCL_VAR {entry.LocalNumber}");
     _indent++;
     entry.Op1.Accept(this);
     _indent--;
 }
Beispiel #2
0
        public void Import(Instruction instruction, ImportContext context, IILImporterProxy importer)
        {
            var op1 = importer.PopExpression();

            // Need to spill result removed from stack to a temp that will never be used
            var lclNum = importer.GrabTemp(op1.Kind, op1.ExactSize);
            var node   = new StoreLocalVariableEntry(lclNum, false, op1);

            // ctor has no return type so just append the tree
            importer.ImportAppendTree(node);
        }
Beispiel #3
0
        public void Import(Instruction instruction, ImportContext context, IILImporterProxy importer)
        {
            var value = importer.PopExpression();

            if (value.Kind != StackValueKind.Int32 && value.Kind != StackValueKind.ObjRef)
            {
                throw new NotSupportedException("Storing to argument other than short, int32 or object refs not supported yet");
            }
            var node = new StoreLocalVariableEntry((instruction.OperandAs <Parameter>()).Index, true, value);

            importer.ImportAppendTree(node);
        }
Beispiel #4
0
        private StackEntry ImportSpillStackEntry(StackEntry entry, int?tempNumber = null)
        {
            if (tempNumber == null)
            {
                tempNumber = GrabTemp(entry.Kind, entry.ExactSize);
                var temp = _localVariableTable[tempNumber.Value];
            }

            var node = new StoreLocalVariableEntry(tempNumber.Value, false, entry);

            ImportAppendTree(node);

            return(new LocalVariableEntry(tempNumber.Value, entry.Kind, entry.ExactSize));
        }
Beispiel #5
0
        public void Import(Instruction instruction, ImportContext context, IILImporterProxy importer)
        {
            int index = GetIndex(instruction);

            var value = importer.PopExpression();

            if (value.Kind != StackValueKind.Int32 && value.Kind != StackValueKind.ObjRef && value.Kind != StackValueKind.ValueType && value.Kind != StackValueKind.NativeInt)
            {
                throw new NotSupportedException("Storing variables other than short, int32 ,object refs, or valuetypes not supported yet");
            }
            var localNumber = importer.ParameterCount + index;
            var node        = new StoreLocalVariableEntry(localNumber, false, value);

            importer.ImportAppendTree(node, true);
        }
Beispiel #6
0
        public void Import(Instruction instruction, ImportContext context, IILImporterProxy importer)
        {
            var methodDefOrRef = instruction.Operand as IMethodDefOrRef;
            var methodToCall   = methodDefOrRef.ResolveMethodDefThrow();

            var declType = methodToCall.DeclaringType;

            var objType = declType.ToTypeSig();
            var objKind = objType.GetStackValueKind();
            var objSize = objType.GetExactSize();

            if (declType.IsValueType)
            {
                // Allocate memory on the stack for the value type as a temp local variable
                var lclNum        = importer.GrabTemp(objKind, objSize);
                var newObjThisPtr = new LocalVariableAddressEntry(lclNum);

                // Call the valuetype constructor
                CallImporter.ImportCall(instruction, context, importer, newObjThisPtr);

                var node = new LocalVariableEntry(lclNum, objKind, objSize);
                importer.PushExpression(node);
            }
            else
            {
                // Allocate memory for object
                var op1 = new AllocObjEntry((int)declType.ClassSize, objKind);

                // Store allocated memory address into a temp local variable
                var lclNum = importer.GrabTemp(objKind, objSize);
                var asg    = new StoreLocalVariableEntry(lclNum, false, op1);
                importer.ImportAppendTree(asg);

                // Call the constructor
                var newObjThisPtr = new LocalVariableEntry(lclNum, objKind, objSize);
                CallImporter.ImportCall(instruction, context, importer, newObjThisPtr);

                // Push a local variable entry corresponding to the object here
                var node = new LocalVariableEntry(lclNum, objKind, objSize);
                importer.PushExpression(node);
            }
        }
Beispiel #7
0
 public void Visit(StoreLocalVariableEntry entry)
 {
     _sb.AppendLine($"       ┌──▌  t{entry.Op1.TreeID}");
     _sb.AppendLine($"       storelcl {entry.LocalNumber}");
 }
 public void Visit(StoreLocalVariableEntry entry)
 {
     _genericStackEntryVisitor.Visit <StoreLocalVariableEntry>(entry);
 }
Beispiel #9
0
 public void Visit(StoreLocalVariableEntry entry)
 {
     entry.Op1.Accept(this);
     SetNext(entry);
 }