lcode.h 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /*
  2. ** $Id: lcode.h,v 1.36 2002/05/13 13:07:48 roberto Exp roberto $
  3. ** Code generator for Lua
  4. ** See Copyright Notice in lua.h
  5. */
  6. #ifndef lcode_h
  7. #define lcode_h
  8. #include "llex.h"
  9. #include "lobject.h"
  10. #include "lopcodes.h"
  11. #include "lparser.h"
  12. /*
  13. ** Marks the end of a patch list. It is an invalid value both as an absolute
  14. ** address, and as a list link (would link an element to itself).
  15. */
  16. #define NO_JUMP (-1)
  17. /*
  18. ** grep "ORDER OPR" if you change these enums
  19. */
  20. typedef enum BinOpr {
  21. OPR_ADD, OPR_SUB, OPR_MULT, OPR_DIV, OPR_POW,
  22. OPR_CONCAT,
  23. OPR_NE, OPR_EQ,
  24. OPR_LT, OPR_LE, OPR_GT, OPR_GE,
  25. OPR_AND, OPR_OR,
  26. OPR_NOBINOPR
  27. } BinOpr;
  28. #define binopistest(op) ((op) >= OPR_NE)
  29. typedef enum UnOpr { OPR_MINUS, OPR_NOT, OPR_NOUNOPR } UnOpr;
  30. #define getcode(fs,e) ((fs)->f->code[(e)->info])
  31. #define luaK_codeAsBx(fs,o,A,sBx) luaK_codeABx(fs,o,A,(sBx)+MAXARG_sBx)
  32. int luaK_code (FuncState *fs, Instruction i, int line);
  33. int luaK_codeABx (FuncState *fs, OpCode o, int A, unsigned int Bx);
  34. int luaK_codeABC (FuncState *fs, OpCode o, int A, int B, int C);
  35. void luaK_fixline (FuncState *fs, int line);
  36. void luaK_nil (FuncState *fs, int from, int n);
  37. void luaK_reserveregs (FuncState *fs, int n);
  38. int luaK_stringK (FuncState *fs, TString *s);
  39. int luaK_numberK (FuncState *fs, lua_Number r);
  40. void luaK_dischargevars (FuncState *fs, expdesc *e);
  41. int luaK_exp2anyreg (FuncState *fs, expdesc *e);
  42. void luaK_exp2nextreg (FuncState *fs, expdesc *e);
  43. void luaK_exp2val (FuncState *fs, expdesc *e);
  44. int luaK_exp2RK (FuncState *fs, expdesc *e);
  45. void luaK_self (FuncState *fs, expdesc *e, expdesc *key);
  46. void luaK_indexed (FuncState *fs, expdesc *t, expdesc *k);
  47. void luaK_goiftrue (FuncState *fs, expdesc *e);
  48. void luaK_goiffalse (FuncState *fs, expdesc *e);
  49. void luaK_storevar (FuncState *fs, expdesc *var, expdesc *e);
  50. void luaK_setcallreturns (FuncState *fs, expdesc *var, int nresults);
  51. int luaK_jump (FuncState *fs);
  52. void luaK_patchlist (FuncState *fs, int list, int target);
  53. void luaK_patchtohere (FuncState *fs, int list);
  54. void luaK_concat (FuncState *fs, int *l1, int l2);
  55. int luaK_getlabel (FuncState *fs);
  56. void luaK_prefix (FuncState *fs, UnOpr op, expdesc *v);
  57. void luaK_infix (FuncState *fs, BinOpr op, expdesc *v);
  58. void luaK_posfix (FuncState *fs, BinOpr op, expdesc *v1, expdesc *v2);
  59. #endif