Advertisement
Guest User

Untitled

a guest
Aug 19th, 2019
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.40 KB | None | 0 0
  1. function recompile(context) {
  2.  
  3. var previous = {values: context.previous};
  4.  
  5. previous.argnames = previous.values.map(function cmpArgNames(_, i) { return 'previous' + i });
  6.  
  7. previous.funcalls = previous.values.map(function cmpFunCalls(f, i) {
  8. var args = (f.length === 1 ? '(recv)' : '(recv, args, context.storage)');
  9. return previous.argnames[i] + args;
  10. });
  11.  
  12. var future = {values: context.future};
  13.  
  14. future.argnames = future.values.map(function(_, i) { return 'future' + i });
  15.  
  16. future.funcalls = future.values.map(function(f, i) {
  17. var args = (f.length === 2 ? '(recv, rval)' : '(recv, args, rval, context.storage)');
  18.  
  19. return future.argnames[i] + args;
  20. });
  21.  
  22. var source = require('util').format(
  23. ' (function(%s) { n return function(recv, args) { n try{%s;}catch(e){logProbeErrorMessage(e, recv, context.target, true);} n var rval = context.target.apply(recv, args); n try{%s;}catch(e){logProbeErrorMessage(e, recv, context.target, null, true);} n return rval; n }; n }) n' ,
  24. ['context'].concat(previous.argnames).concat(future.argnames),
  25. previous.funcalls.join(';n'), future.funcalls.join(';n'));
  26.  
  27. var args = [context].concat(previous.values).concat(future.values);
  28.  
  29. return eval(source).apply(null, args);
  30. }
  31.  
  32. var source = require('util').format(
  33. ' (function(%s) { n return function(recv, args) { n try{%s;}catch(e){logProbeErrorMessage(e, recv, context.target, true);} n var rval = context.target.apply(recv, args); n try{%s;}catch(e){logProbeErrorMessage(e, recv, context.target, null, true);} n return rval; n }; n }) n' ,
  34. ['context'].concat(previous.argnames).concat(future.argnames),
  35. previous.funcalls.join(';n'), future.funcalls.join(';n'));
  36.  
  37. (function(context) {
  38. return function(recv, args) {
  39. try{;}catch(e){logProbeErrorMessage(e, recv, context.target, true);}
  40. var rval = context.target.apply(recv, args);
  41. try{;}catch(e){logProbeErrorMessage(e, recv, context.target, null, true);}
  42. return rval;
  43. };
  44. })
  45.  
  46. (function([ 'context' ]) {
  47. return function(recv, args) {
  48. try{;}catch(e){logProbeErrorMessage(e, recv, context.target, true);}
  49. var rval = context.target.apply(recv, args);
  50. try{;}catch(e){logProbeErrorMessage(e, recv, context.target, null, true);}
  51. return rval;
  52. };
  53. })
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement