record.js 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. <rtl code>
  2. var m = function (){
  3. function Base1(){
  4. }
  5. function T1(){
  6. Base1.call(this);
  7. this.i = 0;
  8. }
  9. RTL$.extend(T1, Base1);
  10. function RecordWithInnerRecord(){
  11. this.r = new T1();
  12. }
  13. function RecordWithInnerArray(){
  14. this.aInts = RTL$.makeArray(3, 0);
  15. this.aRecords = RTL$.makeArray(3, function(){return new T1();});
  16. this.aPointers = RTL$.makeArray(3, null);
  17. }
  18. function RecordWithMangledFields(){
  19. this.constructor$ = 0;
  20. this.prototype$ = false;
  21. }
  22. var b1 = new Base1();
  23. var r1 = new T1();var r2 = new T1();
  24. var recordWithInnerRecord = new RecordWithInnerRecord();
  25. var recordWithInnerArray = new RecordWithInnerArray();
  26. var recordWithMangledFields = new RecordWithMangledFields();
  27. function p1(r/*T1*/){
  28. }
  29. function p2(r/*VAR T1*/){
  30. p1(r);
  31. }
  32. function byRef(i/*VAR INTEGER*/){
  33. }
  34. RTL$.copy(r1, b1, {record: {}});
  35. RTL$.copy(r2, r1, {record: {i: null}});
  36. RTL$.copy(recordWithInnerArray, recordWithInnerArray, {record: {aInts: {array: null}, aRecords: {array: {record: {i: null}}}, aPointers: {array: null}}});
  37. p1(r1);
  38. p2(r1);
  39. recordWithInnerRecord.r.i = 123;
  40. p1(recordWithInnerRecord.r);
  41. p2(recordWithInnerRecord.r);
  42. byRef(RTL$.makeRef(recordWithInnerRecord.r, "i"));
  43. recordWithInnerArray.aInts[0] = 123;
  44. recordWithInnerArray.aRecords[0].i = 123;
  45. recordWithInnerArray.aPointers[0].i = 123;
  46. RTL$.assert(recordWithMangledFields.constructor$ == 0);
  47. RTL$.assert(!recordWithMangledFields.prototype$);
  48. }();