Removed compilation warnings in dyninst
[dyninst.git] / dyninstAPI / src / BPatch_sourceBlock.C
1 #define BPATCH_FILE
2
3 #include <stdio.h>
4 #include <iostream>
5 #include "BPatch_sourceBlock.h"
6
7 //constructor
8 BPatch_sourceBlock::BPatch_sourceBlock()
9         : sourceFile(NULL),sourceLines(NULL)
10 {}
11
12 //constructor
13 BPatch_sourceBlock::BPatch_sourceBlock( const char *filePtr,
14                                         BPatch_Set<unsigned short>& lines)
15 {
16         sourceFile = filePtr;
17         sourceLines = new BPatch_Set<unsigned short>(lines);
18 }
19
20 const char*
21 BPatch_sourceBlock::getSourceFile(){
22         return sourceFile;
23 }
24
25 void
26 BPatch_sourceBlock::getSourceLines(BPatch_Vector<unsigned short>& lines){
27
28         if(!sourceLines)
29                 return;
30
31         unsigned short* elements = new unsigned short[sourceLines->size()];
32         sourceLines->elements(elements);
33
34         for(unsigned j=0;j<sourceLines->size();j++)
35                 lines.push_back(elements[j]);
36                 
37         delete[] elements;
38 }
39
40
41 #ifdef DEBUG 
42 //print method 
43 ostream& operator<<(ostream& os,BPatch_sourceBlock& sb){
44
45         os << "{";
46
47         if(sb.sourceFile)
48                 os << sb.sourceFile << " (";
49         else
50                 os << "<NO_FILE_NAME>" << " (";
51                 
52         if(sb.sourceLines){
53                 unsigned short* elements = new unsigned short[sb.sourceLines->size()];
54                 sb.sourceLines->elements(elements);
55                 for(int j=0;j<sb.sourceLines->size();j++)
56                         os << " " << elements[j];
57                 delete[] elements;
58         }
59         else
60                 os << "<NO_LINE_NUMBERS>";
61
62         os << ")}" << endl;
63         return os;
64 }
65 #endif
66
67 #ifdef IBM_BPATCH_COMPAT
68 void BPatch_sourceBlock::getIncPoints(BPatch_Vector<BPatch_point *> &vect)
69 {
70 //  nothing here for now...  might need to implement, might not.
71 }
72
73 void BPatch_sourceBlock::getExcPoints(BPatch_Vector<BPatch_point *> &vect)
74 {
75  //  for now, they are the same
76  getIncPoints(vect);
77 }
78 #endif