Ejemplo n.º 1
0
        internal DirectCommand(int globals, ReplyParser <TReply> replyParser, BytecodeObject obj)
        {
            if (globals < 0 || globals > maxGlobals)
            {
                throw new ArgumentOutOfRangeException($"Cannot be < 0 or exceed {maxGlobals}", nameof(globals));
            }

            if (obj == null)
            {
                throw new ArgumentNullException(nameof(obj));
            }

            if (obj.Type != BytecodeObjectType.VMThread)
            {
                throw new ArgumentOutOfRangeException("Only vmthread objects are supported", nameof(obj));
            }

            // TODO: could do a check here to see if we exceed maxBytecodes instead of waiting until ToBytes() is called.

            if (obj.Locals > maxLocals)
            {
                throw new ArgumentOutOfRangeException("Exceeds max local size", nameof(obj));
            }

            this.globals     = globals;
            this.replyParser = replyParser ?? throw new ArgumentNullException(nameof(replyParser));
            this.obj         = obj;
        }
Ejemplo n.º 2
0
 internal LabelPlaceholder(BytecodeObject obj)
 {
     this.obj = obj ?? throw new ArgumentNullException(nameof(obj));
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Creates a copy of this command with the specified bytecode object.
 /// </summary>
 /// <param name="obj">The bytecode object.</param>
 /// <returns>A new direct command.</returns>
 /// <exception cref="ArgumentNullException">
 /// Thrown if <paramref name="obj"/> is <c>null</c>.
 /// </exception>
 /// <exception cref="ArgumentOutOfRangeException">
 /// Thrown if <paramref name="obj"/> is not a <see cref="BytecodeObjectType.VMThread"/>
 /// or the size of the local variables exceeds 1021 bytes.
 /// </exception>
 public DirectCommand <TReply> WithBytecodeObject(BytecodeObject obj)
 {
     return(new DirectCommand <TReply>(globals, replyParser, obj));
 }