static void createSynthesizedExternVar ( AbstractCompiler compiler , String varName ) { Node nameNode = IR . name ( varName ) ; // Mark the variable as constant if it matches the coding convention // for constant vars. // NOTE(nicksantos): honestly, I'm not sure how much this matters. // AFAIK, all people who use the CONST coding convention also // compile with undeclaredVars as errors. We have some test // cases for this configuration though, and it makes them happier. if ( compiler . getCodingConvention ( ) . isConstant ( varName ) ) { nameNode . putBooleanProp ( Node . IS_CONSTANT_NAME , true ) ; } Node syntheticExternVar = IR . var ( nameNode ) ; getSynthesizedExternsRoot ( compiler ) . addChildToBack ( syntheticExternVar ) ; compiler . reportChangeToEnclosingScope ( syntheticExternVar ) ; }
Create a new variable in a synthetic script . This will prevent subsequent compiler passes from crashing .