@@ -52,7 +52,14 @@ InstructionTextToken::InstructionTextToken(): type(TextToken), value(0)
52
52
53
53
54
54
InstructionTextToken::InstructionTextToken (BNInstructionTextTokenType t, const std::string& txt, uint64_t val,
55
- size_t s, size_t o) : type(t), text(txt), value(val), size(s), operand(o)
55
+ size_t s, size_t o) : type(t), text(txt), value(val), size(s), operand(o), context(NoTokenContext), address(0 )
56
+ {
57
+ }
58
+
59
+
60
+ InstructionTextToken::InstructionTextToken (BNInstructionTextTokenType t, BNInstructionTextTokenContext ctxt,
61
+ const string& txt, uint64_t a, uint64_t val, size_t s, size_t o):
62
+ type(t), text(txt), value(val), size(s), operand(o), context(ctxt), address(a)
56
63
{
57
64
}
58
65
@@ -153,6 +160,8 @@ bool Architecture::GetInstructionTextCallback(void* ctxt, const uint8_t* data, u
153
160
(*result)[i].value = tokens[i].value ;
154
161
(*result)[i].size = tokens[i].size ;
155
162
(*result)[i].operand = tokens[i].operand ;
163
+ (*result)[i].context = tokens[i].context ;
164
+ (*result)[i].address = tokens[i].address ;
156
165
}
157
166
return true ;
158
167
}
@@ -737,9 +746,9 @@ void Architecture::SetBinaryViewTypeConstant(const string& type, const string& n
737
746
738
747
739
748
bool Architecture::ParseTypesFromSource (const string& source, const string& fileName,
740
- map<string , Ref<Type>>& types, map<string , Ref<Type>>& variables,
741
- map<string , Ref<Type>>& functions, string& errors,
742
- const vector< string>& includeDirs )
749
+ map<QualifiedName , Ref<Type>>& types, map<QualifiedName , Ref<Type>>& variables,
750
+ map<QualifiedName , Ref<Type>>& functions, string& errors, const vector<string>& includeDirs ,
751
+ const string& autoTypeSource )
743
752
{
744
753
BNTypeParserResult result;
745
754
char * errorStr;
@@ -753,26 +762,35 @@ bool Architecture::ParseTypesFromSource(const string& source, const string& file
753
762
functions.clear ();
754
763
755
764
bool ok = BNParseTypesFromSource (m_object, source.c_str (), fileName.c_str (), &result,
756
- &errorStr, includeDirList, includeDirs.size ());
765
+ &errorStr, includeDirList, includeDirs.size (), autoTypeSource. c_str ());
757
766
errors = errorStr;
758
767
BNFreeString (errorStr);
759
768
if (!ok)
760
769
return false ;
761
770
762
771
for (size_t i = 0 ; i < result.typeCount ; i++)
763
- types[result.types [i].name ] = new Type (BNNewTypeReference (result.types [i].type ));
772
+ {
773
+ QualifiedName name = QualifiedName::FromAPIObject (&result.types [i].name );
774
+ types[name] = new Type (BNNewTypeReference (result.types [i].type ));
775
+ }
764
776
for (size_t i = 0 ; i < result.variableCount ; i++)
765
- types[result.variables [i].name ] = new Type (BNNewTypeReference (result.variables [i].type ));
777
+ {
778
+ QualifiedName name = QualifiedName::FromAPIObject (&result.variables [i].name );
779
+ types[name] = new Type (BNNewTypeReference (result.variables [i].type ));
780
+ }
766
781
for (size_t i = 0 ; i < result.functionCount ; i++)
767
- types[result.functions [i].name ] = new Type (BNNewTypeReference (result.functions [i].type ));
782
+ {
783
+ QualifiedName name = QualifiedName::FromAPIObject (&result.functions [i].name );
784
+ types[name] = new Type (BNNewTypeReference (result.functions [i].type ));
785
+ }
768
786
BNFreeTypeParserResult (&result);
769
787
return true ;
770
788
}
771
789
772
790
773
- bool Architecture::ParseTypesFromSourceFile (const string& fileName, map<string , Ref<Type>>& types,
774
- map<string , Ref<Type>>& variables, map<string , Ref<Type>>& functions,
775
- string& errors, const vector<string>& includeDirs)
791
+ bool Architecture::ParseTypesFromSourceFile (const string& fileName, map<QualifiedName , Ref<Type>>& types,
792
+ map<QualifiedName , Ref<Type>>& variables, map<QualifiedName , Ref<Type>>& functions,
793
+ string& errors, const vector<string>& includeDirs, const string& autoTypeSource )
776
794
{
777
795
BNTypeParserResult result;
778
796
char * errorStr;
@@ -786,18 +804,27 @@ bool Architecture::ParseTypesFromSourceFile(const string& fileName, map<string,
786
804
functions.clear ();
787
805
788
806
bool ok = BNParseTypesFromSourceFile (m_object, fileName.c_str (), &result, &errorStr,
789
- includeDirList, includeDirs.size ());
807
+ includeDirList, includeDirs.size (), autoTypeSource. c_str ());
790
808
errors = errorStr;
791
809
BNFreeString (errorStr);
792
810
if (!ok)
793
811
return false ;
794
812
795
813
for (size_t i = 0 ; i < result.typeCount ; i++)
796
- types[result.types [i].name ] = new Type (BNNewTypeReference (result.types [i].type ));
814
+ {
815
+ QualifiedName name = QualifiedName::FromAPIObject (&result.types [i].name );
816
+ types[name] = new Type (BNNewTypeReference (result.types [i].type ));
817
+ }
797
818
for (size_t i = 0 ; i < result.variableCount ; i++)
798
- variables[result.variables [i].name ] = new Type (BNNewTypeReference (result.variables [i].type ));
819
+ {
820
+ QualifiedName name = QualifiedName::FromAPIObject (&result.variables [i].name );
821
+ variables[name] = new Type (BNNewTypeReference (result.variables [i].type ));
822
+ }
799
823
for (size_t i = 0 ; i < result.functionCount ; i++)
800
- functions[result.functions [i].name ] = new Type (BNNewTypeReference (result.functions [i].type ));
824
+ {
825
+ QualifiedName name = QualifiedName::FromAPIObject (&result.functions [i].name );
826
+ functions[name] = new Type (BNNewTypeReference (result.functions [i].type ));
827
+ }
801
828
BNFreeTypeParserResult (&result);
802
829
return true ;
803
830
}
@@ -954,8 +981,8 @@ bool CoreArchitecture::GetInstructionText(const uint8_t* data, uint64_t addr, si
954
981
955
982
for (size_t i = 0 ; i < count; i++)
956
983
{
957
- result.push_back (InstructionTextToken (tokens[i].type , tokens[i].text , tokens[i].value ,
958
- tokens[i].size , tokens[i].operand ));
984
+ result.push_back (InstructionTextToken (tokens[i].type , tokens[i].context , tokens[i]. text , tokens[i].address ,
985
+ tokens[i].value , tokens[i]. size , tokens[i].operand ));
959
986
}
960
987
961
988
BNFreeInstructionText (tokens, count);
0 commit comments