void oframe(Node *n, Node *res) { char *p; Node *lp; uvlong ival; Frtype *f; p = n->sym->name; while(*p && *p == '$') p++; lp = n->left; if(localaddr(cormap, p, lp->sym->name, &ival, rget) < 0) error("colon: %r"); res->ival = ival; res->op = OCONST; res->fmt = 'A'; res->type = TINT; /* Try and set comt */ for(f = n->sym->local; f; f = f->next) { if(f->var == lp->sym) { res->comt = f->type; res->fmt = 'a'; break; } } }
int sockinetbuf::localhost(char *hostname, size_t hostnameLen) const { hostname[0] = '\0'; sockinetaddr sin (localaddr()); if (sin.family() != af_inet) return -1; return sin.gethostname(hostname, hostnameLen); }
void retcode(Tree p) { Type ty; if (p == NULL) { if (events.returns) apply(events.returns, cfunc, NULL); return; } p = pointer(p); ty = assign(freturn(cfunc->type), p); if (ty == NULL) { error("illegal return type; found `%t' expected `%t'\n", p->type, freturn(cfunc->type)); return; } p = cast(p, ty); if (retv) { if (iscallb(p)) p = tree(RIGHT, p->type, tree(CALL+B, p->type, p->kids[0]->kids[0], idtree(retv)), rvalue(idtree(retv))); else { Type ty = retv->type->type; assert(isstruct(ty)); if (ty->u.sym->u.s.cfields) { ty->u.sym->u.s.cfields = 0; p = asgntree(ASGN, rvalue(idtree(retv)), p); ty->u.sym->u.s.cfields = 1; } else p = asgntree(ASGN, rvalue(idtree(retv)), p); } walk(p, 0, 0); if (events.returns) apply(events.returns, cfunc, rvalue(idtree(retv))); return; } if (events.returns) { Symbol t1 = genident(AUTO, p->type, level); addlocal(t1); walk(asgn(t1, p), 0, 0); apply(events.returns, cfunc, idtree(t1)); p = idtree(t1); } if (!isfloat(p->type)) p = cast(p, promote(p->type)); if (isptr(p->type)) { Symbol q = localaddr(p); if (q && (q->computed || q->generated)) warning("pointer to a %s is an illegal return value\n", q->scope == PARAM ? "parameter" : "local"); else if (q) warning("pointer to %s `%s' is an illegal return value\n", q->scope == PARAM ? "parameter" : "local", q->name); } walk(tree(mkop(RET,p->type), p->type, p, NULL), 0, 0); }
item(int a) { /* name [ . local ] | number | . | ^ | <register | 'x | | */ char *base; char savc; uvlong e; Symbol s; char gsym[MAXSYM], lsym[MAXSYM]; readchar(); if (isfileref()) { readfname(gsym); rdc(); /* skip white space */ if (lastc == ':') { /* it better be */ rdc(); /* skip white space */ if (!getnum(readchar)) error("bad number"); if (expv == 0) expv = 1; /* file begins at line 1 */ expv = file2pc(gsym, expv); if (expv == -1) error("%r"); return 1; } error("bad file location"); } else if (symchar(0)) { readsym(gsym); if (lastc=='.') { readchar(); /* ugh */ if (lastc == '.') { lsym[0] = '.'; readchar(); readsym(lsym+1); } else if (symchar(0)) { readsym(lsym); } else lsym[0] = 0; if (localaddr(cormap, gsym, lsym, &e, rget) < 0) error("%r"); expv = e; } else { if (lookup(0, gsym, &s) == 0) error("symbol not found"); expv = s.value; } reread(); } else if (getnum(readchar)) { ; } else if (lastc=='.') { readchar(); if (!symchar(0) && lastc != '.') { expv = dot; } else { if (findsym(rget(cormap, mach->pc), CTEXT, &s) == 0) error("no current function"); if (lastc == '.') { lsym[0] = '.'; readchar(); readsym(lsym+1); } else readsym(lsym); if (localaddr(cormap, s.name, lsym, &e, rget) < 0) error("%r"); expv = e; } reread(); } else if (lastc=='"') { expv=ditto; } else if (lastc=='+') { expv=inkdot(dotinc); } else if (lastc=='^') { expv=inkdot(-dotinc); } else if (lastc=='<') { savc=rdc(); base = regname(savc); expv = rget(cormap, base); } else if (lastc=='\'') expv = ascval(); else if (a) error("address expected"); else { reread(); return(0); } return(1); }
int sockinetbuf::localport() const { sockinetaddr sin (localaddr()); if (sin.family() != af_inet) return -1; return sin.getport(); }