svf-lib 1.0.1544 → 1.0.1546

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -264,6 +264,7 @@ private:
264
264
  StInfo* typeinfo; ///< SVF's TypeInfo
265
265
  bool isSingleValTy; ///< The type represents a single value, not struct or
266
266
  ///< array
267
+
267
268
  protected:
268
269
  SVFType(bool svt, SVFTyKind k)
269
270
  : kind(k), getPointerToTy(nullptr), typeinfo(nullptr),
@@ -280,9 +281,11 @@ public:
280
281
  return kind;
281
282
  }
282
283
 
283
- /// Needs to be implemented by a specific SVF front end (e.g., the
284
- /// implementation in LLVMUtil)
285
- virtual const std::string toString() const;
284
+ /// Note: Use `os<<svfType` or `svfType.print(os)` when possible to avoid
285
+ /// string concatenation.
286
+ std::string toString() const;
287
+
288
+ virtual void print(std::ostream& OS) const = 0;
286
289
 
287
290
  inline void setPointerTo(const SVFPointerType* ty)
288
291
  {
@@ -323,6 +326,8 @@ public:
323
326
  }
324
327
  };
325
328
 
329
+ std::ostream& operator<<(std::ostream& OS, const SVFType& type);
330
+
326
331
  class SVFPointerType : public SVFType
327
332
  {
328
333
  friend class SVFIRWriter;
@@ -344,6 +349,8 @@ public:
344
349
  {
345
350
  return ptrElementType;
346
351
  }
352
+
353
+ void print(std::ostream& OS) const override;
347
354
  };
348
355
 
349
356
  class SVFIntegerType : public SVFType
@@ -354,6 +361,8 @@ public:
354
361
  {
355
362
  return node->getKind() == SVFIntegerTy;
356
363
  }
364
+
365
+ void print(std::ostream& OS) const override;
357
366
  };
358
367
 
359
368
  class SVFFunctionType : public SVFType
@@ -377,36 +386,89 @@ public:
377
386
  {
378
387
  return retTy;
379
388
  }
389
+
390
+ void print(std::ostream& OS) const override;
380
391
  };
381
392
 
382
393
  class SVFStructType : public SVFType
383
394
  {
395
+ friend class SVFIRWriter;
396
+ friend class SVFIRReader;
397
+
398
+ private:
399
+ std::string name;
400
+
384
401
  public:
385
402
  SVFStructType() : SVFType(false, SVFStructTy) {}
403
+
386
404
  static inline bool classof(const SVFType* node)
387
405
  {
388
406
  return node->getKind() == SVFStructTy;
389
407
  }
408
+
409
+ void print(std::ostream& OS) const override;
410
+
411
+ std::string& getName()
412
+ {
413
+ return name;
414
+ }
390
415
  };
391
416
 
392
417
  class SVFArrayType : public SVFType
393
418
  {
419
+ friend class SVFIRWriter;
420
+ friend class SVFIRReader;
421
+
422
+ private:
423
+ unsigned numOfElement; /// For printing
424
+ SVFType* typeOfElement; /// For printing
425
+
394
426
  public:
395
- SVFArrayType() : SVFType(false, SVFArrayTy) {}
427
+ SVFArrayType()
428
+ : SVFType(false, SVFArrayTy), numOfElement(0), typeOfElement(nullptr)
429
+ {
430
+ }
431
+
396
432
  static inline bool classof(const SVFType* node)
397
433
  {
398
434
  return node->getKind() == SVFArrayTy;
399
435
  }
436
+
437
+ void print(std::ostream& OS) const override;
438
+
439
+ void setTypeOfElement(SVFType* elemType)
440
+ {
441
+ typeOfElement = elemType;
442
+ }
443
+
444
+ void setNumOfElement(unsigned elemNum)
445
+ {
446
+ numOfElement = elemNum;
447
+ }
400
448
  };
401
449
 
402
450
  class SVFOtherType : public SVFType
403
451
  {
452
+ friend class SVFIRWriter;
453
+ friend class SVFIRReader;
454
+
455
+ private:
456
+ std::string repr; /// Field representation for printing
457
+
404
458
  public:
405
459
  SVFOtherType(bool isSingleValueTy) : SVFType(isSingleValueTy, SVFOtherTy) {}
460
+
406
461
  static inline bool classof(const SVFType* node)
407
462
  {
408
463
  return node->getKind() == SVFOtherTy;
409
464
  }
465
+
466
+ std::string& getRepr()
467
+ {
468
+ return repr;
469
+ }
470
+
471
+ void print(std::ostream& OS) const override;
410
472
  };
411
473
 
412
474
  // TODO: be explicit that this is a pair of 32-bit unsigneds?
@@ -264,6 +264,7 @@ private:
264
264
  StInfo* typeinfo; ///< SVF's TypeInfo
265
265
  bool isSingleValTy; ///< The type represents a single value, not struct or
266
266
  ///< array
267
+
267
268
  protected:
268
269
  SVFType(bool svt, SVFTyKind k)
269
270
  : kind(k), getPointerToTy(nullptr), typeinfo(nullptr),
@@ -280,9 +281,11 @@ public:
280
281
  return kind;
281
282
  }
282
283
 
283
- /// Needs to be implemented by a specific SVF front end (e.g., the
284
- /// implementation in LLVMUtil)
285
- virtual const std::string toString() const;
284
+ /// Note: Use `os<<svfType` or `svfType.print(os)` when possible to avoid
285
+ /// string concatenation.
286
+ std::string toString() const;
287
+
288
+ virtual void print(std::ostream& OS) const = 0;
286
289
 
287
290
  inline void setPointerTo(const SVFPointerType* ty)
288
291
  {
@@ -323,6 +326,8 @@ public:
323
326
  }
324
327
  };
325
328
 
329
+ std::ostream& operator<<(std::ostream& OS, const SVFType& type);
330
+
326
331
  class SVFPointerType : public SVFType
327
332
  {
328
333
  friend class SVFIRWriter;
@@ -344,6 +349,8 @@ public:
344
349
  {
345
350
  return ptrElementType;
346
351
  }
352
+
353
+ void print(std::ostream& OS) const override;
347
354
  };
348
355
 
349
356
  class SVFIntegerType : public SVFType
@@ -354,6 +361,8 @@ public:
354
361
  {
355
362
  return node->getKind() == SVFIntegerTy;
356
363
  }
364
+
365
+ void print(std::ostream& OS) const override;
357
366
  };
358
367
 
359
368
  class SVFFunctionType : public SVFType
@@ -377,36 +386,89 @@ public:
377
386
  {
378
387
  return retTy;
379
388
  }
389
+
390
+ void print(std::ostream& OS) const override;
380
391
  };
381
392
 
382
393
  class SVFStructType : public SVFType
383
394
  {
395
+ friend class SVFIRWriter;
396
+ friend class SVFIRReader;
397
+
398
+ private:
399
+ std::string name;
400
+
384
401
  public:
385
402
  SVFStructType() : SVFType(false, SVFStructTy) {}
403
+
386
404
  static inline bool classof(const SVFType* node)
387
405
  {
388
406
  return node->getKind() == SVFStructTy;
389
407
  }
408
+
409
+ void print(std::ostream& OS) const override;
410
+
411
+ std::string& getName()
412
+ {
413
+ return name;
414
+ }
390
415
  };
391
416
 
392
417
  class SVFArrayType : public SVFType
393
418
  {
419
+ friend class SVFIRWriter;
420
+ friend class SVFIRReader;
421
+
422
+ private:
423
+ unsigned numOfElement; /// For printing
424
+ SVFType* typeOfElement; /// For printing
425
+
394
426
  public:
395
- SVFArrayType() : SVFType(false, SVFArrayTy) {}
427
+ SVFArrayType()
428
+ : SVFType(false, SVFArrayTy), numOfElement(0), typeOfElement(nullptr)
429
+ {
430
+ }
431
+
396
432
  static inline bool classof(const SVFType* node)
397
433
  {
398
434
  return node->getKind() == SVFArrayTy;
399
435
  }
436
+
437
+ void print(std::ostream& OS) const override;
438
+
439
+ void setTypeOfElement(SVFType* elemType)
440
+ {
441
+ typeOfElement = elemType;
442
+ }
443
+
444
+ void setNumOfElement(unsigned elemNum)
445
+ {
446
+ numOfElement = elemNum;
447
+ }
400
448
  };
401
449
 
402
450
  class SVFOtherType : public SVFType
403
451
  {
452
+ friend class SVFIRWriter;
453
+ friend class SVFIRReader;
454
+
455
+ private:
456
+ std::string repr; /// Field representation for printing
457
+
404
458
  public:
405
459
  SVFOtherType(bool isSingleValueTy) : SVFType(isSingleValueTy, SVFOtherTy) {}
460
+
406
461
  static inline bool classof(const SVFType* node)
407
462
  {
408
463
  return node->getKind() == SVFOtherTy;
409
464
  }
465
+
466
+ std::string& getRepr()
467
+ {
468
+ return repr;
469
+ }
470
+
471
+ void print(std::ostream& OS) const override;
410
472
  };
411
473
 
412
474
  // TODO: be explicit that this is a pair of 32-bit unsigneds?
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "svf-lib",
3
- "version": "1.0.1544",
3
+ "version": "1.0.1546",
4
4
  "description": "SVF's npm support",
5
5
  "main": "index.js",
6
6
  "scripts": {