]> sourceware.org Git - systemtap.git/commitdiff
new resolved_type struct and mismatch/resolved functions
authorJonathan Lebon <jlebon@redhat.com>
Mon, 11 Nov 2013 16:34:39 +0000 (11:34 -0500)
committerJonathan Lebon <jlebon@redhat.com>
Tue, 12 Nov 2013 21:01:45 +0000 (16:01 -0500)
The resolved_type struct holds all the information about a newly
resolved decl. The token 'tok' holds where the resolution occurred, and
'index' is the position of the function-argument/array-index of the
decl.

The vector resolved_types will hold all the decls we resolve. A new
resolved() function is introduced which will add elements to the vector,
while an analogous mismatch() function will be used to report mismatches
between type and resolved decl.

elaborate.cxx
elaborate.h

index 361ce2b2e8ea80098f4e11938070334558fd3e6f..6e4df928c4eda88bae4d7ed39230c7dcb95ca42c 100644 (file)
@@ -5346,6 +5346,19 @@ typeresolution_info::invalid (const token* tok, exp_type pe)
     }
 }
 
+void
+typeresolution_info::mismatch (const binary_expression* e)
+{
+  num_still_unresolved ++;
+
+  if (assert_resolvability)
+    {
+      stringstream msg;
+      msg << _F("type mismatch: left and right sides don't agree (%s vs %s)",
+                lex_cast(e->left->type).c_str(), lex_cast(e->right->type).c_str());
+      session.print_error (SEMANTIC_ERROR (msg.str(), e->tok));
+    }
+}
 
 /* tok   token where mismatch occurred
  * t1    type we expected (the 'good' type)
@@ -5366,11 +5379,36 @@ typeresolution_info::mismatch (const token* tok, exp_type t1, exp_type t2)
     }
 }
 
+/* tok   token where the mismatch happened
+ * type  type we received (the 'bad' type)
+ * decl  declaration of mismatched symbol
+ * index if index-based (array index or function arg)
+ * */
+void
+typeresolution_info::mismatch (const token *tok, exp_type type,
+                               const symboldecl* decl, int index)
+{
+  num_still_unresolved ++;
+
+  if (assert_resolvability)
+    {
+      cerr << "A mismatch occurred" << endl;
+      // TODO: retrieve from resolved_types vector
+    }
+}
+
 
+/* tok   token where resolution occurred
+ * type  type to which we resolved
+ * decl  declaration of resolved symbol
+ * index if index-based (array index or function arg)
+ * */
 void
-typeresolution_info::resolved (const token*, exp_type)
+typeresolution_info::resolved (const token *tok, exp_type type,
+                               const symboldecl* decl, int index)
 {
   num_newly_resolved ++;
+  // TODO: add to resolved_types vector
 }
 
 /* vim: set sw=2 ts=8 cino=>4,n-2,{2,^-2,t0,(0,u0,w1,M1 : */
index 7624d63d6353cc5a32b8b1ac49778c094a6e9514..54aadfd3c7d860b9fb2d6ab7c73e5ceed15d1fe0 100644 (file)
@@ -74,12 +74,34 @@ struct typeresolution_info: public visitor
   functiondecl* current_function;
   derived_probe* current_probe;
 
+  // Holds information about a type we resolved (see PR16097)
+  struct resolved_type
+  {
+    const token *tok;
+    const symboldecl *decl;
+    int index;
+    resolved_type(const token *ct, const symboldecl *cdecl, int cindex):
+      tok(ct), decl(cdecl), index(cindex) {}
+  };
+
+  // Holds an element each time we resolve a decl. Unique by decl & index.
+  // Possible values:
+  //  - resolved function type     -> decl = functiondecl, index = -1
+  //  - resolved function arg type -> decl = vardecl,      index = index of arg
+  //  - resolved array/var type    -> decl = vardecl,      index = -1
+  //  - resolved array index type  -> decl = vardecl,      index = index of type
+  std::vector<resolved_type> resolved_types; // see PR16097
+
   void check_arg_type (exp_type wanted, expression* arg);
   void check_local (vardecl* v);
-  void mismatch (const token* tok, exp_type t1, exp_type t2);
   void unresolved (const token* tok);
-  void resolved (const token* tok, exp_type t);
   void invalid (const token* tok, exp_type t);
+  void mismatch (const binary_expression* e);
+  void mismatch (const token* tok, exp_type t1, exp_type t2);
+  void mismatch (const token* tok, exp_type type,
+                 const symboldecl* decl, int index = -1);
+  void resolved (const token* tok, exp_type type,
+                 const symboldecl* decl = NULL, int index = -1);
 
   exp_type t; // implicit parameter for nested visit call; may clobber
               // Upon entry to one of the visit_* calls, the incoming
This page took 0.037905 seconds and 5 git commands to generate.