| OLD | NEW |
| (Empty) |
| 1 // Copyright (c) 2015, the Dartino project authors. Please see the AUTHORS file | |
| 2 // for details. All rights reserved. Use of this source code is governed by a | |
| 3 // BSD-style license that can be found in the LICENSE.md file. | |
| 4 | |
| 5 library fletchc.vm_commands; | |
| 6 | |
| 7 import 'dart:convert' show | |
| 8 UTF8; | |
| 9 | |
| 10 import 'dart:typed_data' show | |
| 11 Int32List, | |
| 12 Uint16List, | |
| 13 Uint8List; | |
| 14 | |
| 15 import 'bytecodes.dart' show | |
| 16 Bytecode, | |
| 17 MethodEnd; | |
| 18 | |
| 19 import 'src/shared_command_infrastructure.dart' show | |
| 20 CommandBuffer; | |
| 21 | |
| 22 abstract class VmCommand { | |
| 23 final VmCommandCode code; | |
| 24 | |
| 25 const VmCommand(this.code); | |
| 26 | |
| 27 factory VmCommand.fromBuffer(VmCommandCode code, Uint8List buffer) { | |
| 28 switch (code) { | |
| 29 case VmCommandCode.HandShakeResult: | |
| 30 bool success = CommandBuffer.readBoolFromBuffer(buffer, 0); | |
| 31 int versionLength = CommandBuffer.readInt32FromBuffer(buffer, 1); | |
| 32 String version = | |
| 33 CommandBuffer.readAsciiStringFromBuffer(buffer, 5, versionLength); | |
| 34 return new HandShakeResult(success, version); | |
| 35 case VmCommandCode.InstanceStructure: | |
| 36 int classId = CommandBuffer.readInt64FromBuffer(buffer, 0); | |
| 37 int fields = CommandBuffer.readInt32FromBuffer(buffer, 8); | |
| 38 return new InstanceStructure(classId, fields); | |
| 39 case VmCommandCode.Instance: | |
| 40 int classId = CommandBuffer.readInt64FromBuffer(buffer, 0); | |
| 41 return new Instance(classId); | |
| 42 case VmCommandCode.Class: | |
| 43 int classId = CommandBuffer.readInt64FromBuffer(buffer, 0); | |
| 44 return new ClassValue(classId); | |
| 45 case VmCommandCode.Integer: | |
| 46 int value = CommandBuffer.readInt64FromBuffer(buffer, 0); | |
| 47 return new Integer(value); | |
| 48 case VmCommandCode.Double: | |
| 49 return new Double(CommandBuffer.readDoubleFromBuffer(buffer, 0)); | |
| 50 case VmCommandCode.Boolean: | |
| 51 return new Boolean(CommandBuffer.readBoolFromBuffer(buffer, 0)); | |
| 52 case VmCommandCode.Null: | |
| 53 return const NullValue(); | |
| 54 case VmCommandCode.String: | |
| 55 return new StringValue( | |
| 56 CommandBuffer.readStringFromBuffer(buffer, 0, buffer.length)); | |
| 57 case VmCommandCode.StdoutData: | |
| 58 return new StdoutData(buffer); | |
| 59 case VmCommandCode.StderrData: | |
| 60 return new StderrData(buffer); | |
| 61 case VmCommandCode.ObjectId: | |
| 62 int id = CommandBuffer.readInt64FromBuffer(buffer, 0); | |
| 63 return new ObjectId(id); | |
| 64 case VmCommandCode.ProcessBacktrace: | |
| 65 int frames = CommandBuffer.readInt32FromBuffer(buffer, 0); | |
| 66 ProcessBacktrace backtrace = new ProcessBacktrace(frames); | |
| 67 for (int i = 0; i < frames; i++) { | |
| 68 int offset = i * 16 + 4; | |
| 69 int functionId = CommandBuffer.readInt64FromBuffer(buffer, offset); | |
| 70 int bytecodeIndex = | |
| 71 CommandBuffer.readInt64FromBuffer(buffer, offset + 8); | |
| 72 backtrace.functionIds[i] = functionId; | |
| 73 backtrace.bytecodeIndices[i] = bytecodeIndex; | |
| 74 } | |
| 75 return backtrace; | |
| 76 case VmCommandCode.ProcessBreakpoint: | |
| 77 int breakpointId = CommandBuffer.readInt32FromBuffer(buffer, 0); | |
| 78 int functionId = CommandBuffer.readInt64FromBuffer(buffer, 4); | |
| 79 int bytecodeIndex = CommandBuffer.readInt64FromBuffer(buffer, 12); | |
| 80 return new ProcessBreakpoint(breakpointId, functionId, bytecodeIndex); | |
| 81 case VmCommandCode.ProcessDeleteBreakpoint: | |
| 82 int id = CommandBuffer.readInt32FromBuffer(buffer, 0); | |
| 83 return new ProcessDeleteBreakpoint(id); | |
| 84 case VmCommandCode.ProcessSetBreakpoint: | |
| 85 int value = CommandBuffer.readInt32FromBuffer(buffer, 0); | |
| 86 return new ProcessSetBreakpoint(value); | |
| 87 case VmCommandCode.ProcessTerminated: | |
| 88 return const ProcessTerminated(); | |
| 89 case VmCommandCode.ProcessCompileTimeError: | |
| 90 return const ProcessCompileTimeError(); | |
| 91 case VmCommandCode.ProcessNumberOfStacks: | |
| 92 int value = CommandBuffer.readInt32FromBuffer(buffer, 0); | |
| 93 return new ProcessNumberOfStacks(value); | |
| 94 case VmCommandCode.ProcessGetProcessIdsResult: | |
| 95 int count = CommandBuffer.readInt32FromBuffer(buffer, 0); | |
| 96 List<int> ids = new List(count); | |
| 97 for (int i = 0; i < count; ++i) { | |
| 98 ids[i] = CommandBuffer.readInt32FromBuffer(buffer, (i + 1) * 4); | |
| 99 } | |
| 100 return new ProcessGetProcessIdsResult(ids); | |
| 101 case VmCommandCode.UncaughtException: | |
| 102 return const UncaughtException(); | |
| 103 case VmCommandCode.CommitChangesResult: | |
| 104 bool success = CommandBuffer.readBoolFromBuffer(buffer, 0); | |
| 105 String message = CommandBuffer.readAsciiStringFromBuffer( | |
| 106 buffer, 1, buffer.length - 1); | |
| 107 return new CommitChangesResult(success, message); | |
| 108 case VmCommandCode.WriteSnapshotResult: | |
| 109 if ((buffer.offsetInBytes % 4) != 0) { | |
| 110 buffer = new Uint8List.fromList(buffer); | |
| 111 } | |
| 112 | |
| 113 int offset = 0; | |
| 114 | |
| 115 int readInt() { | |
| 116 int number = CommandBuffer.readInt32FromBuffer(buffer, offset); | |
| 117 offset += 4; | |
| 118 return number; | |
| 119 } | |
| 120 | |
| 121 Int32List readArray(int length) { | |
| 122 Int32List classTable = new Int32List.view( | |
| 123 buffer.buffer, buffer.offsetInBytes + offset, length); | |
| 124 offset += 4 * length; | |
| 125 return classTable; | |
| 126 } | |
| 127 | |
| 128 int hashtag = readInt(); | |
| 129 | |
| 130 int classEntries = readInt(); | |
| 131 Int32List classTable = readArray(classEntries); | |
| 132 | |
| 133 int functionEntries = readInt(); | |
| 134 Int32List functionTable = readArray(functionEntries); | |
| 135 | |
| 136 return new WriteSnapshotResult(classTable, functionTable, hashtag); | |
| 137 default: | |
| 138 throw 'Unhandled command in VmCommand.fromBuffer: $code'; | |
| 139 } | |
| 140 } | |
| 141 | |
| 142 void addTo(Sink<List<int>> sink) { | |
| 143 internalAddTo(sink, new CommandBuffer<VmCommandCode>()); | |
| 144 } | |
| 145 | |
| 146 void internalAddTo( | |
| 147 Sink<List<int>> sink, CommandBuffer<VmCommandCode> buffer) { | |
| 148 buffer.sendOn(sink, code); | |
| 149 } | |
| 150 | |
| 151 /// Indicates the number of responses we expect after sending a [VmCommand]. | |
| 152 /// If the number is unknown (e.g. one response determines whether more will | |
| 153 /// come) this will be `null`. | |
| 154 /// | |
| 155 /// Some of the [VmCommand]s will instruct the fletch-vm to continue running | |
| 156 /// the program. The response [VmCommand] can be one of | |
| 157 /// * ProcessBreakpoint | |
| 158 /// * ProcessTerminated | |
| 159 /// * ProcessCompileTimeError | |
| 160 /// * UncaughtException | |
| 161 int get numberOfResponsesExpected => null; | |
| 162 | |
| 163 String valuesToString(); | |
| 164 | |
| 165 String toString() => "$code(${valuesToString()})"; | |
| 166 } | |
| 167 | |
| 168 class HandShake extends VmCommand { | |
| 169 final String value; | |
| 170 | |
| 171 const HandShake(this.value) | |
| 172 : super(VmCommandCode.HandShake); | |
| 173 | |
| 174 void internalAddTo( | |
| 175 Sink<List<int>> sink, CommandBuffer<VmCommandCode> buffer) { | |
| 176 List<int> payload = UTF8.encode(value); | |
| 177 buffer | |
| 178 ..addUint32(payload.length) | |
| 179 ..addUint8List(payload) | |
| 180 ..sendOn(sink, code); | |
| 181 } | |
| 182 | |
| 183 // Expects a HandShakeResult reply. | |
| 184 int get numberOfResponsesExpected => 1; | |
| 185 | |
| 186 String valuesToString() => "$value"; | |
| 187 } | |
| 188 | |
| 189 class HandShakeResult extends VmCommand { | |
| 190 final bool success; | |
| 191 final String version; | |
| 192 | |
| 193 const HandShakeResult(this.success, this.version) | |
| 194 : super(VmCommandCode.HandShakeResult); | |
| 195 | |
| 196 void internalAddTo( | |
| 197 Sink<List<int>> sink, CommandBuffer<VmCommandCode> buffer) { | |
| 198 List<int> payload = UTF8.encode(version); | |
| 199 buffer | |
| 200 ..addUint8(success ? 1 : 0) | |
| 201 ..addUint32(payload.length) | |
| 202 ..addUint8List(payload) | |
| 203 ..sendOn(sink, code); | |
| 204 } | |
| 205 | |
| 206 int get numberOfResponsesExpected => 0; | |
| 207 | |
| 208 String valuesToString() => "$success, $version"; | |
| 209 } | |
| 210 | |
| 211 class Dup extends VmCommand { | |
| 212 const Dup() | |
| 213 : super(VmCommandCode.Dup); | |
| 214 | |
| 215 int get numberOfResponsesExpected => 0; | |
| 216 | |
| 217 String valuesToString() => ""; | |
| 218 } | |
| 219 | |
| 220 class PushNewOneByteString extends VmCommand { | |
| 221 final Uint8List value; | |
| 222 | |
| 223 const PushNewOneByteString(this.value) | |
| 224 : super(VmCommandCode.PushNewOneByteString); | |
| 225 | |
| 226 void internalAddTo( | |
| 227 Sink<List<int>> sink, CommandBuffer<VmCommandCode> buffer) { | |
| 228 List<int> payload = value; | |
| 229 buffer | |
| 230 ..addUint32(payload.length) | |
| 231 ..addUint8List(payload) | |
| 232 ..sendOn(sink, code); | |
| 233 } | |
| 234 | |
| 235 int get numberOfResponsesExpected => 0; | |
| 236 | |
| 237 String valuesToString() => "'${new String.fromCharCodes(value)}'"; | |
| 238 } | |
| 239 | |
| 240 class PushNewTwoByteString extends VmCommand { | |
| 241 final Uint16List value; | |
| 242 | |
| 243 const PushNewTwoByteString(this.value) | |
| 244 : super(VmCommandCode.PushNewTwoByteString); | |
| 245 | |
| 246 void internalAddTo( | |
| 247 Sink<List<int>> sink, CommandBuffer<VmCommandCode> buffer) { | |
| 248 List<int> payload = value.buffer.asUint8List(); | |
| 249 buffer | |
| 250 ..addUint32(payload.length) | |
| 251 ..addUint8List(payload) | |
| 252 ..sendOn(sink, code); | |
| 253 } | |
| 254 | |
| 255 int get numberOfResponsesExpected => 0; | |
| 256 | |
| 257 String valuesToString() => "'${new String.fromCharCodes(value)}'"; | |
| 258 } | |
| 259 | |
| 260 class PushNewInstance extends VmCommand { | |
| 261 const PushNewInstance() | |
| 262 : super(VmCommandCode.PushNewInstance); | |
| 263 | |
| 264 int get numberOfResponsesExpected => 0; | |
| 265 | |
| 266 String valuesToString() => ""; | |
| 267 } | |
| 268 | |
| 269 class PushNewClass extends VmCommand { | |
| 270 final int fields; | |
| 271 | |
| 272 const PushNewClass(this.fields) | |
| 273 : super(VmCommandCode.PushNewClass); | |
| 274 | |
| 275 void internalAddTo( | |
| 276 Sink<List<int>> sink, CommandBuffer<VmCommandCode> buffer) { | |
| 277 buffer | |
| 278 ..addUint32(fields) | |
| 279 ..sendOn(sink, code); | |
| 280 } | |
| 281 | |
| 282 int get numberOfResponsesExpected => 0; | |
| 283 | |
| 284 String valuesToString() => "$fields"; | |
| 285 } | |
| 286 | |
| 287 class PushBuiltinClass extends VmCommand { | |
| 288 final int name; | |
| 289 final int fields; | |
| 290 | |
| 291 const PushBuiltinClass(this.name, this.fields) | |
| 292 : super(VmCommandCode.PushBuiltinClass); | |
| 293 | |
| 294 void internalAddTo( | |
| 295 Sink<List<int>> sink, CommandBuffer<VmCommandCode> buffer) { | |
| 296 buffer | |
| 297 ..addUint32(name) | |
| 298 ..addUint32(fields) | |
| 299 ..sendOn(sink, code); | |
| 300 } | |
| 301 | |
| 302 int get numberOfResponsesExpected => 0; | |
| 303 | |
| 304 String valuesToString() => "$name, $fields"; | |
| 305 } | |
| 306 | |
| 307 class PushConstantList extends VmCommand { | |
| 308 final int entries; | |
| 309 | |
| 310 const PushConstantList(this.entries) | |
| 311 : super(VmCommandCode.PushConstantList); | |
| 312 | |
| 313 void internalAddTo( | |
| 314 Sink<List<int>> sink, CommandBuffer<VmCommandCode> buffer) { | |
| 315 buffer | |
| 316 ..addUint32(entries) | |
| 317 ..sendOn(sink, code); | |
| 318 } | |
| 319 | |
| 320 int get numberOfResponsesExpected => 0; | |
| 321 | |
| 322 String valuesToString() => "$entries"; | |
| 323 } | |
| 324 | |
| 325 class PushConstantByteList extends VmCommand { | |
| 326 final int entries; | |
| 327 | |
| 328 const PushConstantByteList(this.entries) | |
| 329 : super(VmCommandCode.PushConstantByteList); | |
| 330 | |
| 331 void internalAddTo( | |
| 332 Sink<List<int>> sink, CommandBuffer<VmCommandCode> buffer) { | |
| 333 buffer | |
| 334 ..addUint32(entries) | |
| 335 ..sendOn(sink, code); | |
| 336 } | |
| 337 | |
| 338 int get numberOfResponsesExpected => 0; | |
| 339 | |
| 340 String valuesToString() => "$entries"; | |
| 341 } | |
| 342 | |
| 343 class PushConstantMap extends VmCommand { | |
| 344 final int entries; | |
| 345 | |
| 346 const PushConstantMap(this.entries) | |
| 347 : super(VmCommandCode.PushConstantMap); | |
| 348 | |
| 349 void internalAddTo( | |
| 350 Sink<List<int>> sink, CommandBuffer<VmCommandCode> buffer) { | |
| 351 buffer | |
| 352 ..addUint32(entries) | |
| 353 ..sendOn(sink, code); | |
| 354 } | |
| 355 | |
| 356 int get numberOfResponsesExpected => 0; | |
| 357 | |
| 358 String valuesToString() => "$entries"; | |
| 359 } | |
| 360 | |
| 361 class Generic extends VmCommand { | |
| 362 final List<int> payload; | |
| 363 | |
| 364 const Generic(VmCommandCode code, this.payload) | |
| 365 : super(code); | |
| 366 | |
| 367 void internalAddTo( | |
| 368 Sink<List<int>> sink, CommandBuffer<VmCommandCode> buffer) { | |
| 369 buffer | |
| 370 ..addUint8List(payload) | |
| 371 ..sendOn(sink, code); | |
| 372 } | |
| 373 | |
| 374 // We do not know who many commands to expect as a response. | |
| 375 int get numberOfResponsesExpected => null; | |
| 376 | |
| 377 String valuesToString() => "$payload"; | |
| 378 | |
| 379 String toString() => "Generic($code, ${valuesToString()})"; | |
| 380 } | |
| 381 | |
| 382 class NewMap extends VmCommand { | |
| 383 final MapId map; | |
| 384 | |
| 385 const NewMap(this.map) | |
| 386 : super(VmCommandCode.NewMap); | |
| 387 | |
| 388 void internalAddTo( | |
| 389 Sink<List<int>> sink, CommandBuffer<VmCommandCode> buffer) { | |
| 390 buffer | |
| 391 ..addUint32(map.index) | |
| 392 ..sendOn(sink, code); | |
| 393 } | |
| 394 | |
| 395 int get numberOfResponsesExpected => 0; | |
| 396 | |
| 397 String valuesToString() => "$map"; | |
| 398 } | |
| 399 | |
| 400 class DeleteMap extends VmCommand { | |
| 401 final MapId map; | |
| 402 | |
| 403 const DeleteMap(this.map) | |
| 404 : super(VmCommandCode.DeleteMap); | |
| 405 | |
| 406 void internalAddTo( | |
| 407 Sink<List<int>> sink, CommandBuffer<VmCommandCode> buffer) { | |
| 408 buffer | |
| 409 ..addUint32(map.index) | |
| 410 ..sendOn(sink, code); | |
| 411 } | |
| 412 | |
| 413 int get numberOfResponsesExpected => 0; | |
| 414 | |
| 415 String valuesToString() => "$map"; | |
| 416 } | |
| 417 | |
| 418 abstract class MapAccess extends VmCommand { | |
| 419 final MapId map; | |
| 420 final int index; | |
| 421 | |
| 422 const MapAccess(this.map, this.index, VmCommandCode code) | |
| 423 : super(code); | |
| 424 | |
| 425 void internalAddTo( | |
| 426 Sink<List<int>> sink, CommandBuffer<VmCommandCode> buffer) { | |
| 427 buffer | |
| 428 ..addUint32(map.index) | |
| 429 ..addUint64(index) | |
| 430 ..sendOn(sink, code); | |
| 431 } | |
| 432 } | |
| 433 | |
| 434 class PopToMap extends MapAccess { | |
| 435 const PopToMap(MapId map, int index) | |
| 436 : super(map, index, VmCommandCode.PopToMap); | |
| 437 | |
| 438 int get numberOfResponsesExpected => 0; | |
| 439 | |
| 440 String valuesToString() => "$map, $index"; | |
| 441 } | |
| 442 | |
| 443 class PushFromMap extends MapAccess { | |
| 444 const PushFromMap(MapId map, int index) | |
| 445 : super(map, index, VmCommandCode.PushFromMap); | |
| 446 | |
| 447 int get numberOfResponsesExpected => 0; | |
| 448 | |
| 449 String valuesToString() => "$map, $index"; | |
| 450 } | |
| 451 | |
| 452 class RemoveFromMap extends MapAccess { | |
| 453 const RemoveFromMap(MapId map, int index) | |
| 454 : super(map, index, VmCommandCode.RemoveFromMap); | |
| 455 | |
| 456 int get numberOfResponsesExpected => 0; | |
| 457 | |
| 458 String valuesToString() => "$map, $index"; | |
| 459 } | |
| 460 | |
| 461 class Drop extends VmCommand { | |
| 462 final int value; | |
| 463 | |
| 464 const Drop(this.value) | |
| 465 : super(VmCommandCode.Drop); | |
| 466 | |
| 467 void internalAddTo( | |
| 468 Sink<List<int>> sink, CommandBuffer<VmCommandCode> buffer) { | |
| 469 buffer | |
| 470 ..addUint32(value) | |
| 471 ..sendOn(sink, code); | |
| 472 } | |
| 473 | |
| 474 int get numberOfResponsesExpected => 0; | |
| 475 | |
| 476 String valuesToString() => "$value"; | |
| 477 } | |
| 478 | |
| 479 class PushNull extends VmCommand { | |
| 480 const PushNull() | |
| 481 : super(VmCommandCode.PushNull); | |
| 482 | |
| 483 int get numberOfResponsesExpected => 0; | |
| 484 | |
| 485 String valuesToString() => ""; | |
| 486 } | |
| 487 | |
| 488 class PushBoolean extends VmCommand { | |
| 489 final bool value; | |
| 490 | |
| 491 const PushBoolean(this.value) | |
| 492 : super(VmCommandCode.PushBoolean); | |
| 493 | |
| 494 void internalAddTo( | |
| 495 Sink<List<int>> sink, CommandBuffer<VmCommandCode> buffer) { | |
| 496 buffer | |
| 497 ..addUint8(value ? 1 : 0) | |
| 498 ..sendOn(sink, code); | |
| 499 } | |
| 500 | |
| 501 int get numberOfResponsesExpected => 0; | |
| 502 | |
| 503 String valuesToString() => '$value'; | |
| 504 } | |
| 505 | |
| 506 class BytecodeSink implements Sink<List<int>> { | |
| 507 List<int> bytes = <int>[]; | |
| 508 | |
| 509 void add(List<int> data) { | |
| 510 bytes.addAll(data); | |
| 511 } | |
| 512 | |
| 513 void close() { | |
| 514 } | |
| 515 } | |
| 516 | |
| 517 class PushNewFunction extends VmCommand { | |
| 518 final int arity; | |
| 519 | |
| 520 final int literals; | |
| 521 | |
| 522 final List<Bytecode> bytecodes; | |
| 523 | |
| 524 final List<int> catchRanges; | |
| 525 | |
| 526 const PushNewFunction( | |
| 527 this.arity, | |
| 528 this.literals, | |
| 529 this.bytecodes, | |
| 530 this.catchRanges) | |
| 531 : super(VmCommandCode.PushNewFunction); | |
| 532 | |
| 533 List<int> computeBytes(List<Bytecode> bytecodes) { | |
| 534 BytecodeSink sink = new BytecodeSink(); | |
| 535 for (Bytecode bytecode in bytecodes) { | |
| 536 bytecode.addTo(sink); | |
| 537 } | |
| 538 return sink.bytes; | |
| 539 } | |
| 540 | |
| 541 void internalAddTo( | |
| 542 Sink<List<int>> sink, CommandBuffer<VmCommandCode> buffer) { | |
| 543 List<int> bytes = computeBytes(bytecodes); | |
| 544 int size = bytes.length; | |
| 545 if (catchRanges.isNotEmpty) size += 4 + catchRanges.length * 4; | |
| 546 buffer | |
| 547 ..addUint32(arity) | |
| 548 ..addUint32(literals) | |
| 549 ..addUint32(size) | |
| 550 ..addUint8List(bytes); | |
| 551 if (catchRanges.isNotEmpty) { | |
| 552 buffer.addUint32(catchRanges.length ~/ 3); | |
| 553 catchRanges.forEach(buffer.addUint32); | |
| 554 } | |
| 555 buffer.sendOn(sink, code); | |
| 556 } | |
| 557 | |
| 558 int get numberOfResponsesExpected => 0; | |
| 559 | |
| 560 String valuesToString() => "$arity, $literals, $bytecodes, $catchRanges"; | |
| 561 } | |
| 562 | |
| 563 class PushNewInitializer extends VmCommand { | |
| 564 const PushNewInitializer() | |
| 565 : super(VmCommandCode.PushNewInitializer); | |
| 566 | |
| 567 int get numberOfResponsesExpected => 0; | |
| 568 | |
| 569 String valuesToString() => ""; | |
| 570 } | |
| 571 | |
| 572 class ChangeStatics extends VmCommand { | |
| 573 final int count; | |
| 574 | |
| 575 const ChangeStatics(this.count) | |
| 576 : super(VmCommandCode.ChangeStatics); | |
| 577 | |
| 578 void internalAddTo( | |
| 579 Sink<List<int>> sink, CommandBuffer<VmCommandCode> buffer) { | |
| 580 buffer | |
| 581 ..addUint32(count) | |
| 582 ..sendOn(sink, code); | |
| 583 } | |
| 584 | |
| 585 int get numberOfResponsesExpected => 0; | |
| 586 | |
| 587 String valuesToString() => "$count"; | |
| 588 } | |
| 589 | |
| 590 class ChangeMethodLiteral extends VmCommand { | |
| 591 final int index; | |
| 592 | |
| 593 const ChangeMethodLiteral(this.index) | |
| 594 : super(VmCommandCode.ChangeMethodLiteral); | |
| 595 | |
| 596 void internalAddTo( | |
| 597 Sink<List<int>> sink, CommandBuffer<VmCommandCode> buffer) { | |
| 598 buffer | |
| 599 ..addUint32(index) | |
| 600 ..sendOn(sink, code); | |
| 601 } | |
| 602 | |
| 603 int get numberOfResponsesExpected => 0; | |
| 604 | |
| 605 String valuesToString() => "$index"; | |
| 606 } | |
| 607 | |
| 608 class ChangeMethodTable extends VmCommand { | |
| 609 final int count; | |
| 610 | |
| 611 const ChangeMethodTable(this.count) | |
| 612 : super(VmCommandCode.ChangeMethodTable); | |
| 613 | |
| 614 void internalAddTo( | |
| 615 Sink<List<int>> sink, CommandBuffer<VmCommandCode> buffer) { | |
| 616 buffer | |
| 617 ..addUint32(count) | |
| 618 ..sendOn(sink, code); | |
| 619 } | |
| 620 | |
| 621 int get numberOfResponsesExpected => 0; | |
| 622 | |
| 623 String valuesToString() => "$count"; | |
| 624 } | |
| 625 | |
| 626 class ChangeSuperClass extends VmCommand { | |
| 627 const ChangeSuperClass() | |
| 628 : super(VmCommandCode.ChangeSuperClass); | |
| 629 | |
| 630 int get numberOfResponsesExpected => 0; | |
| 631 | |
| 632 String valuesToString() => ""; | |
| 633 } | |
| 634 | |
| 635 class ChangeSchemas extends VmCommand { | |
| 636 final int count; | |
| 637 final int delta; | |
| 638 | |
| 639 const ChangeSchemas(this.count, this.delta) | |
| 640 : super(VmCommandCode.ChangeSchemas); | |
| 641 | |
| 642 void internalAddTo( | |
| 643 Sink<List<int>> sink, CommandBuffer<VmCommandCode> buffer) { | |
| 644 buffer | |
| 645 ..addUint32(count) | |
| 646 ..addUint32(delta) | |
| 647 ..sendOn(sink, code); | |
| 648 } | |
| 649 | |
| 650 int get numberOfResponsesExpected => 0; | |
| 651 | |
| 652 String valuesToString() => '$count, $delta'; | |
| 653 } | |
| 654 | |
| 655 class PrepareForChanges extends VmCommand { | |
| 656 const PrepareForChanges() | |
| 657 : super(VmCommandCode.PrepareForChanges); | |
| 658 | |
| 659 int get numberOfResponsesExpected => 0; | |
| 660 | |
| 661 String valuesToString() => ""; | |
| 662 } | |
| 663 | |
| 664 class CommitChanges extends VmCommand { | |
| 665 final int count; | |
| 666 | |
| 667 const CommitChanges(this.count) | |
| 668 : super(VmCommandCode.CommitChanges); | |
| 669 | |
| 670 void internalAddTo( | |
| 671 Sink<List<int>> sink, CommandBuffer<VmCommandCode> buffer) { | |
| 672 buffer | |
| 673 ..addUint32(count) | |
| 674 ..sendOn(sink, code); | |
| 675 } | |
| 676 | |
| 677 /// Peer will respond with [CommitChangesResult]. | |
| 678 int get numberOfResponsesExpected => 1; | |
| 679 | |
| 680 String valuesToString() => '$count'; | |
| 681 } | |
| 682 | |
| 683 class CommitChangesResult extends VmCommand { | |
| 684 final bool successful; | |
| 685 final String message; | |
| 686 | |
| 687 const CommitChangesResult(this.successful, this.message) | |
| 688 : super(VmCommandCode.CommitChangesResult); | |
| 689 | |
| 690 void internalAddTo( | |
| 691 Sink<List<int>> sink, CommandBuffer<VmCommandCode> buffer) { | |
| 692 buffer | |
| 693 ..addBool(successful) | |
| 694 ..addAsciiString(message) | |
| 695 ..sendOn(sink, code); | |
| 696 } | |
| 697 | |
| 698 int get numberOfResponsesExpected => 0; | |
| 699 | |
| 700 String valuesToString() => 'success: $successful, message: $message'; | |
| 701 } | |
| 702 | |
| 703 class UncaughtException extends VmCommand { | |
| 704 const UncaughtException() | |
| 705 : super(VmCommandCode.UncaughtException); | |
| 706 | |
| 707 int get numberOfResponsesExpected => 0; | |
| 708 | |
| 709 String valuesToString() => ""; | |
| 710 } | |
| 711 | |
| 712 class MapLookup extends VmCommand { | |
| 713 final MapId mapId; | |
| 714 | |
| 715 const MapLookup(this.mapId) | |
| 716 : super(VmCommandCode.MapLookup); | |
| 717 | |
| 718 void internalAddTo( | |
| 719 Sink<List<int>> sink, CommandBuffer<VmCommandCode> buffer) { | |
| 720 buffer | |
| 721 ..addUint32(mapId.index) | |
| 722 ..sendOn(sink, code); | |
| 723 } | |
| 724 | |
| 725 /// Peer will respond with [ObjectId]. | |
| 726 int get numberOfResponsesExpected => 1; | |
| 727 | |
| 728 String valuesToString() => "$mapId"; | |
| 729 } | |
| 730 | |
| 731 class ObjectId extends VmCommand { | |
| 732 final int id; | |
| 733 | |
| 734 const ObjectId(this.id) | |
| 735 : super(VmCommandCode.ObjectId); | |
| 736 | |
| 737 void internalAddTo( | |
| 738 Sink<List<int>> sink, CommandBuffer<VmCommandCode> buffer) { | |
| 739 buffer | |
| 740 ..addUint64(id) | |
| 741 ..sendOn(sink, code); | |
| 742 } | |
| 743 | |
| 744 int get numberOfResponsesExpected => 0; | |
| 745 | |
| 746 String valuesToString() => "$id"; | |
| 747 } | |
| 748 | |
| 749 class PushNewArray extends VmCommand { | |
| 750 final int length; | |
| 751 | |
| 752 const PushNewArray(this.length) | |
| 753 : super(VmCommandCode.PushNewArray); | |
| 754 | |
| 755 void internalAddTo( | |
| 756 Sink<List<int>> sink, CommandBuffer<VmCommandCode> buffer) { | |
| 757 buffer | |
| 758 ..addUint32(length) | |
| 759 ..sendOn(sink, code); | |
| 760 } | |
| 761 | |
| 762 int get numberOfResponsesExpected => 0; | |
| 763 | |
| 764 String valuesToString() => '$length'; | |
| 765 } | |
| 766 | |
| 767 class PushNewInteger extends VmCommand { | |
| 768 final int value; | |
| 769 | |
| 770 const PushNewInteger(this.value) | |
| 771 : super(VmCommandCode.PushNewInteger); | |
| 772 | |
| 773 void internalAddTo( | |
| 774 Sink<List<int>> sink, CommandBuffer<VmCommandCode> buffer) { | |
| 775 buffer | |
| 776 ..addUint64(value) | |
| 777 ..sendOn(sink, code); | |
| 778 } | |
| 779 | |
| 780 int get numberOfResponsesExpected => 0; | |
| 781 | |
| 782 String valuesToString() => "$value"; | |
| 783 } | |
| 784 | |
| 785 class PushNewBigInteger extends VmCommand { | |
| 786 final bool negative; | |
| 787 final List<int> parts; | |
| 788 final MapId classMap; | |
| 789 final int bigintClassId; | |
| 790 final int uint32DigitsClassId; | |
| 791 | |
| 792 const PushNewBigInteger(this.negative, | |
| 793 this.parts, | |
| 794 this.classMap, | |
| 795 this.bigintClassId, | |
| 796 this.uint32DigitsClassId) | |
| 797 : super(VmCommandCode.PushNewBigInteger); | |
| 798 | |
| 799 void internalAddTo( | |
| 800 Sink<List<int>> sink, CommandBuffer<VmCommandCode> buffer) { | |
| 801 buffer | |
| 802 ..addUint8(negative ? 1 : 0) | |
| 803 ..addUint32(parts.length) | |
| 804 ..addUint32(classMap.index) | |
| 805 ..addUint64(bigintClassId) | |
| 806 ..addUint64(uint32DigitsClassId); | |
| 807 parts.forEach((part) => buffer.addUint32(part)); | |
| 808 buffer.sendOn(sink, code); | |
| 809 } | |
| 810 | |
| 811 int get numberOfResponsesExpected => 0; | |
| 812 | |
| 813 String valuesToString() { | |
| 814 return "$negative, $parts, $classMap, $bigintClassId, $uint32DigitsClassId"; | |
| 815 } | |
| 816 } | |
| 817 | |
| 818 class PushNewDouble extends VmCommand { | |
| 819 final double value; | |
| 820 | |
| 821 const PushNewDouble(this.value) | |
| 822 : super(VmCommandCode.PushNewDouble); | |
| 823 | |
| 824 void internalAddTo( | |
| 825 Sink<List<int>> sink, CommandBuffer<VmCommandCode> buffer) { | |
| 826 buffer | |
| 827 ..addDouble(value) | |
| 828 ..sendOn(sink, code); | |
| 829 } | |
| 830 | |
| 831 int get numberOfResponsesExpected => 0; | |
| 832 | |
| 833 String valuesToString() => "$value"; | |
| 834 } | |
| 835 | |
| 836 class ProcessSpawnForMain extends VmCommand { | |
| 837 const ProcessSpawnForMain() | |
| 838 : super(VmCommandCode.ProcessSpawnForMain); | |
| 839 | |
| 840 int get numberOfResponsesExpected => 0; | |
| 841 | |
| 842 String valuesToString() => ""; | |
| 843 } | |
| 844 | |
| 845 class ProcessDebugInterrupt extends VmCommand { | |
| 846 const ProcessDebugInterrupt() | |
| 847 : super(VmCommandCode.ProcessDebugInterrupt); | |
| 848 | |
| 849 int get numberOfResponsesExpected => 0; | |
| 850 | |
| 851 String valuesToString() => ""; | |
| 852 } | |
| 853 | |
| 854 class ProcessRun extends VmCommand { | |
| 855 const ProcessRun() | |
| 856 : super(VmCommandCode.ProcessRun); | |
| 857 | |
| 858 /// It depends whether the connection is a "debugging session" or a | |
| 859 /// "normal session". For a normal session, we do not expect to get any | |
| 860 /// response, but for a debugging session we expect this to result in any of | |
| 861 /// the responses noted further up at [Command.numberOfResponsesExpected]. | |
| 862 int get numberOfResponsesExpected => null; | |
| 863 | |
| 864 String valuesToString() => ""; | |
| 865 } | |
| 866 | |
| 867 class ProcessSetBreakpoint extends VmCommand { | |
| 868 final int value; | |
| 869 | |
| 870 const ProcessSetBreakpoint(this.value) | |
| 871 : super(VmCommandCode.ProcessSetBreakpoint); | |
| 872 | |
| 873 void internalAddTo( | |
| 874 Sink<List<int>> sink, CommandBuffer<VmCommandCode> buffer) { | |
| 875 buffer | |
| 876 ..addUint32(value) | |
| 877 ..sendOn(sink, code); | |
| 878 } | |
| 879 | |
| 880 /// Peer will respond with [ProcessSetBreakpoint] | |
| 881 int get numberOfResponsesExpected => 1; | |
| 882 | |
| 883 String valuesToString() => "$value"; | |
| 884 } | |
| 885 | |
| 886 class ProcessDeleteBreakpoint extends VmCommand { | |
| 887 final int id; | |
| 888 | |
| 889 const ProcessDeleteBreakpoint(this.id) | |
| 890 : super(VmCommandCode.ProcessDeleteBreakpoint); | |
| 891 | |
| 892 void internalAddTo( | |
| 893 Sink<List<int>> sink, CommandBuffer<VmCommandCode> buffer) { | |
| 894 buffer | |
| 895 ..addUint32(id) | |
| 896 ..sendOn(sink, code); | |
| 897 } | |
| 898 | |
| 899 /// Peer will respond with [ProcessDeleteBreakpoint] | |
| 900 int get numberOfResponsesExpected => 1; | |
| 901 | |
| 902 String valuesToString() => "$id"; | |
| 903 } | |
| 904 | |
| 905 class ProcessBacktrace extends VmCommand { | |
| 906 final int frames; | |
| 907 final List<int> functionIds; | |
| 908 final List<int> bytecodeIndices; | |
| 909 | |
| 910 ProcessBacktrace(int frameCount) | |
| 911 : frames = frameCount, | |
| 912 functionIds = new List<int>(frameCount), | |
| 913 bytecodeIndices = new List<int>(frameCount), | |
| 914 super(VmCommandCode.ProcessBacktrace); | |
| 915 | |
| 916 void internalAddTo( | |
| 917 Sink<List<int>> sink, CommandBuffer<VmCommandCode> buffer) { | |
| 918 throw new UnimplementedError(); | |
| 919 } | |
| 920 | |
| 921 int get numberOfResponsesExpected => 0; | |
| 922 | |
| 923 String valuesToString() => "$frames, $functionIds, $bytecodeIndices"; | |
| 924 } | |
| 925 | |
| 926 class ProcessBacktraceRequest extends VmCommand { | |
| 927 final int processId; | |
| 928 | |
| 929 // TODO(zerny): Make the process id non-optional and non-negative. | |
| 930 const ProcessBacktraceRequest([this.processId = -1]) | |
| 931 : super(VmCommandCode.ProcessBacktraceRequest); | |
| 932 | |
| 933 void internalAddTo( | |
| 934 Sink<List<int>> sink, CommandBuffer<VmCommandCode> buffer) { | |
| 935 buffer | |
| 936 ..addUint32(processId + 1) | |
| 937 ..sendOn(sink, code); | |
| 938 } | |
| 939 /// Peer will respond with [ProcessBacktrace] | |
| 940 int get numberOfResponsesExpected => 1; | |
| 941 | |
| 942 String valuesToString() => "$processId"; | |
| 943 } | |
| 944 | |
| 945 class ProcessFiberBacktraceRequest extends VmCommand { | |
| 946 final int fiber; | |
| 947 | |
| 948 const ProcessFiberBacktraceRequest(this.fiber) | |
| 949 : super(VmCommandCode.ProcessFiberBacktraceRequest); | |
| 950 | |
| 951 void internalAddTo( | |
| 952 Sink<List<int>> sink, CommandBuffer<VmCommandCode> buffer) { | |
| 953 buffer | |
| 954 ..addUint64(fiber) | |
| 955 ..sendOn(sink, code); | |
| 956 } | |
| 957 | |
| 958 /// Peer will respond with [ProcessBacktrace] | |
| 959 int get numberOfResponsesExpected => 1; | |
| 960 | |
| 961 String valuesToString() => "$fiber"; | |
| 962 } | |
| 963 | |
| 964 class ProcessUncaughtExceptionRequest extends VmCommand { | |
| 965 const ProcessUncaughtExceptionRequest() | |
| 966 : super(VmCommandCode.ProcessUncaughtExceptionRequest); | |
| 967 | |
| 968 /// Peer will respond with a [DartValue] or [InstanceStructure] and a number | |
| 969 /// of [DartValue]s. | |
| 970 /// | |
| 971 /// The number of responses is not fixed. | |
| 972 int get numberOfResponsesExpected => null; | |
| 973 | |
| 974 String valuesToString() => ''; | |
| 975 } | |
| 976 | |
| 977 class ProcessBreakpoint extends VmCommand { | |
| 978 final int breakpointId; | |
| 979 final int functionId; | |
| 980 final int bytecodeIndex; | |
| 981 | |
| 982 const ProcessBreakpoint( | |
| 983 this.breakpointId, this.functionId, this.bytecodeIndex) | |
| 984 : super(VmCommandCode.ProcessBreakpoint); | |
| 985 | |
| 986 void internalAddTo( | |
| 987 Sink<List<int>> sink, CommandBuffer<VmCommandCode> buffer) { | |
| 988 throw new UnimplementedError(); | |
| 989 } | |
| 990 | |
| 991 int get numberOfResponsesExpected => 0; | |
| 992 | |
| 993 String valuesToString() => "$breakpointId, $functionId, $bytecodeIndex"; | |
| 994 } | |
| 995 | |
| 996 class ProcessLocal extends VmCommand { | |
| 997 final int frame; | |
| 998 final int slot; | |
| 999 | |
| 1000 const ProcessLocal(this.frame, this.slot) | |
| 1001 : super(VmCommandCode.ProcessLocal); | |
| 1002 | |
| 1003 void internalAddTo( | |
| 1004 Sink<List<int>> sink, CommandBuffer<VmCommandCode> buffer) { | |
| 1005 buffer | |
| 1006 ..addUint32(frame) | |
| 1007 ..addUint32(slot) | |
| 1008 ..sendOn(sink, code); | |
| 1009 } | |
| 1010 | |
| 1011 /// Peer will respond with a [DartValue]. | |
| 1012 int get numberOfResponsesExpected => 1; | |
| 1013 | |
| 1014 String valuesToString() => "$frame, $slot"; | |
| 1015 } | |
| 1016 | |
| 1017 class ProcessLocalStructure extends VmCommand { | |
| 1018 final int frame; | |
| 1019 final int slot; | |
| 1020 | |
| 1021 const ProcessLocalStructure(this.frame, this.slot) | |
| 1022 : super(VmCommandCode.ProcessLocalStructure); | |
| 1023 | |
| 1024 void internalAddTo( | |
| 1025 Sink<List<int>> sink, CommandBuffer<VmCommandCode> buffer) { | |
| 1026 buffer | |
| 1027 ..addUint32(frame) | |
| 1028 ..addUint32(slot) | |
| 1029 ..sendOn(sink, code); | |
| 1030 } | |
| 1031 | |
| 1032 /// Peer will respond with a [DartValue] or [InstanceStructure] and a number | |
| 1033 /// of [DartValue]s. | |
| 1034 /// | |
| 1035 /// The number of responses is not fixed. | |
| 1036 int get numberOfResponsesExpected => null; | |
| 1037 | |
| 1038 String valuesToString() => "$frame, $slot"; | |
| 1039 } | |
| 1040 | |
| 1041 class ProcessRestartFrame extends VmCommand { | |
| 1042 final int frame; | |
| 1043 | |
| 1044 const ProcessRestartFrame(this.frame) | |
| 1045 : super(VmCommandCode.ProcessRestartFrame); | |
| 1046 | |
| 1047 void internalAddTo( | |
| 1048 Sink<List<int>> sink, CommandBuffer<VmCommandCode> buffer) { | |
| 1049 buffer | |
| 1050 ..addUint32(frame) | |
| 1051 ..sendOn(sink, code); | |
| 1052 } | |
| 1053 | |
| 1054 /// Peer will continue program -- see [Command.numberOfResponsesExpected] for | |
| 1055 /// possible responses. | |
| 1056 int get numberOfResponsesExpected => 1; | |
| 1057 | |
| 1058 String valuesToString() => "$frame"; | |
| 1059 } | |
| 1060 | |
| 1061 class ProcessStep extends VmCommand { | |
| 1062 const ProcessStep() | |
| 1063 : super(VmCommandCode.ProcessStep); | |
| 1064 | |
| 1065 /// Peer will continue program -- see [Command.numberOfResponsesExpected] for | |
| 1066 /// possible responses. | |
| 1067 int get numberOfResponsesExpected => 1; | |
| 1068 | |
| 1069 String valuesToString() => ""; | |
| 1070 } | |
| 1071 | |
| 1072 class ProcessStepOver extends VmCommand { | |
| 1073 const ProcessStepOver() | |
| 1074 : super(VmCommandCode.ProcessStepOver); | |
| 1075 | |
| 1076 /// Peer will respond with a [ProcessSetBreakpoint] response and continues | |
| 1077 /// the program -- see [Command.numberOfResponsesExpected] for possible | |
| 1078 /// responses. | |
| 1079 int get numberOfResponsesExpected => 2; | |
| 1080 | |
| 1081 String valuesToString() => ""; | |
| 1082 } | |
| 1083 | |
| 1084 class ProcessStepOut extends VmCommand { | |
| 1085 const ProcessStepOut() | |
| 1086 : super(VmCommandCode.ProcessStepOut); | |
| 1087 | |
| 1088 /// Peer will respond with a [ProcessSetBreakpoint] response and continues | |
| 1089 /// the program -- see [Command.numberOfResponsesExpected] for possible | |
| 1090 /// responses. | |
| 1091 int get numberOfResponsesExpected => 2; | |
| 1092 | |
| 1093 String valuesToString() => ""; | |
| 1094 } | |
| 1095 | |
| 1096 class ProcessStepTo extends VmCommand { | |
| 1097 final int functionId; | |
| 1098 final int bcp; | |
| 1099 | |
| 1100 const ProcessStepTo(this.functionId, this.bcp) | |
| 1101 : super(VmCommandCode.ProcessStepTo); | |
| 1102 | |
| 1103 void internalAddTo( | |
| 1104 Sink<List<int>> sink, CommandBuffer<VmCommandCode> buffer) { | |
| 1105 buffer | |
| 1106 ..addUint64(functionId) | |
| 1107 ..addUint32(bcp) | |
| 1108 ..sendOn(sink, code); | |
| 1109 } | |
| 1110 | |
| 1111 /// Peer will continue program -- see [Command.numberOfResponsesExpected] for | |
| 1112 /// possible responses. | |
| 1113 int get numberOfResponsesExpected => 1; | |
| 1114 | |
| 1115 String valuesToString() => "$functionId, $bcp"; | |
| 1116 } | |
| 1117 | |
| 1118 class ProcessContinue extends VmCommand { | |
| 1119 const ProcessContinue() | |
| 1120 : super(VmCommandCode.ProcessContinue); | |
| 1121 | |
| 1122 /// Peer will continue program -- see [Command.numberOfResponsesExpected] for | |
| 1123 /// possible responses. | |
| 1124 int get numberOfResponsesExpected => 1; | |
| 1125 | |
| 1126 String valuesToString() => ""; | |
| 1127 } | |
| 1128 | |
| 1129 class ProcessTerminated extends VmCommand { | |
| 1130 const ProcessTerminated() | |
| 1131 : super(VmCommandCode.ProcessTerminated); | |
| 1132 | |
| 1133 int get numberOfResponsesExpected => 0; | |
| 1134 | |
| 1135 String valuesToString() => ""; | |
| 1136 } | |
| 1137 | |
| 1138 class ProcessCompileTimeError extends VmCommand { | |
| 1139 const ProcessCompileTimeError() | |
| 1140 : super(VmCommandCode.ProcessCompileTimeError); | |
| 1141 | |
| 1142 int get numberOfResponsesExpected => 0; | |
| 1143 | |
| 1144 String valuesToString() => ""; | |
| 1145 } | |
| 1146 | |
| 1147 class ProcessAddFibersToMap extends VmCommand { | |
| 1148 const ProcessAddFibersToMap() | |
| 1149 : super(VmCommandCode.ProcessAddFibersToMap); | |
| 1150 | |
| 1151 /// The peer will respond with [ProcessNumberOfStacks]. | |
| 1152 int get numberOfResponsesExpected => 1; | |
| 1153 | |
| 1154 String valuesToString() => ""; | |
| 1155 } | |
| 1156 | |
| 1157 class ProcessNumberOfStacks extends VmCommand { | |
| 1158 final int value; | |
| 1159 | |
| 1160 const ProcessNumberOfStacks(this.value) | |
| 1161 : super(VmCommandCode.ProcessNumberOfStacks); | |
| 1162 | |
| 1163 int get numberOfResponsesExpected => 0; | |
| 1164 | |
| 1165 String valuesToString() => "$value"; | |
| 1166 } | |
| 1167 | |
| 1168 class ProcessGetProcessIds extends VmCommand { | |
| 1169 const ProcessGetProcessIds() | |
| 1170 : super(VmCommandCode.ProcessGetProcessIds); | |
| 1171 | |
| 1172 /// The peer will respond with [ProcessGetProcessIdsResult]. | |
| 1173 int get numberOfResponsesExpected => 1; | |
| 1174 | |
| 1175 String valuesToString() => ""; | |
| 1176 } | |
| 1177 | |
| 1178 class ProcessGetProcessIdsResult extends VmCommand { | |
| 1179 final List<int> ids; | |
| 1180 | |
| 1181 const ProcessGetProcessIdsResult(this.ids) | |
| 1182 : super(VmCommandCode.ProcessGetProcessIdsResult); | |
| 1183 | |
| 1184 int get numberOfResponsesExpected => 0; | |
| 1185 | |
| 1186 String valuesToString() => "$ids"; | |
| 1187 } | |
| 1188 | |
| 1189 class SessionEnd extends VmCommand { | |
| 1190 const SessionEnd() | |
| 1191 : super(VmCommandCode.SessionEnd); | |
| 1192 | |
| 1193 int get numberOfResponsesExpected => 0; | |
| 1194 | |
| 1195 String valuesToString() => ""; | |
| 1196 } | |
| 1197 | |
| 1198 class Debugging extends VmCommand { | |
| 1199 const Debugging() | |
| 1200 : super(VmCommandCode.Debugging); | |
| 1201 | |
| 1202 void internalAddTo( | |
| 1203 Sink<List<int>> sink, CommandBuffer<VmCommandCode> buffer) { | |
| 1204 buffer | |
| 1205 ..addUint32(MapId.methods.index) | |
| 1206 ..addUint32(MapId.classes.index) | |
| 1207 ..addUint32(MapId.fibers.index) | |
| 1208 ..sendOn(sink, code); | |
| 1209 } | |
| 1210 | |
| 1211 int get numberOfResponsesExpected => 0; | |
| 1212 | |
| 1213 String valuesToString() => ""; | |
| 1214 } | |
| 1215 | |
| 1216 class DisableStandardOutput extends VmCommand { | |
| 1217 const DisableStandardOutput() | |
| 1218 : super(VmCommandCode.DisableStandardOutput); | |
| 1219 | |
| 1220 int get numberOfResponsesExpected => 0; | |
| 1221 | |
| 1222 String valuesToString() => ""; | |
| 1223 } | |
| 1224 | |
| 1225 class StdoutData extends VmCommand { | |
| 1226 final Uint8List value; | |
| 1227 | |
| 1228 const StdoutData(this.value) | |
| 1229 : super(VmCommandCode.StdoutData); | |
| 1230 | |
| 1231 int get numberOfResponsesExpected => 0; | |
| 1232 | |
| 1233 String valuesToString() => "$value"; | |
| 1234 } | |
| 1235 | |
| 1236 class StderrData extends VmCommand { | |
| 1237 final Uint8List value; | |
| 1238 | |
| 1239 const StderrData(this.value) | |
| 1240 : super(VmCommandCode.StderrData); | |
| 1241 | |
| 1242 int get numberOfResponsesExpected => 0; | |
| 1243 | |
| 1244 String valuesToString() => "$value"; | |
| 1245 } | |
| 1246 | |
| 1247 class WriteSnapshot extends VmCommand { | |
| 1248 final String value; | |
| 1249 | |
| 1250 const WriteSnapshot(this.value) | |
| 1251 : super(VmCommandCode.WriteSnapshot); | |
| 1252 | |
| 1253 void internalAddTo( | |
| 1254 Sink<List<int>> sink, CommandBuffer<VmCommandCode> buffer) { | |
| 1255 List<int> payload = UTF8.encode(value).toList()..add(0); | |
| 1256 buffer | |
| 1257 ..addUint32(payload.length) | |
| 1258 ..addUint8List(payload) | |
| 1259 ..sendOn(sink, code); | |
| 1260 } | |
| 1261 | |
| 1262 // Response is a [WriteSnapshotResult] message. | |
| 1263 int get numberOfResponsesExpected => 1; | |
| 1264 | |
| 1265 String valuesToString() => "'$value'"; | |
| 1266 } | |
| 1267 | |
| 1268 // Contains two tables with information about function/class offsets in the | |
| 1269 // program heap (when loaded from a snapshot). | |
| 1270 // | |
| 1271 // Both offset tables have the form: | |
| 1272 // [ | |
| 1273 // [class/function id1, config{1,2,3,4}-offset] | |
| 1274 // [class/function id2, ...], | |
| 1275 // ..., | |
| 1276 // ] | |
| 1277 // Each id/offset is represented as a 4 byte integer (which may be -1). | |
| 1278 // | |
| 1279 // All offsets are relative to the start of the program heap if a snapshot was | |
| 1280 // loaded into memory. | |
| 1281 // | |
| 1282 // The offsets are different for our 4 different configurations: | |
| 1283 // | |
| 1284 // config1: "64 bit double" | |
| 1285 // config2: "64 bit float" | |
| 1286 // config3: "32 bit double" | |
| 1287 // config4: "32 bit float" | |
| 1288 // | |
| 1289 class WriteSnapshotResult extends VmCommand { | |
| 1290 final Int32List classOffsetTable; | |
| 1291 final Int32List functionOffsetTable; | |
| 1292 final int hashtag; | |
| 1293 | |
| 1294 const WriteSnapshotResult(this.classOffsetTable, | |
| 1295 this.functionOffsetTable, | |
| 1296 this.hashtag) | |
| 1297 : super(VmCommandCode.WriteSnapshotResult); | |
| 1298 | |
| 1299 void internalAddTo( | |
| 1300 Sink<List<int>> sink, CommandBuffer<VmCommandCode> buffer) { | |
| 1301 throw new UnimplementedError(); | |
| 1302 } | |
| 1303 | |
| 1304 int get numberOfResponsesExpected => 0; | |
| 1305 | |
| 1306 String valuesToString() => "$classOffsetTable, $functionOffsetTable"; | |
| 1307 } | |
| 1308 | |
| 1309 class InstanceStructure extends VmCommand { | |
| 1310 final int classId; | |
| 1311 final int fields; | |
| 1312 | |
| 1313 const InstanceStructure(this.classId, this.fields) | |
| 1314 : super(VmCommandCode.InstanceStructure); | |
| 1315 | |
| 1316 void internalAddTo( | |
| 1317 Sink<List<int>> sink, CommandBuffer<VmCommandCode> buffer) { | |
| 1318 throw new UnimplementedError(); | |
| 1319 } | |
| 1320 | |
| 1321 int get numberOfResponsesExpected => 0; | |
| 1322 | |
| 1323 String valuesToString() => "$classId, $fields"; | |
| 1324 } | |
| 1325 | |
| 1326 abstract class DartValue extends VmCommand { | |
| 1327 const DartValue(VmCommandCode code) | |
| 1328 : super(code); | |
| 1329 | |
| 1330 void internalAddTo( | |
| 1331 Sink<List<int>> sink, CommandBuffer<VmCommandCode> buffer) { | |
| 1332 throw new UnimplementedError(); | |
| 1333 } | |
| 1334 | |
| 1335 int get numberOfResponsesExpected => 0; | |
| 1336 | |
| 1337 String valuesToString() => dartToString(); | |
| 1338 | |
| 1339 String dartToString(); | |
| 1340 } | |
| 1341 | |
| 1342 class Instance extends DartValue { | |
| 1343 final int classId; | |
| 1344 | |
| 1345 const Instance(this.classId) | |
| 1346 : super(VmCommandCode.Instance); | |
| 1347 | |
| 1348 String valuesToString() => "$classId"; | |
| 1349 | |
| 1350 String dartToString() => "Instance of $classId"; | |
| 1351 } | |
| 1352 | |
| 1353 class ClassValue extends DartValue { | |
| 1354 final int classId; | |
| 1355 | |
| 1356 const ClassValue(this.classId) | |
| 1357 : super(VmCommandCode.Class); | |
| 1358 | |
| 1359 String valuesToString() => "$classId"; | |
| 1360 | |
| 1361 String dartToString() => "Class with id $classId"; | |
| 1362 } | |
| 1363 | |
| 1364 class Integer extends DartValue { | |
| 1365 final int value; | |
| 1366 | |
| 1367 const Integer(this.value) | |
| 1368 : super(VmCommandCode.Integer); | |
| 1369 | |
| 1370 void internalAddTo( | |
| 1371 Sink<List<int>> sink, CommandBuffer<VmCommandCode> buffer) { | |
| 1372 buffer | |
| 1373 ..addUint64(value) | |
| 1374 ..sendOn(sink, code); | |
| 1375 } | |
| 1376 | |
| 1377 String dartToString() => '$value'; | |
| 1378 } | |
| 1379 | |
| 1380 class Double extends DartValue { | |
| 1381 final double value; | |
| 1382 | |
| 1383 const Double(this.value) | |
| 1384 : super(VmCommandCode.Double); | |
| 1385 | |
| 1386 String dartToString() => '$value'; | |
| 1387 } | |
| 1388 | |
| 1389 class Boolean extends DartValue { | |
| 1390 final bool value; | |
| 1391 | |
| 1392 const Boolean(this.value) | |
| 1393 : super(VmCommandCode.Boolean); | |
| 1394 | |
| 1395 String dartToString() => '$value'; | |
| 1396 } | |
| 1397 | |
| 1398 class NullValue extends DartValue { | |
| 1399 const NullValue() | |
| 1400 : super(VmCommandCode.Null); | |
| 1401 | |
| 1402 String valuesToString() => ''; | |
| 1403 | |
| 1404 String dartToString() => 'null'; | |
| 1405 } | |
| 1406 | |
| 1407 class StringValue extends DartValue { | |
| 1408 final String value; | |
| 1409 | |
| 1410 const StringValue(this.value) | |
| 1411 : super(VmCommandCode.String); | |
| 1412 | |
| 1413 String dartToString() => "'$value'"; | |
| 1414 } | |
| 1415 | |
| 1416 class ConnectionError extends VmCommand { | |
| 1417 final error; | |
| 1418 | |
| 1419 final StackTrace trace; | |
| 1420 | |
| 1421 const ConnectionError(this.error, this.trace) | |
| 1422 : super(VmCommandCode.ConnectionError); | |
| 1423 | |
| 1424 int get numberOfResponsesExpected => 0; | |
| 1425 | |
| 1426 String valuesToString() => "$error, $trace"; | |
| 1427 } | |
| 1428 | |
| 1429 // Any change in [VmCommandCode] must also be done in [Opcode] in | |
| 1430 // src/shared/connection.h. | |
| 1431 enum VmCommandCode { | |
| 1432 // DO NOT MOVE! The handshake opcodes needs to be the first one as | |
| 1433 // it is used to verify the compiler and vm versions. | |
| 1434 HandShake, | |
| 1435 HandShakeResult, | |
| 1436 | |
| 1437 // Session opcodes. | |
| 1438 // TODO(ahe): Understand what "Session opcodes" mean and turn it into a | |
| 1439 // proper documentation comment (the comment was copied from | |
| 1440 // src/bridge/opcodes.dart). | |
| 1441 ConnectionError, | |
| 1442 CompilerError, | |
| 1443 SessionEnd, | |
| 1444 Debugging, | |
| 1445 DisableStandardOutput, | |
| 1446 StdoutData, | |
| 1447 StderrData, | |
| 1448 | |
| 1449 ProcessDebugInterrupt, | |
| 1450 ProcessSpawnForMain, | |
| 1451 ProcessRun, | |
| 1452 ProcessSetBreakpoint, | |
| 1453 ProcessDeleteBreakpoint, | |
| 1454 ProcessStep, | |
| 1455 ProcessStepOver, | |
| 1456 ProcessStepOut, | |
| 1457 ProcessStepTo, | |
| 1458 ProcessContinue, | |
| 1459 ProcessBacktraceRequest, | |
| 1460 ProcessFiberBacktraceRequest, | |
| 1461 ProcessBacktrace, | |
| 1462 ProcessUncaughtExceptionRequest, | |
| 1463 ProcessBreakpoint, | |
| 1464 ProcessLocal, | |
| 1465 ProcessLocalStructure, | |
| 1466 ProcessRestartFrame, | |
| 1467 ProcessTerminated, | |
| 1468 ProcessCompileTimeError, | |
| 1469 ProcessAddFibersToMap, | |
| 1470 ProcessNumberOfStacks, | |
| 1471 | |
| 1472 ProcessGetProcessIds, | |
| 1473 ProcessGetProcessIdsResult, | |
| 1474 | |
| 1475 WriteSnapshot, | |
| 1476 WriteSnapshotResult, | |
| 1477 CollectGarbage, | |
| 1478 | |
| 1479 NewMap, | |
| 1480 DeleteMap, | |
| 1481 PushFromMap, | |
| 1482 PopToMap, | |
| 1483 RemoveFromMap, | |
| 1484 | |
| 1485 Dup, | |
| 1486 Drop, | |
| 1487 PushNull, | |
| 1488 PushBoolean, | |
| 1489 PushNewInteger, | |
| 1490 PushNewBigInteger, | |
| 1491 PushNewDouble, | |
| 1492 PushNewOneByteString, | |
| 1493 PushNewTwoByteString, | |
| 1494 PushNewInstance, | |
| 1495 PushNewArray, | |
| 1496 PushNewFunction, | |
| 1497 PushNewInitializer, | |
| 1498 PushNewClass, | |
| 1499 PushBuiltinClass, | |
| 1500 PushConstantList, | |
| 1501 PushConstantByteList, | |
| 1502 PushConstantMap, | |
| 1503 | |
| 1504 ChangeSuperClass, | |
| 1505 ChangeMethodTable, | |
| 1506 ChangeMethodLiteral, | |
| 1507 ChangeStatics, | |
| 1508 ChangeSchemas, | |
| 1509 | |
| 1510 PrepareForChanges, | |
| 1511 CommitChanges, | |
| 1512 CommitChangesResult, | |
| 1513 DiscardChange, | |
| 1514 | |
| 1515 UncaughtException, | |
| 1516 | |
| 1517 MapLookup, | |
| 1518 ObjectId, | |
| 1519 | |
| 1520 Integer, | |
| 1521 Boolean, | |
| 1522 Null, | |
| 1523 Double, | |
| 1524 String, | |
| 1525 Instance, | |
| 1526 Class, | |
| 1527 InstanceStructure | |
| 1528 } | |
| 1529 | |
| 1530 enum MapId { | |
| 1531 methods, | |
| 1532 classes, | |
| 1533 constants, | |
| 1534 fibers, | |
| 1535 } | |
| OLD | NEW |