|
|
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.1 (Berkeley) 6/6/85"; ! 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: ! 21: assign(var, exp) ! 22: NODE *var; ! 23: NODE *exp; ! 24: { ! 25: ADDRESS addr; ! 26: int varsize; ! 27: char cvalue; ! 28: short svalue; ! 29: long lvalue; ! 30: ! 31: if (!compatible(var->nodetype, exp->nodetype)) { ! 32: error("incompatible types"); ! 33: } ! 34: addr = lval(var); ! 35: eval(exp); ! 36: varsize = size(var->nodetype); ! 37: if (varsize < sizeof(long)) { ! 38: lvalue = pop(long); ! 39: switch (varsize) { ! 40: case sizeof(char): ! 41: cvalue = lvalue; ! 42: dwrite(&cvalue, addr, varsize); ! 43: break; ! 44: ! 45: case sizeof(short): ! 46: svalue = lvalue; ! 47: dwrite(&svalue, addr, varsize); ! 48: break; ! 49: ! 50: default: ! 51: panic("bad size %d", varsize); ! 52: } ! 53: } else { ! 54: sp -= varsize; ! 55: dwrite(sp, addr, varsize); ! 56: } ! 57: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.