Esempio n. 1
0
        private void ImportLoadInt(long value, StackValueKind kind)
        {
            switch (kind)
            {
            case StackValueKind.Int32:
            case StackValueKind.NativeInt:
                _stack.Push(new Int32ConstantEntry((int)value, _method.Context.GetWellKnownType(WellKnownType.Int32)));
                break;

            case StackValueKind.Int64:
                _stack.Push(new Int64ConstantEntry(value, _method.Context.GetWellKnownType(WellKnownType.Int64)));
                break;

            default:
                throw new InvalidOperationException(kind.ToString());
            }
        }
Esempio n. 2
0
        private void AppendCastIfNecessary(StackValueKind dstType, TypeDesc srcType)
        {
            if (dstType == StackValueKind.ByRef)
            {
                throw new NotImplementedException();

                /*
                 * Append("(");
                 * Append(GetSignatureTypeNameAndAddReference(srcType));
                 * Append(")");*/
            }
            else
            if (srcType.IsPointer)
            {
                throw new NotImplementedException();
                //Append("(intptr_t)");
            }
        }
Esempio n. 3
0
        public static int GetExactSize(StackValueKind kind)
        {
            switch (kind)
            {
            case StackValueKind.Int32:
                return(4);

            case StackValueKind.Int64:
                return(8);

            case StackValueKind.ObjRef:
                return(2);

            case StackValueKind.NativeInt:
                return(2);

            case StackValueKind.ByRef:
                return(2);

            default:
                throw new NotImplementedException($"Kind {kind} not yet supported");
            }
        }
Esempio n. 4
0
 public LLVMValueRef ValueForStackKind(StackValueKind kind, LLVMBuilderRef builder, bool signExtend)
 {
     if (kind == StackValueKind.Int32)
     {
         return(ValueAsInt32(builder, signExtend));
     }
     else if (kind == StackValueKind.Int64)
     {
         return(ValueAsInt64(builder, signExtend));
     }
     else if (kind == StackValueKind.Float)
     {
         return(ValueAsType(LLVM.FloatType(), builder));
     }
     else if (kind == StackValueKind.NativeInt || kind == StackValueKind.ByRef || kind == StackValueKind.ObjRef)
     {
         return(ValueAsInt32(builder, false));
     }
     else
     {
         throw new NotImplementedException();
     }
 }
Esempio n. 5
0
 public LLVMValueRef ValueForStackKind(StackValueKind kind, LLVMBuilderRef builder, bool signExtend)
 {
     if (kind == StackValueKind.Int32)
     {
         return(ValueAsInt32(builder, signExtend));
     }
     else if (kind == StackValueKind.Int64)
     {
         return(ValueAsInt64(builder, signExtend));
     }
     else if (kind == StackValueKind.Float)
     {
         return(ValueAsType(Type.IsWellKnownType(WellKnownType.Single) ? ILImporter.Context.FloatType : ILImporter.Context.DoubleType, builder));
     }
     else if (kind == StackValueKind.NativeInt || kind == StackValueKind.ByRef || kind == StackValueKind.ObjRef)
     {
         return(ValueAsInt32(builder, false));
     }
     else
     {
         throw new NotImplementedException();
     }
 }
Esempio n. 6
0
 protected ConstantEntry(StackValueKind kind, LLVMValueRef llvmValue, TypeDesc type = null) : base(kind, llvmValue, type)
 {
 }
Esempio n. 7
0
 private void AppendCastIfNecessary(StackValueKind dstType, TypeDesc srcType)
 {
     if (dstType == StackValueKind.ByRef)
     {
         Append("(");
         Append(_writer.GetCppSignatureTypeName(srcType));
         Append(")");
     }
     else
     if (srcType.IsPointer)
     {
         Append("(intptr_t)");
     }
 }
Esempio n. 8
0
      /// <summary>
        /// Push an expression named <paramref name="name"/> of kind <paramref name="kind"/>.
        /// </summary>
        /// <param name="kind">Kind of entry in stack</param>
        /// <param name="name">Variable to be pushed</param>
        /// <param name="type">Type if any of <paramref name="name"/></param>
        private void PushExpression(StackValueKind kind, string name, TypeDesc type = null)
        {
            Debug.Assert(kind != StackValueKind.Unknown, "Unknown stack kind");

            _stack.Push(new ExpressionEntry(kind, name, type));
        }
Esempio n. 9
0
 private void ImportLoadInt(long value, StackValueKind kind)
 {
     if (kind == StackValueKind.Int64)
     {
         _stack.Push(new Int64ConstantEntry(value));
     }
     else
     {
         Debug.Assert(value >= Int32.MinValue && value <= Int32.MaxValue, "Value too large for an Int32.");
         _stack.Push(new Int32ConstantEntry(checked((int) value)));
     }
 }
Esempio n. 10
0
        private Value NewSpillSlot(StackValueKind kind, TypeDesc type)
        {
            if (_spillSlots == null)
                _spillSlots = new List<SpillSlot>();

            SpillSlot spillSlot = new SpillSlot();
            spillSlot.Kind = kind;
            spillSlot.Type = type;
            spillSlot.Name = "_s" + _spillSlots.Count.ToString();

            _spillSlots.Add(spillSlot);

            return new Value() { Name = spillSlot.Name };
        }
Esempio n. 11
0
        private void PushTemp(StackValueKind kind, TypeDesc type = null)
        {
            string temp = NewTempName();

            Push(kind, new Value(temp), type);

            _builder.Append(GetStackValueKindCPPTypeName(kind, type));
            _builder.Append(" ");
            _builder.Append(temp);
            _builder.Append("=");
        }
Esempio n. 12
0
 public GenericReturnExpressionEntry(TypeDesc genericReturnTypeDesc, StackValueKind kind, string name, LLVMValueRef llvmValue, TypeDesc type = null)
     : base(kind, name, llvmValue, type)
 {
     GenericReturnTypeDesc = genericReturnTypeDesc;
 }
Esempio n. 13
0
 public BinaryOperator(Operation operation, bool isComparison, StackEntry op1, StackEntry op2, StackValueKind kind) : base(kind, op1.ExactSize)
 {
     Operation    = operation;
     IsComparison = isComparison;
     Op1          = op1;
     Op2          = op2;
 }
Esempio n. 14
0
 private void ImportLoadInt(long value, StackValueKind kind)
 {
 }
Esempio n. 15
0
 public LocalHeapEntry(StackEntry op1, StackValueKind objKind) : base(objKind)
 {
     Op1 = op1;
 }
Esempio n. 16
0
 public AllocObjEntry(int objSize, StackValueKind objKind) : base(objKind)
 {
     Size = objSize;
 }
Esempio n. 17
0
        private void PushTemp(StackValueKind kind, TypeDesc type = null)
        {
            string temp = NewTempName();

            Push(kind, new Value(temp), type);

            // Start declaration on a new line
            AppendLine();
            Append(GetStackValueKindCPPTypeName(kind, type));
            Append(" ");
            Append(temp);
            Append(" = ");
        }
Esempio n. 18
0
 public IntrinsicEntry(string targetMethod, IList <StackEntry> arguments, StackValueKind returnKind) : base(returnKind)
 {
     TargetMethod = targetMethod;
     Arguments    = arguments;
 }
Esempio n. 19
0
 public int GrabTemp(StackValueKind kind, int?exactSize) => _importer.GrabTemp(kind, exactSize);
Esempio n. 20
0
 private StackValue(StackValueKind kind, TypeDesc type = null, StackValueFlags flags = StackValueFlags.None)
 {
     this.Kind  = kind;
     this.Type  = type;
     this.Flags = flags;
 }
Esempio n. 21
0
 public LdTokenEntry(StackValueKind kind, string name, T token, TypeDesc type = null) : base(kind, name, default(LLVMValueRef), type)
 {
     LdToken = token;
 }
Esempio n. 22
0
 private StackValue(StackValueKind kind, TypeDesc type = null)
 {
     this.Kind = kind;
     this.Type = type;
 }
Esempio n. 23
0
 private void Push(StackValueKind kind, Value value, TypeDesc type = null)
 {
     Push(new StackValue() { Kind = kind, Type = type, Value = value });
 }
Esempio n. 24
0
 public LdTokenEntry(StackValueKind kind, string name, T token, LLVMValueRef llvmValue, TypeDesc type = null) : base(kind, name, llvmValue, type)
 {
     LdToken = token;
 }
Esempio n. 25
0
 private void AppendCastIfNecessary(TypeDesc destType, StackValueKind srcType)
 {
     if (destType.IsValueType)
         return;
     Append("(");
     Append(_writer.GetCppSignatureTypeName(destType));
     Append(")");
 }
Esempio n. 26
0
 public CastEntry(WellKnownType desiredType, StackEntry op1, StackValueKind kind) : base(kind, op1.ExactSize)
 {
     DesiredType = desiredType;
     Op1         = op1;
 }
Esempio n. 27
0
        private void ImportLoadInt(long value, StackValueKind kind)
        {
            string val;
            if (kind == StackValueKind.Int64)
            {
                if (value == Int64.MinValue)
                    val = "(int64_t)(0x8000000000000000" + (_msvc ? "i64" : "LL") + ")";
                else
                    val = value.ToString() + (_msvc ? "i64" : "LL");
            }
            else
            {
                if (value == Int32.MinValue)
                    val = "(int32_t)(0x80000000)";
                else
                    val = ((int)value).ToString();
            }

            Push(kind, new Value(val));
        }
Esempio n. 28
0
 public IndirectEntry(StackEntry op1, StackValueKind kind, int?exactSize, uint offset = 0) : base(kind, exactSize)
 {
     Op1    = op1;
     Offset = offset;
 }
Esempio n. 29
0
 private string GetStackValueKindCPPTypeName(StackValueKind kind, TypeDesc type = null)
 {
     switch (kind)
     {
         case StackValueKind.Int32: return "int32_t";
         case StackValueKind.Int64: return "int64_t";
         case StackValueKind.NativeInt: return "intptr_t";
         case StackValueKind.ObjRef: return "void*";
         case StackValueKind.Float: return "double";
         case StackValueKind.ByRef:
         case StackValueKind.ValueType: return _writer.GetCppSignatureTypeName(type);
         default: throw new NotSupportedException();
     }
 }
        public RuntimeValue GetStackFrameValue(uint pid, uint depth, StackValueKind kind, uint index)
        {
            WireProtocol.OutgoingMessage cmd = CreateMessage_GetValue_Stack(pid, depth, kind, index);

            WireProtocol.IncomingMessage reply = SyncRequest(cmd, 10, 100);
            if (reply != null)
            {
                WireProtocol.Commands.Debugging_Value_Reply cmdReply = reply.Payload as WireProtocol.Commands.Debugging_Value_Reply;

                return RuntimeValue.Convert(this, cmdReply.m_values);
            }

            return null;
        }
Esempio n. 31
0
        /// <summary>
        /// Push a new temporary local of kind <paramref name="kind"/> and type <paramref name="type"/> and generate its declaration.
        /// </summary>
        /// <param name="kind">Kind of entry in stack</param>
        /// <param name="type">Type if any for new entry in stack</param>
        private void PushTemp(StackValueKind kind, TypeDesc type = null)
        {
            Debug.Assert(kind != StackValueKind.Unknown, "Unknown stack kind");

            PushTemp(new ExpressionEntry(kind, NewTempName(), type));
        }
Esempio n. 32
0
 protected ConstantEntry(StackValueKind kind, int?exactSize) : base(kind, exactSize)
 {
 }
        private WireProtocol.OutgoingMessage CreateMessage_GetValue_Stack(uint pid, uint depth, StackValueKind kind, uint index)
        {
            WireProtocol.Commands.Debugging_Value_GetStack cmd = new WireProtocol.Commands.Debugging_Value_GetStack();

            cmd.m_pid = pid;
            cmd.m_depth = depth;
            cmd.m_kind = (uint)kind;
            cmd.m_index = index;

            return CreateMessage(WireProtocol.Commands.c_Debugging_Value_GetStack, 0, cmd);
        }
Esempio n. 34
0
 /// <summary>
 /// Initializes a new instance of StackEntry.
 /// </summary>
 /// <param name="kind">Kind of entry.</param>
 /// <param name="type">Type if any of entry.</param>
 protected StackEntry(StackValueKind kind, LLVMValueRef llvmValue, TypeDesc type = null)
 {
     Kind      = kind;
     Type      = type;
     LLVMValue = llvmValue;
 }
        public RuntimeValue[] GetStackFrameValueAll(uint pid, uint depth, uint cValues, StackValueKind kind)
        {
            WireProtocol.OutgoingMessage[] cmds = new WireProtocol.OutgoingMessage[cValues];
            RuntimeValue[] vals = null;
            uint i;

            for (i = 0; i < cValues; i++)
            {
                cmds[i] = CreateMessage_GetValue_Stack(pid, depth, kind, i);
            }

            WireProtocol.IncomingMessage[] replies = SyncMessages(cmds);
            if (replies != null)
            {
                vals = new RuntimeValue[cValues];

                for (i = 0; i < cValues; i++)
                {
                    WireProtocol.Commands.Debugging_Value_Reply reply = replies[i].Payload as WireProtocol.Commands.Debugging_Value_Reply;
                    if (reply != null)
                    {
                        vals[i] = RuntimeValue.Convert(this, reply.m_values);
                    }
                }
            }

            return vals;
        }
Esempio n. 36
0
 /// <summary>
 /// Initializes a new instance of StackEntry.
 /// </summary>
 /// <param name="kind">Kind of entry.</param>
 /// <param name="type">Type if any of entry.</param>
 protected StackEntry(StackValueKind kind, TypeDesc type = null)
 {
     Kind = kind;
     Type = type;
 }
Esempio n. 37
0
 /// <summary>
 /// Initializes new instance of ExpressionEntry
 /// </summary>
 /// <param name="kind">Kind of entry</param>
 /// <param name="name">String representation of entry</param>
 /// <param name="type">Type if any of entry</param>
 public ExpressionEntry(StackValueKind kind, string name, LLVMValueRef llvmValue, TypeDesc type = null) : base(kind, type)
 {
     Name         = name;
     RawLLVMValue = llvmValue;
 }
Esempio n. 38
0
 protected StackEntry(StackValueKind kind, int?exactSize = null)
 {
     Kind      = kind;
     ExactSize = exactSize;
     TreeID    = _treeID++;
 }
Esempio n. 39
0
 protected ConstantEntry(StackValueKind kind, TypeDesc type = null) : base(kind, type)
 {
 }
Esempio n. 40
0
 public LdFtnTokenEntry(StackValueKind kind, string name, MethodDesc token, bool isVirtual, TypeDesc type = null) : base(kind, name, token, type)
 {
     IsVirtual = isVirtual;
 }
Esempio n. 41
0
 /// <summary>
 /// Initializes new instance of ExpressionEntry
 /// </summary>
 /// <param name="kind">Kind of entry</param>
 /// <param name="name">String representation of entry</param>
 /// <param name="type">Type if any of entry</param>
 public AddressExpressionEntry(StackValueKind kind, string name, LLVMValueRef llvmValue, TypeDesc type = null) : base(kind, name, llvmValue, type)
 {
 }
Esempio n. 42
0
 /// <summary>
 /// Initializes new instance of ExpressionEntry
 /// </summary>
 /// <param name="kind">Kind of entry</param>
 /// <param name="name">String representation of entry</param>
 /// <param name="type">Type if any of entry</param>
 public ExpressionEntry(StackValueKind kind, string name, TypeDesc type = null) : base(kind, type)
 {
     Name = name;
 }
Esempio n. 43
0
 public SpilledExpressionEntry(StackValueKind kind, string name, TypeDesc type, int localIndex, ILImporter importer) : base(kind, name, new LLVMValueRef(IntPtr.Zero), type)
 {
     LocalIndex = localIndex;
     _importer  = importer;
 }
 public InvalidStackValueTypeException(StackValueKind expected, StackValueKind got) : base($"The parameter type is invalid. Expected: {expected}. Got: {got}.")
 {
 }