2N/A * The contents of this file are subject to the terms of the 2N/A * Common Development and Distribution License, Version 1.0 only 2N/A * (the "License"). You may not use this file except in compliance 2N/A * See the License for the specific language governing permissions 2N/A * and limitations under the License. 2N/A * When distributing Covered Code, include this CDDL HEADER in each 2N/A * If applicable, add the following below this CDDL HEADER, with the 2N/A * fields enclosed by brackets "[]" replaced with your own identifying 2N/A * information: Portions Copyright [yyyy] [name of copyright owner] 2N/A * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 2N/A * Use is subject to license terms. 2N/A#
pragma ident "%Z%%M% %I% %E% SMI" 2N/A * DTrace Parsing Control Block 2N/A * A DTrace Parsing Control Block (PCB) contains all of the state that is used 2N/A * by a single pass of the D compiler, other than the global variables used by 2N/A * lex and yacc. The routines in this file are used to set up and tear down 2N/A * PCBs, which are kept on a stack pointed to by the libdtrace global 'yypcb'. 2N/A * The main engine of the compiler, dt_compile(), is located in dt_cc.c and is 2N/A * responsible for calling these routines to begin and end a compilation pass. 2N/A * Sun's lex/yacc are not MT-safe or re-entrant, but we permit limited nested 2N/A * use of dt_compile() once the entire parse tree has been constructed but has 2N/A * not yet executed the "cooking" pass (see dt_cc.c for more information). The 2N/A * PCB design also makes it easier to debug (since all global state is kept in 2N/A * one place) and could permit us to make the D compiler MT-safe or re-entrant 2N/A * in the future by adding locks to libdtrace or switching to Flex and Bison. 2N/A * Initialize the specified PCB by zeroing it and filling in a few default 2N/A * members, and then pushing it on to the top of the PCB stack and setting 2N/A * yypcb to point to it. Increment the current handle's generation count. 2N/A * Since lex/yacc are not re-entrant and we don't implement state save, 2N/A * assert that if another PCB is active, it is from the same handle and 2N/A * has completed execution of yyparse(). If the first assertion fires, 2N/A * the caller is calling libdtrace without proper MT locking. If the 2N/A * second assertion fires, dt_compile() is being called recursively 2N/A * from an illegal location in libdtrace, or a dt_pcb_pop() is missing. 2N/A * Pop the topmost PCB from the PCB stack and destroy any data structures that 2N/A * are associated with it. If 'err' is non-zero, destroy any intermediate 2N/A * state that is left behind as part of a compilation that has failed.