]> Cypherpunks repositories - gostls13.git/commitdiff
gc: add GOEXPERIMENT=reorg
authorRuss Cox <rsc@golang.org>
Wed, 9 Nov 2011 17:35:45 +0000 (12:35 -0500)
committerRuss Cox <rsc@golang.org>
Wed, 9 Nov 2011 17:35:45 +0000 (12:35 -0500)
This won't last long but may ease conversions.

R=ken2
CC=golang-dev
https://golang.org/cl/5375043

src/cmd/gc/go.h
src/cmd/gc/lex.c

index faae7bd9eabd84ef67e5406d6e571beae85954ce..266cc8597d8925e7f1d807728e72a7f73431e8e4 100644 (file)
@@ -852,6 +852,7 @@ EXTERN      int     typecheckok;
 EXTERN int     compiling_runtime;
 
 EXTERN int     rune32;
+EXTERN int     reorg;
 
 /*
  *     y.tab.c
index b1eab441c3d1bde4aa626ce10b19b17e0e86f67c..a07232d1bdb160adef6e35a94c673e9941206f3f 100644 (file)
@@ -18,6 +18,8 @@ int windows;
 int yyprev;
 int yylast;
 
+Strlit *reorgpath(Strlit*);
+
 static void    lexinit(void);
 static void    lexinit1(void);
 static void    lexfini(void);
@@ -38,6 +40,7 @@ static struct {
        int *val;
 } exper[] = {
        {"rune32", &rune32},
+       {"reorg", &reorg},
 };
 
 static void
@@ -537,6 +540,9 @@ importfile(Val *f, int line)
                yyerror("import path contains NUL");
                errorexit();
        }
+       
+       if(reorg)
+               f->u.sval = reorgpath(f->u.sval);
 
        // The package name main is no longer reserved,
        // but we reserve the import path "main" to identify
@@ -2115,3 +2121,47 @@ mkpackage(char* pkgname)
                outfile = smprint("%s.%c", namebuf, thechar);
        }
 }
+
+static struct {
+       char *old;
+       char *xnew;
+} reorgtab[] = {
+       {"asn1", "encoding/asn1"},
+       {"big", "math/big"},
+       {"cmath", "math/cmplx"},
+       {"csv", "encoding/csv"},
+       {"exec", "os/exec"},
+       {"exp/template/html", "html/template"},
+       {"gob", "encoding/gob"},
+       {"http", "net/http"},
+       {"http/cgi", "net/http/cgi"},
+       {"http/fcgi", "net/http/fcgi"},
+       {"http/httptest", "net/http/httptest"},
+       {"http/pprof", "net/http/pprof"},
+       {"json", "encoding/json"},
+       {"mail", "net/mail"},
+       {"rpc", "net/rpc"},
+       {"rpc/jsonrpc", "net/rpc/jsonrpc"},
+       {"scanner", "text/scanner"},
+       {"smtp", "net/smtp"},
+       {"syslog", "log/syslog"},
+       {"tabwriter", "text/tabwriter"},
+       {"template", "text/template"},
+       {"template/parse", "text/template/parse"},
+       {"rand", "math/rand"},
+       {"url", "net/url"},
+       {"utf16", "unicode/utf16"},
+       {"utf8", "unicode/utf8"},
+       {"xml", "encoding/xml"},
+};
+
+Strlit*
+reorgpath(Strlit *s)
+{
+       int i;
+
+       for(i=0; i < nelem(reorgtab); i++)
+               if(strcmp(s->s, reorgtab[i].old) == 0)
+                       return strlit(reorgtab[i].xnew);
+       return s;
+}