You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

37 lines
1.1 KiB

  1. From a114b871e460ef2ddcf7698bc6b18651c976626a Mon Sep 17 00:00:00 2001
  2. From: Muh Muhten <muh.muhten@gmail.com>
  3. Date: Tue, 19 Feb 2019 00:14:53 -0500
  4. Subject: [PATCH 6/9] Replace TOP-before-imports special case with assert
  5. The case isn't actually possible afaict.
  6. ---
  7. src/compile.c | 11 ++++-------
  8. 1 file changed, 4 insertions(+), 7 deletions(-)
  9. --- a/src/compile.c
  10. +++ b/src/compile.c
  11. @@ -469,10 +469,10 @@ block block_drop_unreferenced(block body
  12. jv block_take_imports(block* body) {
  13. jv imports = jv_array();
  14. - inst* top = NULL;
  15. - if (body->first && body->first->op == TOP) {
  16. - top = block_take(body);
  17. - }
  18. + /* Parser should never generate TOP before imports */
  19. + assert(!(body->first && body->first->op == TOP && body->first->next &&
  20. + (body->first->next->op == MODULEMETA || body->first->next->op == DEPS)));
  21. +
  22. while (body->first && (body->first->op == MODULEMETA || body->first->op == DEPS)) {
  23. inst* dep = block_take(body);
  24. if (dep->op == DEPS) {
  25. @@ -480,9 +480,6 @@ jv block_take_imports(block* body) {
  26. }
  27. inst_free(dep);
  28. }
  29. - if (top) {
  30. - *body = block_join(inst_block(top),*body);
  31. - }
  32. return imports;
  33. }