~ubuntu-branches/ubuntu/vivid/golang/vivid

« back to all changes in this revision

Viewing changes to src/cmd/8g/gsubr.c

  • Committer: Package Import Robot
  • Author(s): Serge Hallyn
  • Date: 2014-11-18 15:12:26 UTC
  • mfrom: (14.2.12 vivid-proposed)
  • Revision ID: package-import@ubuntu.com-20141118151226-zug7vn93mn3dtiz3
Tags: 2:1.3.2-1ubuntu1
* Merge from Debian unstable.  Remaining changes:
  - 016-armhf-elf-header.patch: Use correct ELF header for armhf binaries.
  - Support co-installability with gccgo-go tool:
    - d/rules,golang-go.install: Rename bin/go -> bin/golang-go
    - d/golang-go.{postinst,prerm}: Install/remove /usr/bin/go using
      alternatives.
  - d/copyright: Amendments for full compiliance with copyright format.
  - d/control: Demote golang-go.tools to Suggests to support Ubuntu MIR.
  - dropped patches (now upstream):
    - d/p/issue27650045_40001_50001.diff
    - d/p/issue28050043_60001_70001.diff
    - d/p/issue54790044_100001_110001.diff

Show diffs side-by-side

added added

removed removed

Lines of Context:
48
48
        p->from.index = D_NONE;
49
49
        p->to.type = D_NONE;
50
50
        p->to.index = D_NONE;
51
 
        p->loc = pcloc;
 
51
        p->pc = pcloc;
52
52
        pcloc++;
53
53
}
54
54
 
137
137
        if(p->to.type != D_BRANCH)
138
138
                fatal("patch: not a branch");
139
139
        p->to.u.branch = to;
140
 
        p->to.offset = to->loc;
 
140
        p->to.offset = to->pc;
141
141
}
142
142
 
143
143
Prog*
161
161
{
162
162
        Plist *pl;
163
163
 
164
 
        pl = mal(sizeof(*pl));
165
 
        if(plist == nil)
166
 
                plist = pl;
167
 
        else
168
 
                plast->link = pl;
169
 
        plast = pl;
170
 
 
 
164
        pl = linknewplist(ctxt);
 
165
        
171
166
        pc = mal(sizeof(*pc));
172
167
        clearp(pc);
173
168
        pl->firstpc = pc;
199
194
 
200
195
        p = gins(AGLOBL, nam, N);
201
196
        p->lineno = nam->lineno;
202
 
        p->from.gotype = ngotype(nam);
203
 
        p->to.sym = S;
 
197
        p->from.sym->gotype = linksym(ngotype(nam));
 
198
        p->to.sym = nil;
204
199
        p->to.type = D_CONST;
205
200
        p->to.offset = nam->type->width;
206
201
        if(nam->readonly)
227
222
        p = gins(AGLOBL, N, N);
228
223
        p->from.type = D_EXTERN;
229
224
        p->from.index = D_NONE;
230
 
        p->from.sym = s;
 
225
        p->from.sym = linksym(s);
231
226
        p->to.type = D_CONST;
232
227
        p->to.index = D_NONE;
233
228
        p->to.offset = width;
245
240
        p = gins(AUSEFIELD, N, N);
246
241
        p->from.type = D_EXTERN;
247
242
        p->from.index = D_NONE;
248
 
        p->from.sym = s;
 
243
        p->from.sym = linksym(s);
249
244
}
250
245
 
251
246
int
273
268
        if(a->type == D_ADDR && a->index == D_EXTERN) {
274
269
                a->type = D_EXTERN;
275
270
                a->index = D_NONE;
276
 
                a->sym = n->sym;
 
271
                a->sym = linksym(n->sym);
277
272
        }
278
273
}
279
274
 
437
432
        case CASE(OADD, TINT32):
438
433
        case CASE(OADD, TUINT32):
439
434
        case CASE(OADD, TPTR32):
 
435
        case CASE(OADDPTR, TPTR32):
440
436
                a = AADDL;
441
437
                break;
442
438
 
1048
1044
nodarg(Type *t, int fp)
1049
1045
{
1050
1046
        Node *n;
 
1047
        NodeList *l;
1051
1048
        Type *first;
1052
1049
        Iter savet;
1053
1050
 
1072
1069
                break;
1073
1070
 
1074
1071
        case TFIELD:
 
1072
                if(fp == 1 && t->sym != S && !isblanksym(t->sym)) {
 
1073
                        for(l=curfn->dcl; l; l=l->next) {
 
1074
                                n = l->n;
 
1075
                                if((n->class == PPARAM || n->class == PPARAMOUT) && n->sym == t->sym)
 
1076
                                        return n;
 
1077
                        }
 
1078
                }
 
1079
 
1075
1080
                n = nod(ONAME, N, N);
1076
1081
                n->type = t->type;
1077
1082
                n->sym = t->sym;
1692
1697
                gins(ACMPL, &thi, ncon(0));
1693
1698
                p1 = gbranch(AJLT, T, 0);
1694
1699
                // native
1695
 
                t1.type = types[TINT64];
1696
1700
                nodreg(&r1, types[tt], D_F0);
1697
1701
                gins(AFMOVV, &t1, &r1);
1698
1702
                if(tt == TFLOAT32)
2178
2182
void
2179
2183
naddr(Node *n, Addr *a, int canemitcode)
2180
2184
{
 
2185
        Sym *s;
 
2186
 
2181
2187
        a->scale = 0;
2182
2188
        a->index = D_NONE;
2183
2189
        a->type = D_NONE;
2184
 
        a->gotype = S;
 
2190
        a->gotype = nil;
2185
2191
        a->node = N;
2186
2192
        if(n == N)
2187
2193
                return;
2193
2199
 
2194
2200
        case OREGISTER:
2195
2201
                a->type = n->val.u.reg;
2196
 
                a->sym = S;
 
2202
                a->sym = nil;
2197
2203
                break;
2198
2204
 
2199
2205
        case OINDREG:
2200
2206
                a->type = n->val.u.reg+D_INDIR;
2201
 
                a->sym = n->sym;
 
2207
                a->sym = linksym(n->sym);
2202
2208
                a->offset = n->xoffset;
2203
2209
                break;
2204
2210
 
2208
2214
                a->etype = n->left->type->etype;
2209
2215
                a->width = n->left->type->width;
2210
2216
                a->offset = n->xoffset;
2211
 
                a->sym = n->left->sym;
 
2217
                a->sym = linksym(n->left->sym);
2212
2218
                a->type = D_PARAM;
2213
2219
                a->node = n->left->orig;
2214
2220
                break;
2215
2221
 
2216
2222
        case OCLOSUREVAR:
 
2223
                if(!curfn->needctxt)
 
2224
                        fatal("closurevar without needctxt");
2217
2225
                a->type = D_DX+D_INDIR;
2218
2226
                a->offset = n->xoffset;
2219
 
                a->sym = S;
 
2227
                a->sym = nil;
2220
2228
                break;
2221
2229
 
2222
2230
        case OCFUNC:
2223
2231
                naddr(n->left, a, canemitcode);
2224
 
                a->sym = n->left->sym;
 
2232
                a->sym = linksym(n->left->sym);
2225
2233
                break;
2226
2234
 
2227
2235
        case ONAME:
2233
2241
                        a->width = n->type->width;
2234
2242
                }
2235
2243
                a->offset = n->xoffset;
2236
 
                a->sym = n->sym;
 
2244
                s = n->sym;
2237
2245
                a->node = n->orig;
2238
2246
                //if(a->node >= (Node*)&n)
2239
2247
                //      fatal("stack node");
2240
 
                if(a->sym == S)
2241
 
                        a->sym = lookup(".noname");
 
2248
                if(s == S)
 
2249
                        s = lookup(".noname");
2242
2250
                if(n->method) {
2243
2251
                        if(n->type != T)
2244
2252
                        if(n->type->sym != S)
2245
2253
                        if(n->type->sym->pkg != nil)
2246
 
                                a->sym = pkglookup(a->sym->name, n->type->sym->pkg);
 
2254
                                s = pkglookup(s->name, n->type->sym->pkg);
2247
2255
                }
2248
2256
 
2249
2257
                switch(n->class) {
2262
2270
                case PFUNC:
2263
2271
                        a->index = D_EXTERN;
2264
2272
                        a->type = D_ADDR;
2265
 
                        a->sym = funcsym(a->sym);
 
2273
                        s = funcsym(s);
2266
2274
                        break;
2267
2275
                }
 
2276
                a->sym = linksym(s);
2268
2277
                break;
2269
2278
 
2270
2279
        case OLITERAL:
2278
2287
                        break;
2279
2288
                case CTINT:
2280
2289
                case CTRUNE:
2281
 
                        a->sym = S;
 
2290
                        a->sym = nil;
2282
2291
                        a->type = D_CONST;
2283
2292
                        a->offset = mpgetfix(n->val.u.xval);
2284
2293
                        break;
2286
2295
                        datagostring(n->val.u.sval, a);
2287
2296
                        break;
2288
2297
                case CTBOOL:
2289
 
                        a->sym = S;
 
2298
                        a->sym = nil;
2290
2299
                        a->type = D_CONST;
2291
2300
                        a->offset = n->val.u.bval;
2292
2301
                        break;
2293
2302
                case CTNIL:
2294
 
                        a->sym = S;
 
2303
                        a->sym = nil;
2295
2304
                        a->type = D_CONST;
2296
2305
                        a->offset = 0;
2297
2306
                        break;
2327
2336
                naddr(n->left, a, canemitcode);
2328
2337
                if(a->type == D_CONST && a->offset == 0)
2329
2338
                        break;  // ptr(nil)
2330
 
                a->etype = simtype[TUINTPTR];
 
2339
                a->etype = simtype[tptr];
2331
2340
                a->offset += Array_array;
2332
2341
                a->width = widthptr;
2333
2342
                break;