Annotation of 43BSDTahoe/ucb/pascal/pdx/tree/assign.c, revision 1.1

1.1     ! root        1: /*
        !             2:  * Copyright (c) 1980 Regents of the University of California.
        !             3:  * All rights reserved.  The Berkeley software License Agreement
        !             4:  * specifies the terms and conditions for redistribution.
        !             5:  */
        !             6: 
        !             7: #ifndef lint
        !             8: static char sccsid[] = "@(#)assign.c   5.2 (Berkeley) 4/7/87";
        !             9: #endif not lint
        !            10: 
        !            11: /*
        !            12:  * assign the value of an expression to a variable (or term)
        !            13:  */
        !            14: 
        !            15: #include "defs.h"
        !            16: #include "tree.h"
        !            17: #include "sym.h"
        !            18: #include "process.h"
        !            19: #include "tree.rep"
        !            20: #include "process/process.rep"
        !            21: #include "process/pxinfo.h"
        !            22: 
        !            23: assign(var, exp)
        !            24: NODE *var;
        !            25: NODE *exp;
        !            26: {
        !            27:        ADDRESS addr;
        !            28:        int varsize;
        !            29:        char cvalue;
        !            30:        short svalue;
        !            31:        long lvalue;
        !            32: 
        !            33:        if (!compatible(var->nodetype, exp->nodetype)) {
        !            34:                error("incompatible types");
        !            35:        }
        !            36:        addr = lval(var);
        !            37:        eval(exp);
        !            38:        varsize = size(var->nodetype);
        !            39:        if (varsize < sizeof(long)) {
        !            40:                lvalue = pop(long);
        !            41:                switch (varsize) {
        !            42:                        case sizeof(char):
        !            43:                                cvalue = lvalue;
        !            44:                                dwrite(&cvalue, addr, varsize);
        !            45:                                break;
        !            46: 
        !            47:                        case sizeof(short):
        !            48:                                svalue = lvalue;
        !            49:                                dwrite(&svalue, addr, varsize);
        !            50:                                break;
        !            51: 
        !            52:                        default:
        !            53:                                goto othersize;
        !            54:                                /*
        !            55:                                panic("bad size %d", varsize);
        !            56:                                */
        !            57:                }
        !            58:        } else {
        !            59:            othersize:
        !            60:                sp -= varsize;
        !            61:                dwrite(sp, addr, varsize);
        !            62: #ifdef tahoe
        !            63:                downalignstack();
        !            64: #endif
        !            65:        }
        !            66: }

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.