public override int ReadArguments(ParseStream strm, LexicalScope scope) { int read = 0; Argument arg = new Argument(); if(strm.NextTokenCouldBeVariable()) { string vresult = null; if(strm.ReadVariableName(ref vresult)) { arg.Value.StringValue = vresult; arg.Value.Type = HVMType.Variable; read++; } } else { if(strm.Eof) { throw new ParseException("Argument to opcode: push", "Unexpected end of file"); } int val = int.MinValue; if(strm.ReadNumeric(ref val)) { arg.Value.Type = HVMType.Integer; arg.Value.IntegerValue = val; read++; } } if(read == 0) { if(strm.Eof) { throw new ParseException("Argument to opcode: push", "Unexpected end of file"); } throw new ParseException("Argument to opcode: push", "Unable to read valid data from stream"); } Arguments[0] = arg; return read; }
protected int ReadVariableNameAndIntegerOrVariableInt(ParseStream strm, LexicalScope scope) { int read = 0; Argument argName = new Argument(); Argument argIndex = new Argument(); if(strm.NextTokenCouldBeVariable()) { string vresult = null; if(strm.ReadVariableName(ref vresult)) { argName.Value.StringValue = vresult; argName.Value.Type = HVMType.Variable; read++; } } else { throw new OpCodeArgumentException(0, HVMType.Variable, this); } if(strm.NextTokenCouldBeVariable()) { string vresult = null; if(strm.ReadVariableName(ref vresult)) { argIndex.Value.StringValue = vresult; argIndex.Value.Type = HVMType.Variable; read++; } } else { if(strm.Eof) { throw new ParseException("Argument to opcode: stidx", "Unexpected end of file"); } int val = int.MinValue; if(strm.ReadNumeric(ref val)) { argIndex.Value.Type = HVMType.Integer; argIndex.Value.IntegerValue = val; read++; } } if(read != 2) { if(strm.Eof) { throw new ParseException("Argument to opcode: stidx", "Unexpected end of file"); } throw new ParseException("Argument to opcode: stidx", "Unable to read valid data from stream"); } Arguments[0] = argName; Arguments[1] = argIndex; return read; }