lucy-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nwelln...@apache.org
Subject [lucy-commits] git commit: refs/heads/master - Tighten declaration modifier checks
Date Tue, 02 Jul 2013 16:10:00 GMT
Updated Branches:
  refs/heads/master 146a6860d -> f74524e6c


Tighten declaration modifier checks


Project: http://git-wip-us.apache.org/repos/asf/lucy/repo
Commit: http://git-wip-us.apache.org/repos/asf/lucy/commit/f74524e6
Tree: http://git-wip-us.apache.org/repos/asf/lucy/tree/f74524e6
Diff: http://git-wip-us.apache.org/repos/asf/lucy/diff/f74524e6

Branch: refs/heads/master
Commit: f74524e6c1fbc4b9e611bae834987937abeb342b
Parents: 146a686
Author: Nick Wellnhofer <wellnhofer@aevum.de>
Authored: Mon Jul 1 21:34:50 2013 +0200
Committer: Nick Wellnhofer <wellnhofer@aevum.de>
Committed: Mon Jul 1 21:34:50 2013 +0200

----------------------------------------------------------------------
 clownfish/compiler/src/CFCParseHeader.y | 37 +++++++++++++++++++---------
 1 file changed, 25 insertions(+), 12 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/lucy/blob/f74524e6/clownfish/compiler/src/CFCParseHeader.y
----------------------------------------------------------------------
diff --git a/clownfish/compiler/src/CFCParseHeader.y b/clownfish/compiler/src/CFCParseHeader.y
index c9f9215..3c4c9c6 100644
--- a/clownfish/compiler/src/CFCParseHeader.y
+++ b/clownfish/compiler/src/CFCParseHeader.y
@@ -34,14 +34,18 @@
 
 static CFCClass*
 S_start_class(CFCParser *state, CFCDocuComment *docucomment, char *exposure,
-              char *declaration_modifier_list, char *class_name,
-              char *class_cnick, char *inheritance) {
+              char *modifiers, char *class_name, char *class_cnick,
+              char *inheritance) {
     CFCFileSpec *file_spec = CFCParser_get_file_spec(state);
     int is_final = false;
     int is_inert = false;
-    if (declaration_modifier_list) {
-        is_final = !!strstr(declaration_modifier_list, "final");
-        is_inert = !!strstr(declaration_modifier_list, "inert");
+    if (modifiers) {
+        /* TODO: Decide how to handle abstract classes. */
+        if (strstr(modifiers, "inline")) {
+            CFCUtil_die("Illegal class modifiers: '%s'", modifiers);
+        }
+        is_final = !!strstr(modifiers, "final");
+        is_inert = !!strstr(modifiers, "inert");
     }
     CFCParser_set_class_name(state, class_name);
     CFCParser_set_class_cnick(state, class_cnick);
@@ -83,8 +87,8 @@ S_new_var(CFCParser *state, char *exposure, char *modifiers, CFCType *type,
 
 static CFCBase*
 S_new_sub(CFCParser *state, CFCDocuComment *docucomment, 
-          char *exposure, char *declaration_modifier_list,
-          CFCType *type, char *name, CFCParamList *param_list) {
+          char *exposure, char *modifiers, CFCType *type, char *name,
+          CFCParamList *param_list) {
     CFCParcel  *parcel      = CFCParser_get_parcel(state);
     const char *class_name  = CFCParser_get_class_name(state);
     const char *class_cnick = CFCParser_get_class_cnick(state);
@@ -94,21 +98,30 @@ S_new_sub(CFCParser *state, CFCDocuComment *docucomment,
     int is_final    = false;
     int is_inline   = false;
     int is_inert    = false;
-    if (declaration_modifier_list) {
-        is_abstract = !!strstr(declaration_modifier_list, "abstract");
-        is_final    = !!strstr(declaration_modifier_list, "final");
-        is_inline   = !!strstr(declaration_modifier_list, "inline");
-        is_inert    = !!strstr(declaration_modifier_list, "inert");
+    if (modifiers) {
+        is_abstract = !!strstr(modifiers, "abstract");
+        is_final    = !!strstr(modifiers, "final");
+        is_inline   = !!strstr(modifiers, "inline");
+        is_inert    = !!strstr(modifiers, "inert");
     }
 
     /* If "inert", it's a function, otherwise it's a method. */
     CFCBase *sub;
     if (is_inert) {
+        if (is_abstract) {
+            CFCUtil_die("Inert functions must not be abstract");
+        }
+        if (is_final) {
+            CFCUtil_die("Inert functions must not be final");
+        }
         sub = (CFCBase*)CFCFunction_new(parcel, exposure, class_name,
                                          class_cnick, name, type, param_list,
                                          docucomment, is_inline);
     }
     else {
+        if (is_inline) {
+            CFCUtil_die("Methods must not be inline");
+        }
         sub = (CFCBase*)CFCMethod_new(parcel, exposure, class_name,
                                        class_cnick, name, type, param_list,
                                        docucomment, is_final, is_abstract);


Mime
View raw message