Permalink
Browse files

Convert the Intermediate Representation to Reason.

Reviewed By: jberdine

Differential Revision: D3138490

fbshipit-source-id: e3b53fa
  • Loading branch information...
1 parent bf7287e commit 885beed0b14e8ef4b6e8a0aa3f4239e60c4e567b @cristianoc cristianoc committed with Facebook Github Bot 1 May 17, 2016
Showing with 11,241 additions and 9,566 deletions.
  1. +1 −1 configure.ac
  2. +86 −0 infer/src/IR/AttributesTable.re
  3. +30 −0 infer/src/IR/AttributesTable.rei
  4. +1,302 −0 infer/src/IR/Cfg.re
  5. +328 −0 infer/src/IR/Cfg.rei
  6. +435 −0 infer/src/IR/Cg.re
  7. +125 −0 infer/src/IR/Cg.rei
  8. +49 −0 infer/src/IR/Csu.re
  9. +11 −18 infer/src/IR/{csu.mli → Csu.rei}
  10. +415 −0 infer/src/IR/Ident.re
  11. +269 −0 infer/src/IR/Ident.rei
  12. +55 −0 infer/src/IR/Location.re
  13. +39 −0 infer/src/IR/Location.rei
  14. +87 −0 infer/src/IR/Mangled.re
  15. +56 −0 infer/src/IR/Mangled.rei
  16. +68 −0 infer/src/IR/ProcAttributes.re
  17. +42 −0 infer/src/IR/ProcAttributes.rei
  18. +576 −0 infer/src/IR/Procname.re
  19. +251 −0 infer/src/IR/Procname.rei
  20. +306 −0 infer/src/IR/Pvar.re
  21. +125 −0 infer/src/IR/Pvar.rei
  22. +4 −4 infer/src/IR/README.md
  23. +4,755 −0 infer/src/IR/Sil.re
  24. +1,478 −0 infer/src/IR/Sil.rei
  25. +172 −0 infer/src/IR/Tenv.re
  26. +75 −0 infer/src/IR/Tenv.rei
  27. +61 −0 infer/src/IR/Typename.re
  28. +39 −0 infer/src/IR/Typename.rei
  29. +0 −73 infer/src/IR/attributesTable.ml
  30. +0 −28 infer/src/IR/attributesTable.mli
  31. +0 −1,194 infer/src/IR/cfg.ml
  32. +0 −323 infer/src/IR/cfg.mli
  33. +0 −363 infer/src/IR/cg.ml
  34. +0 −102 infer/src/IR/cg.mli
  35. +0 −55 infer/src/IR/csu.ml
  36. +0 −371 infer/src/IR/ident.ml
  37. +0 −211 infer/src/IR/ident.mli
  38. +0 −49 infer/src/IR/location.ml
  39. +0 −34 infer/src/IR/location.mli
  40. +0 −74 infer/src/IR/mangled.ml
  41. +0 −46 infer/src/IR/mangled.mli
  42. +0 −69 infer/src/IR/procAttributes.ml
  43. +0 −44 infer/src/IR/procAttributes.mli
  44. +0 −515 infer/src/IR/procname.ml
  45. +0 −201 infer/src/IR/procname.mli
  46. +0 −215 infer/src/IR/pvar.ml
  47. +0 −99 infer/src/IR/pvar.mli
  48. +0 −3,854 infer/src/IR/sil.ml
  49. +0 −1,294 infer/src/IR/sil.mli
  50. +0 −168 infer/src/IR/tenv.ml
  51. +0 −60 infer/src/IR/tenv.mli
  52. +0 −61 infer/src/IR/typename.ml
  53. +0 −39 infer/src/IR/typename.mli
  54. +1 −1 infer/src/Makefile.in
View
@@ -17,7 +17,7 @@ AC_PREREQ([2.63])
AC_INIT([Infer],
[0.8.1],
[https://github.com/facebook/infer/issues/])
-AC_CONFIG_SRCDIR([infer/src/IR/sil.ml])
+AC_CONFIG_SRCDIR([infer/src/IR/Sil.re])
# WARNING: keep in sync with above
INFER_MAJOR=0
@@ -0,0 +1,86 @@
+/*
+ * Copyright (c) 2015 - present Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under the BSD style license found in the
+ * LICENSE file in the root directory of this source tree. An additional grant
+ * of patent rights can be found in the PATENTS file in the same directory.
+ */
+
+open! Utils;
+
+let module F = Format;
+
+let module L = Logging;
+
+
+/** Module to manage the table of attributes. */
+let serializer: Serialization.serializer ProcAttributes.t = Serialization.create_serializer Serialization.attributes_key;
+
+let attributes_filename pname => {
+ let pname_file = Procname.to_filename pname;
+ pname_file ^ ".attr"
+};
+
+
+/** path to the .attr file for the given procedure in the current results directory */
+let res_dir_attr_filename pname => {
+ let attr_fname = attributes_filename pname;
+ let bucket_dir = {
+ let base = Filename.chop_extension attr_fname;
+ let len = String.length base;
+ if (len < 2) {
+ Filename.current_dir_name
+ } else {
+ String.sub base (len - 2) 2
+ }
+ };
+ let filename =
+ DB.Results_dir.path_to_filename
+ DB.Results_dir.Abs_root [Config.attributes_dir_name, bucket_dir, attr_fname];
+ DB.filename_create_dir filename;
+ filename
+};
+
+let store_attributes proc_attributes => {
+ let proc_name = proc_attributes.ProcAttributes.proc_name;
+ let attributes_file = res_dir_attr_filename proc_name;
+ let should_write =
+ /* only overwrite defined procedures */
+ proc_attributes.ProcAttributes.is_defined || not (DB.file_exists attributes_file);
+ if should_write {
+ Serialization.to_file serializer attributes_file proc_attributes
+ }
+};
+
+let load_attributes proc_name => {
+ let attributes_file = res_dir_attr_filename proc_name;
+ Serialization.from_file serializer attributes_file
+};
+
+
+/** Given a procdesure name, find the file where it is defined and */
+/** its corresponding type environment */
+let find_tenv_from_class_of_proc procname =>
+ switch (load_attributes procname) {
+ | None => None
+ | Some attrs =>
+ let source_file = attrs.ProcAttributes.loc.Location.file;
+ let source_dir = DB.source_dir_from_source_file source_file;
+ let tenv_fname = DB.source_dir_get_internal_file source_dir ".tenv";
+ Tenv.load_from_file tenv_fname
+ };
+
+
+/** Given an ObjC class c, extract the type from the tenv where the class was */
+/** defined. We do this by adding a method that is unique to each class, and then */
+/** finding the tenv that corresponds to the class definition. */
+let get_correct_type_from_objc_class_name c => {
+ let class_method = Procname.get_default_objc_class_method (Mangled.to_string c);
+ switch (find_tenv_from_class_of_proc class_method) {
+ | None => None
+ | Some tenv =>
+ let type_name = Typename.TN_csu (Csu.Class Csu.Objc) c;
+ Option.map (fun st => Sil.Tstruct st) (Tenv.lookup tenv type_name)
+ }
+};
@@ -0,0 +1,30 @@
+/*
+ * Copyright (c) 2015 - present Facebook, Inc.
+ * All rights reserved.
+ *
+ * This source code is licensed under the BSD style license found in the
+ * LICENSE file in the root directory of this source tree. An additional grant
+ * of patent rights can be found in the PATENTS file in the same directory.
+ */
+
+open! Utils;
+
+
+/** Module to manage the table of attributes. */
+/** Save .attr file for the procedure into the attributes database. */
+let store_attributes: ProcAttributes.t => unit;
+
+
+/** Load the attributes for the procedure from the attributes database. */
+let load_attributes: Procname.t => option ProcAttributes.t;
+
+
+/** Given a procdesure name, find the file where it is defined and */
+/** its corresponding type environment */
+let find_tenv_from_class_of_proc: Procname.t => option Tenv.t;
+
+
+/** Given an ObjC class c, extract the type from the tenv where the class was */
+/** defined. We do this by adding a method that is unique to each class, and then */
+/** finding the tenv that corresponds to the class definition. */
+let get_correct_type_from_objc_class_name: Mangled.t => option Sil.typ;
Oops, something went wrong.

0 comments on commit 885beed

Please sign in to comment.