~john-koepi/ubuntu/trusty/golang/default

« back to all changes in this revision

Viewing changes to src/cmd/gc/subr.c

  • Committer: Bazaar Package Importer
  • Author(s): Ondřej Surý
  • Date: 2011-08-03 17:04:59 UTC
  • mfrom: (14.1.2 sid)
  • Revision ID: james.westby@ubuntu.com-20110803170459-wzd99m3567y80ila
Tags: 1:59-1
* Imported Upstream version 59
* Refresh patches to a new release
* Fix FTBFS on ARM (Closes: #634270)
* Update version.bash to work with Debian packaging and not hg
  repository

Show diffs side-by-side

added added

removed removed

Lines of Context:
45
45
        Fmt f;
46
46
        Error *p;
47
47
 
 
48
        erroring++;
48
49
        fmtstrinit(&f);
49
50
        fmtprint(&f, "%L: ", line);
50
51
        fmtvprint(&f, fmt, arg);
51
52
        fmtprint(&f, "\n");
 
53
        erroring--;
52
54
 
53
55
        if(nerr >= merr) {
54
56
                if(merr == 0)
1122
1124
                return 0;
1123
1125
        }
1124
1126
 
1125
 
        if(s->pkg != localpkg || longsymnames || (fp->flags & FmtLong)) {
 
1127
        if(s->pkg && s->pkg != localpkg || longsymnames || (fp->flags & FmtLong)) {
 
1128
                // This one is for the user.  If the package name
 
1129
                // was used by multiple packages, give the full
 
1130
                // import path to disambiguate.
 
1131
                if(erroring && pkglookup(s->pkg->name, nil)->npkg > 1) {
 
1132
                        fmtprint(fp, "\"%Z\".%s", s->pkg->path, s->name);
 
1133
                        return 0;
 
1134
                }
1126
1135
                fmtprint(fp, "%s.%s", s->pkg->name, s->name);
1127
1136
                return 0;
1128
1137
        }
3131
3140
        NodeList *l, *args, *in, *out;
3132
3141
        Type *tpad;
3133
3142
        int isddd;
 
3143
        Val v;
3134
3144
 
3135
 
        if(0 && debug['r'])
 
3145
        if(debug['r'])
3136
3146
                print("genwrapper rcvrtype=%T method=%T newnam=%S\n",
3137
3147
                        rcvr, method, newnam);
3138
3148
 
3174
3184
                args = list(args, l->n->left);
3175
3185
                isddd = l->n->left->isddd;
3176
3186
        }
 
3187
        
 
3188
        // generate nil pointer check for better error
 
3189
        if(isptr[rcvr->etype] && rcvr->type == getthisx(method->type)->type->type) {
 
3190
                // generating wrapper from *T to T.
 
3191
                n = nod(OIF, N, N);
 
3192
                n->ntest = nod(OEQ, this->left, nodnil());
 
3193
                // these strings are already in the reflect tables,
 
3194
                // so no space cost to use them here.
 
3195
                l = nil;
 
3196
                v.ctype = CTSTR;
 
3197
                v.u.sval = strlit(rcvr->type->sym->pkg->name);  // package name
 
3198
                l = list(l, nodlit(v));
 
3199
                v.u.sval = strlit(rcvr->type->sym->name);  // type name
 
3200
                l = list(l, nodlit(v));
 
3201
                v.u.sval = strlit(method->sym->name);
 
3202
                l = list(l, nodlit(v));  // method name
 
3203
                call = nod(OCALL, syslook("panicwrap", 0), N);
 
3204
                call->list = l;
 
3205
                n->nbody = list1(call);
 
3206
                fn->nbody = list(fn->nbody, n);
 
3207
        }
3177
3208
 
3178
3209
        // generate call
3179
3210
        call = nod(OCALL, adddot(nod(OXDOT, this->left, newname(method->sym))), N);
3180
3211
        call->list = args;
3181
3212
        call->isddd = isddd;
3182
 
        fn->nbody = list1(call);
3183
3213
        if(method->type->outtuple > 0) {
3184
3214
                n = nod(ORETURN, N, N);
3185
 
                n->list = fn->nbody;
3186
 
                fn->nbody = list1(n);
 
3215
                n->list = list1(call);
 
3216
                call = n;
3187
3217
        }
 
3218
        fn->nbody = list(fn->nbody, call);
3188
3219
 
3189
3220
        if(0 && debug['r'])
3190
3221
                dumplist("genwrapper body", fn->nbody);