Showing the changes to src/include (1 of 4 files). Show all
Unified · Split
| @@ -34,7 +34,7 @@ namespace disvm · 33 unmodified lines | |||
| 34 | // If the supplied string cannot be resolved or if it is null, the 'invalid' opcode is returned. | 34 | // If the supplied string cannot be resolved or if it is null, the 'invalid' opcode is returned. |
| 35 | disvm::opcode_t token_to_opcode(const char *); | 35 | disvm::opcode_t token_to_opcode(const char *); |
| 36 | 36 | ||
| 37 | // Namedspace named after enum type in Limbo compiler | 37 | // Namespace named after enum type in Limbo compiler |
| 38 | // Source: limbo/types.c | 38 | // Source: limbo/types.c |
| 39 | namespace sigkind | 39 | namespace sigkind |
| 40 | { | 40 | { |
| @@ -369,6 +369,85 @@ namespace disvm · 328 unmodified lines | |||
| 369 | } | 369 | } |
| 370 | } | 370 | } |
| 371 | 371 | ||
| 372 | namespace symbol | ||
| 373 | { | ||
| 374 | // Type class enum for symbols is unrelated to signature types enum. | ||
| 375 | // The historical reason for this isn't recorded but is found in | ||
| 376 | // the official Limbo compiler. | ||
| 377 | enum class type_class_t : uint8_t | ||
| 378 | { | ||
| 379 | type_index = '@', | ||
| 380 | adt = 'a', | ||
| 381 | adt_pick = 'p', | ||
| 382 | tuple = 't', | ||
| 383 | module = 'm', | ||
| 384 | function = 'F', | ||
| 385 | array = 'A', | ||
| 386 | channel = 'C', | ||
| 387 | list = 'L', | ||
| 388 | ref = 'R', | ||
| 389 | none = 'n', | ||
| 390 | nil = 'N', | ||
| 391 | big = 'B', | ||
| 392 | byte = 'b', | ||
| 393 | integer = 'i', | ||
| 394 | real = 'f', | ||
| 395 | string = 's', | ||
| 396 | poly = 'P', | ||
| 397 | }; | ||
| 398 | |||
| 399 | // Reference into source code | ||
| 400 | struct source_ref_t | ||
| 401 | { | ||
| 402 | int32_t source_id; | ||
| 403 | int32_t begin_line; | ||
| 404 | int32_t begin_column; | ||
| 405 | int32_t end_line; | ||
| 406 | int32_t end_column; | ||
| 407 | }; | ||
| 408 | |||
| 409 | class symbol_debug_t | ||
| 410 | { | ||
| 411 | public: | ||
| 412 | // Set the current pc | ||
| 413 | virtual void set_current_pc(disvm::runtime::vm_pc_t) = 0; | ||
| 414 | |||
| 415 | // Enumeration for advancing the pc | ||
| 416 | enum class advance_pc_t | ||
| 417 | { | ||
| 418 | current, // Return the current pc | ||
| 419 | next_pc, | ||
| 420 | next_debug_statement, // Advance to the next debug statement (i.e. source language statement) | ||
| 421 | }; | ||
| 422 | |||
| 423 | // Advance the current pc. | ||
| 424 | // Returns 'true' if the function was successful, otherwise 'false'. | ||
| 425 | virtual bool try_advance_pc(advance_pc_t, disvm::runtime::vm_pc_t *pc_after_advance = nullptr) = 0; | ||
| 426 | |||
| 427 | // Return the name of the function encompassing the current pc. | ||
| 428 | // This function will throw a 'std::runtime_error' if a function doesn't exist at the current pc. | ||
| 429 | virtual const std::string & current_function_name() const = 0; | ||
| 430 | |||
| 431 | // Return the source location for the current pc | ||
| 432 | virtual source_ref_t current_source_location() const = 0; | ||
| 433 | |||
| 434 | // Get source file name based on ID | ||
| 435 | virtual const std::string &get_source_by_id(int32_t source_id) const = 0; | ||
| 436 | }; | ||
| 437 | |||
| 438 | class symbol_data_t | ||
| 439 | { | ||
| 440 | public: | ||
| 441 | // Get name of the module | ||
| 442 | virtual const std::string& get_module_name() const = 0; | ||
| 443 | |||
| 444 | // Get interface over symbol data targeted for debugging | ||
| 445 | virtual std::unique_ptr<symbol_debug_t> get_debug() = 0; | ||
| 446 | }; | ||
| 447 | |||
| 448 | std::unique_ptr<symbol_data_t> read(std::istream &); | ||
| 449 | } | ||
| 450 | |||
| 372 | namespace runtime | 451 | namespace runtime |
| 373 | { | 452 | { |
| 374 | // Operators for printing bytecode instructions | 453 | // Operators for printing bytecode instructions |