A minimalistic programming language written in C89.
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

39 lignes
966 B

il y a 4 mois
il y a 4 mois
il y a 4 mois
il y a 4 mois
il y a 4 mois
il y a 4 mois
il y a 4 mois
  1. #include "ink.h"
  2. #include <stdio.h>
  3. #include <time.h>
  4. int main(int argc, char** argv) {
  5. char read_buffer[2048];
  6. clock_t begin, end;
  7. double time_spent;
  8. struct context* ctx;
  9. char** end_argv;
  10. ctx = ink_make_default_context();
  11. end_argv = argv + argc;
  12. for(argv+=1; argv != end_argv; argv++) {
  13. FILE* file;
  14. size_t cnt;
  15. file = fopen(*argv, "r");
  16. cnt = fread(read_buffer, 1, 2047, file);
  17. if(cnt == 0) {
  18. fprintf(stderr, "Can't read file !! -> %s\n", *argv);
  19. }
  20. read_buffer[cnt] = 0;
  21. ink_compile(ctx, read_buffer);
  22. if(ctx->panic) {
  23. fprintf(stderr, "Panicked !! -> %d\n", ctx->panic);
  24. }
  25. fclose(file);
  26. }
  27. begin = clock();
  28. while(ink_can_run(ctx)) {
  29. ink_step_everyone(ctx);
  30. }
  31. ink_gc(ctx);
  32. end = clock();
  33. time_spent = ctx->steps/((double)(end - begin) / CLOCKS_PER_SEC);
  34. printf("\nExecuted in %u steps\nCollected %u times\nExecution freq: %uHz\n", ctx->steps, ctx->collections, (unsigned int)time_spent);
  35. return ctx->panic;
  36. }