static int callinstr(Node **n, NodeList **init, int wr, int skip);
static Node* uintptraddr(Node *n);
static void makeaddable(Node *n);
-static Node* basenod(Node *n);
static void foreach(Node *n, void(*f)(Node*, void*), void *c);
static void hascallspred(Node *n, void *c);
static void appendinit(Node **np, NodeList *init);
default:
fatal("racewalk: unknown node type %O", n->op);
- case OASOP:
case OAS:
- case OAS2:
- case OAS2RECV:
case OAS2FUNC:
- case OAS2MAPR:
racewalknode(&n->left, init, 1, 0);
racewalknode(&n->right, init, 0, 0);
goto ret;
goto ret;
case OEFACE:
- racewalknode(&n->left, init, 0, 0);
+ // n->left is Type* which is not interesting.
racewalknode(&n->right, init, 0, 0);
goto ret;
case OARRAYLIT: // lowered to assignments
case OMAPLIT:
case OSTRUCTLIT:
+ case OAS2:
+ case OAS2RECV:
+ case OAS2MAPR:
+ case OASOP:
yyerror("racewalk: %O must be lowered by now", n->op);
goto ret;
if(isartificial(n))
return 0;
- b = basenod(n);
+ b = outervalue(n);
// it skips e.g. stores to ... parameter array
if(isartificial(b))
return 0;
// that has got a pointer inside. Whether it points to
// the heap or not is impossible to know at compile time
if((class&PHEAP) || class == PPARAMREF || class == PEXTERN
- || b->op == OINDEX || b->op == ODOTPTR || b->op == OIND || b->op == OXDOT) {
+ || b->op == OINDEX || b->op == ODOTPTR || b->op == OIND) {
hascalls = 0;
foreach(n, hascallspred, &hascalls);
if(hascalls) {
return r;
}
-// basenod returns the simplest child node of n pointing to the same
-// memory area.
-static Node*
-basenod(Node *n)
-{
- for(;;) {
- if(n->op == ODOT || n->op == OXDOT || n->op == OCONVNOP || n->op == OCONV || n->op == OPAREN) {
- n = n->left;
- continue;
- }
- if(n->op == OINDEX && isfixedarray(n->type)) {
- n = n->left;
- continue;
- }
- break;
- }
- return n;
-}
-
static Node*
detachexpr(Node *n, NodeList **init)
{
{
Node *defn;
- while(n->op == ODOT || n->op == OPAREN || n->op == OCONVNOP || n->op == OINDEX && isfixedarray(n->left->type))
- n = n->left;
+ n = outervalue(n);
// If n is *autotmp and autotmp = &foo, replace n with foo.
// We introduce such temps when initializing struct literals.
static int
isglobal(Node *n)
{
- while(n->op == ODOT || n->op == OPAREN || n->op == OCONVNOP || n->op == OINDEX && isfixedarray(n->left->type))
- n = n->left;
+ n = outervalue(n);
switch(n->op) {
case ONAME:
outervalue(Node *n)
{
for(;;) {
- if(n->op == ODOT || n->op == OPAREN) {
+ if(n->op == OXDOT)
+ fatal("OXDOT in walk");
+ if(n->op == ODOT || n->op == OPAREN || n->op == OCONVNOP) {
n = n->left;
continue;
}