From: Samuele P. <ped...@us...> - 2001-03-11 16:27:39
|
Update of /cvsroot/jython/jython/org/python/compiler In directory usw-pr-cvs1:/tmp/cvs-serv25893 Modified Files: ScopeConstants.java ScopeInfo.java Log Message: nested scopes: consistent classdef&global handling Index: ScopeConstants.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/compiler/ScopeConstants.java,v retrieving revision 2.1 retrieving revision 2.2 diff -C2 -r2.1 -r2.2 *** ScopeConstants.java 2001/03/08 23:43:51 2.1 --- ScopeConstants.java 2001/03/11 16:29:31 2.2 *************** *** 4,12 **** public final static int BOUND = 1; ! public final static int GLOBAL = 2; public final static int PARAM = 4; public final static int FROM_PARAM = 8; public final static int CELL = 16; public final static int FREE = 32; public final static int TOPSCOPE = 0; --- 4,14 ---- public final static int BOUND = 1; ! public final static int NGLOBAL = 2; // func scope expl global public final static int PARAM = 4; public final static int FROM_PARAM = 8; public final static int CELL = 16; public final static int FREE = 32; + public final static int CLASS_GLOBAL = 64; // class scope expl global + public final static int GLOBAL = NGLOBAL|CLASS_GLOBAL; // all global public final static int TOPSCOPE = 0; Index: ScopeInfo.java =================================================================== RCS file: /cvsroot/jython/jython/org/python/compiler/ScopeInfo.java,v retrieving revision 2.1 retrieving revision 2.2 diff -C2 -r2.1 -r2.2 *** ScopeInfo.java 2001/03/08 23:43:51 2.1 --- ScopeInfo.java 2001/03/11 16:29:31 2.2 *************** *** 23,27 **** System.err.print(name); if ((flags&BOUND) != 0) System.err.print('='); ! if ((flags&GLOBAL) != 0) System.err.print('G'); if ((flags&PARAM) != 0) System.err.print('P'); else if ((flags&FROM_PARAM) != 0) System.err.print('p'); --- 23,28 ---- System.err.print(name); if ((flags&BOUND) != 0) System.err.print('='); ! if ((flags&NGLOBAL) != 0) System.err.print('G'); else // func scope global (affect nested scopes) ! if ((flags&CLASS_GLOBAL) != 0) System.err.print('g'); // vs. class scope global if ((flags&PARAM) != 0) System.err.print('P'); else if ((flags&FROM_PARAM) != 0) System.err.print('p'); *************** *** 56,66 **** public int addGlobal(String name) { SymInfo info = (SymInfo)tbl.get(name); if (info == null) { ! tbl.put(name,new SymInfo(GLOBAL|BOUND)); return -1; } int prev = info.flags; ! info.flags |= GLOBAL|BOUND; return prev; } --- 57,68 ---- public int addGlobal(String name) { + int global = kind==CLASSSCOPE?CLASS_GLOBAL:NGLOBAL; // global kind = func vs. class SymInfo info = (SymInfo)tbl.get(name); if (info == null) { ! tbl.put(name,new SymInfo(global|BOUND)); return -1; } int prev = info.flags; ! info.flags |= global|BOUND; return prev; } *************** *** 126,130 **** int flags = info.flags; if (func) { ! if ((flags&GLOBAL) == 0 && (flags&BOUND) != 0) { if (nested_scopes) { info.flags |= CELL; --- 128,132 ---- int flags = info.flags; if (func) { ! if ((flags&NGLOBAL) == 0 && (flags&BOUND) != 0) { // not func global and bound ? if (nested_scopes) { info.flags |= CELL; *************** *** 209,214 **** continue; } ! if (nested && (up_flags&GLOBAL) != 0) { ! info.flags = GLOBAL|BOUND; continue; } --- 211,216 ---- continue; } ! if (nested && (up_flags&NGLOBAL) != 0) { // ! func global affect nested scopes ! info.flags = NGLOBAL|BOUND; continue; } |