]> err.no Git - varnish/commitdiff
Make vcl methods call their defaults as a last resort.
authorphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Sat, 5 Aug 2006 18:11:31 +0000 (18:11 +0000)
committerphk <phk@d4fa192b-c00b-0410-8231-f00ffab90ce4>
Sat, 5 Aug 2006 18:11:31 +0000 (18:11 +0000)
Fix the location table so it knows about the default code too.

git-svn-id: svn+ssh://projects.linpro.no/svn/varnish/trunk@682 d4fa192b-c00b-0410-8231-f00ffab90ce4

varnish-cache/include/vcl.h
varnish-cache/include/vcl_returns.h
varnish-cache/include/vrt.h
varnish-cache/lib/libvcl/vcc_compile.c
varnish-cache/lib/libvcl/vcc_fixed_token.c

index 67a53dc4db1fa9d427331650fb6d9d50afd08bb0..fa281c26c654068eefc7133af1bd89751e781962 100644 (file)
@@ -22,7 +22,7 @@ struct VCL_conf {
         unsigned        nref;
         unsigned        busy;
 
-       void            *priv;
+        void            *priv;
 
         vcl_init_f      *init_func;
         vcl_fini_f      *fini_func;
index ef965c1ba5b2de0819c784a996977ed8e11c54db..b1814abe339b3ee530361bb0cf8a5a31f7fa1c20 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * $Id: vcc_gen_fixed_token.tcl 556 2006-07-22 09:38:09Z phk $
+ * $Id: vcc_gen_fixed_token.tcl 638 2006-08-04 10:54:30Z phk $
  *
  * NB:  This file is machine generated, DO NOT EDIT!
  *
index 7b50770315f9e17840ff4a43aaa19b4530b79434..71a32838f80498bc39139aaf6ee004aa8a094ca8 100644 (file)
@@ -3,7 +3,7 @@
  *
  * Runtime support for compiled VCL programs.
  *
- * XXX: When this file is changed, lib/libvcl/vcl_gen_fixed_token.tcl
+ * XXX: When this file is changed, lib/libvcl/vcc_gen_fixed_token.tcl
  * XXX: *MUST* be rerun.
  */
 
@@ -13,6 +13,7 @@ struct backend;
 struct VCL_conf;
 
 struct vrt_ref {
+       unsigned        file;
        unsigned        line;
        unsigned        pos;
        unsigned        count;
index 66898cb9bc9c47e556942a3277aed0e2c5de2f2d..2fca8e96cb1114c86354df1c5726df660d4936d2 100644 (file)
@@ -190,6 +190,21 @@ EncString(struct token *t)
        return (p);
 }
 
+/*--------------------------------------------------------------------*/
+
+static int
+IsMethod(struct token *t)
+{
+       struct method *m;
+
+       for(m = method_tab; m->name != NULL; m++) {
+               if (vcc_IdIs(t, m->defname))
+                       return (2);
+               if (vcc_IdIs(t, m->name))
+                       return (1);
+       }
+       return (0);
+}
 
 /*--------------------------------------------------------------------
  * Keep track of definitions and references
@@ -997,17 +1012,26 @@ Backend(struct tokenlist *tl)
 static void
 Function(struct tokenlist *tl)
 {
+       struct token *tn;
 
        vcc_NextToken(tl);
        ExpectErr(tl, ID);
        tl->curproc = AddProc(tl, tl->t, 1);
        tl->curproc->exists++;
+       tn = tl->t;
        AddDef(tl, tl->t, R_FUNC);
        Fh(tl, 0, "static int VGC_function_%T (struct sess *sp);\n", tl->t);
        Fc(tl, 1, "static int\n");
        Fc(tl, 1, "VGC_function_%T (struct sess *sp)\n", tl->t);
        vcc_NextToken(tl);
+       tl->indent += INDENT;
+       Fc(tl, 1, "{\n");
        L(tl, Compound(tl));
+       if (IsMethod(tn) == 1) {
+               Fc(tl, 1, "VGC_function_default_%T(sp);\n", tn);
+       }
+       Fc(tl, 1, "}\n");
+       tl->indent -= INDENT;
        Fc(tl, 0, "\n");
 }
 
@@ -1221,19 +1245,26 @@ static void
 LocTable(struct tokenlist *tl)
 {
        struct token *t;
-       unsigned lin, pos;
+       unsigned fil, lin, pos;
        const char *p;
        
        Fh(tl, 0, "#define VGC_NREFS %u\n", tl->cnt + 1);
        Fh(tl, 0, "static struct vrt_ref VGC_ref[VGC_NREFS];\n");
        Fc(tl, 0, "static struct vrt_ref VGC_ref[VGC_NREFS] = {\n");
+       fil = 0;
        lin = 1;
        pos = 0;
-       p = tl->b;
+       p = vcc_default_vcl_b;
        TAILQ_FOREACH(t, &tl->tokens, list) {
                if (t->cnt == 0)
                        continue;
                for (;p < t->b; p++) {
+                       if (p == vcc_default_vcl_e) {
+                               p = tl->b;
+                               fil = 1;
+                               lin = 1;
+                               pos = 0;
+                       }
                        if (*p == '\n') {
                                lin++;
                                pos = 0;
@@ -1244,8 +1275,8 @@ LocTable(struct tokenlist *tl)
                                pos++;
                
                }
-               Fc(tl, 0, "  [%3u] = { %4u, %3u, 0, \"%T\" },\n",
-                   t->cnt, lin, pos + 1, t);
+               Fc(tl, 0, "  [%3u] = { %d, %4u, %3u, 0, \"%T\" },\n",
+                   t->cnt, fil, lin, pos + 1, t);
        }
        Fc(tl, 0, "};\n");
 }
@@ -1341,8 +1372,8 @@ VCC_Compile(struct sbuf *sb, const char *b, const char *e)
                e = strchr(b, '\0');
        assert(e != NULL);
        tokens.e = e;
-       vcc_Lexer(&tokens, b, e);
        vcc_Lexer(&tokens, vcc_default_vcl_b, vcc_default_vcl_e);
+       vcc_Lexer(&tokens, b, e);
        vcc_AddToken(&tokens, EOI, e, e);
        if (tokens.err)
                goto done;
index fb254bcafa71b2feaac03c3b7d6db6e0bebb8589..1777c6e8801be35501bc86eb263af1cc2b49ab97 100644 (file)
@@ -455,7 +455,7 @@ vcl_output_lang_h(FILE *f)
        fputs("        unsigned        nref;\n", f);
        fputs("        unsigned        busy;\n", f);
        fputs("\n", f);
-       fputs(" void            *priv;\n", f);
+       fputs("        void            *priv;\n", f);
        fputs("\n", f);
        fputs("        vcl_init_f      *init_func;\n", f);
        fputs("        vcl_fini_f      *fini_func;\n", f);
@@ -471,7 +471,7 @@ vcl_output_lang_h(FILE *f)
        fputs(" *\n", f);
        fputs(" * Runtime support for compiled VCL programs.\n", f);
        fputs(" *\n", f);
-       fputs(" * XXX: When this file is changed, lib/libvcl/vcl_gen_fixed_token.tcl\n", f);
+       fputs(" * XXX: When this file is changed, lib/libvcl/vcc_gen_fixed_token.tcl\n", f);
        fputs(" * XXX: *MUST* be rerun.\n", f);
        fputs(" */\n", f);
        fputs("\n", f);
@@ -481,6 +481,7 @@ vcl_output_lang_h(FILE *f)
        fputs("struct VCL_conf;\n", f);
        fputs("\n", f);
        fputs("struct vrt_ref {\n", f);
+       fputs(" unsigned        file;\n", f);
        fputs(" unsigned        line;\n", f);
        fputs(" unsigned        pos;\n", f);
        fputs(" unsigned        count;\n", f);