package-private for testing
340658
IdBatchAndWaitTime newIdBaseLocal(long now, int nodeId, int batchSize) {
        checkPositive(batchSize, "batchSize");
        if (nodeId == NODE_ID_OUT_OF_RANGE) {
            throw new NodeIdOutOfRangeException("NodeID overflow, this member cannot generate IDs");
        }
        assert (nodeId & -1 << BITS_NODE_ID) == 0  : "nodeId out of range: " + nodeId;
        now -= epochStart;
        if (now < -(1L << BITS_TIMESTAMP) || now >= (1L << BITS_TIMESTAMP)) {
            throw new HazelcastException("Current time out of allowed range");
        }
        now <<= BITS_SEQUENCE;
        long oldGeneratedValue;
        long base;
        do {
            oldGeneratedValue = generatedValue.get();
            base = Math.max(now, oldGeneratedValue);
        } while (!generatedValue.compareAndSet(oldGeneratedValue, base + batchSize));

        long waitTime = Math.max(0, ((base + batchSize - now) >> BITS_SEQUENCE) - ALLOWED_FUTURE_MILLIS);
        base = base << BITS_NODE_ID | nodeId;

        getService().updateStatsForBatch(name, batchSize);
        return new IdBatchAndWaitTime(new IdBatch(base, INCREMENT, batchSize), waitTime);
    }
568974
private Map<String, String> readPrivateConfig(final File privateConfigFile) {
    try {
      return readConfig(privateConfigFile);
    } catch (final Exception ex) {
      return new HashMap<>();
    }
  }
289150
function(context, childPkg){
		var curAddress = childPkg.origFileUrl;
		var parentAddress = utils.path.parentNodeModuleAddress(childPkg.origFileUrl);
		while(parentAddress) {
			var packageAddress = parentAddress+"/"+childPkg.name+"/package.json";
			var parentPkg =	context.paths[packageAddress];
			if(parentPkg && SemVer.valid(parentPkg.version)) {
				if(SemVer.satisfies(parentPkg.version, childPkg.version)) {
					return parentPkg.fileUrl;
				} else {
					return curAddress;
				}
			}
			parentAddress = utils.path.parentNodeModuleAddress(packageAddress);
			curAddress = packageAddress;
		}
		return curAddress;
	}
921002
@VisibleForTesting
  static String packageName(String source) {
    try (StringReader r = new StringReader(source)) {
      StreamTokenizer tokenizer = new StreamTokenizer(r);
      tokenizer.slashSlashComments(true);
      tokenizer.slashStarComments(true);
      StringBuilder sb = new StringBuilder();
      boolean inName = false;
      while (tokenizer.nextToken() != StreamTokenizer.TT_EOF) {
        if (inName) {
          switch (tokenizer.ttype) {
            case ';':
              return sb.length() > 0 ? sb.toString() : null;
            case '.':
              sb.append('.');
              break;
            case StreamTokenizer.TT_WORD:
              sb.append(tokenizer.sval);
              break;
            default:
              inName = false; // Invalid package statement pattern.
              break;
          }
        } else if (tokenizer.ttype == StreamTokenizer.TT_WORD && tokenizer.sval.equals("package")) {
          inName = true;
        }
      }
      return null; // Package statement not found.
    } catch (IOException e) {
      throw new AssertionError("Exception reading string: " + e);
    }
  }
1334494
private void checkAst(Node externs, Node root) {
    astValidator.validateCodeRoot(externs);
    astValidator.validateCodeRoot(root);
  }
743359
private void privateReconfigureLogging(String pkg, final String name) {
    LogManager logManager = LogManager.getLogManager();
    Logger logger = Logger.getLogger(LoggingConfiguration.class.getName());
    // allow null as package name.
    if(pkg == null) {
      pkg = "";
    }
    // Load logging configuration from current directory
    String cfgfile = name;
    if(new File(name).exists()) {
      cfgfile = name;
    }
    else {
      // Fall back to full path / resources.
      cfgfile = pkg.replace('.', File.separatorChar) + File.separatorChar + name;
    }
    try {
      InputStream cfgdata = openSystemFile(cfgfile);
      logManager.readConfiguration(cfgdata);

      // also load as properties for us, to get debug flag.
      InputStream cfgdata2 = openSystemFile(cfgfile);
      Properties cfgprop = new Properties();
      cfgprop.load(cfgdata2);
      DEBUG = Boolean.parseBoolean(cfgprop.getProperty("debug"));

      logger.info("Logging configuration read.");
    }
    catch(FileNotFoundException e) {
      logger.log(Level.SEVERE, "Could not find logging configuration file: " + cfgfile, e);
    }
    catch(Exception e) {
      logger.log(Level.SEVERE, "Failed to configure logging from file: " + cfgfile, e);
    }
  }
124917
private Program compile( Stack<IScriptPartId> scriptPartIdStack, String strCompiledSource, ISymbolTable symbolTable, Map<String, List<IFunctionSymbol>> dfsDeclByName, ITypeUsesMap typeUsesMap, Stack<BlockExpression> blocks, ContextInferenceManager ctxInferenceMgr) throws ParseResultsException
  {
    IGosuParser parser = GosuParserFactory.createParser(symbolTable, ScriptabilityModifiers.SCRIPTABLE);
    for( IScriptPartId id: scriptPartIdStack ) {
      ((GosuParser)parser).pushScriptPart( id );
    }
    parser.setScript( strCompiledSource );
    if(parser instanceof GosuParser) {
      parser.setDfsDeclInSetByName(dfsDeclByName);
      if (ctxInferenceMgr != null) {
        ((GosuParser) parser).setContextInferenceManager(ctxInferenceMgr);
      }
    }
    if (typeUsesMap == null) {
      typeUsesMap = parser.getTypeUsesMap();
    } else {
      parser.setTypeUsesMap(typeUsesMap);
    }
    if(_fqn != null) {
      typeUsesMap.addToTypeUses(GosuClassUtil.getPackage(_fqn) + ".*");
    }
    if( blocks != null )
    {
      ((GosuParser) parser).setBlocks( blocks );
    }
    if(_supertype != null && _supertype instanceof IGosuClassInternal ) {
      IGosuClassInternal supertype = (IGosuClassInternal) _supertype;
      addStaticSymbols(symbolTable, (GosuParser) parser, supertype);

      List<? extends GosuClassTypeLoader> typeLoaders = TypeSystem.getCurrentModule().getTypeLoaders(GosuClassTypeLoader.class);
      for (GosuClassTypeLoader typeLoader : typeLoaders) {
        List<? extends IGosuEnhancement> enhancementsForType = typeLoader.getEnhancementIndex().getEnhancementsForType(supertype);
        for (IGosuEnhancement enhancement : enhancementsForType) {
          if (enhancement instanceof IGosuEnhancementInternal) {
            addStaticSymbols(symbolTable, (GosuParser) parser, (IGosuEnhancementInternal) enhancement);
          }
        }
      }

      // clear out private DFS that may have made their way into the dfsDecldsByName (jove this is ugly)
      for (Entry<String, List<IFunctionSymbol>> dfsDecls : parser.getDfsDecls().entrySet()) {
        for (Iterator<IFunctionSymbol> it = dfsDecls.getValue().iterator(); it.hasNext(); ) {
          IFunctionSymbol fs = it.next();
          if (fs instanceof Symbol && fs.isPrivate()) {
            it.remove();
          }
        }
      }
    }
    IScriptPartId scriptPart;
    ISymbol thisSymbol = symbolTable.getSymbol( Keyword.KW_this.getName() );
    if( thisSymbol != null && thisSymbol.getType() instanceof IGosuClass )
    {
      scriptPart = new ScriptPartId( thisSymbol.getType(), GS_TEMPLATE_PARSED );
    }
    else
    {
      scriptPart = new TypelessScriptPartId( GS_TEMPLATE_PARSED );
    }
    Program program = (Program)parser.parseProgram( scriptPart, null, null, true );
    program.clearParseTreeInformation();
    return program;
  }
873159
@Override
    public void visitClassContext(ClassContext classContext) {
        try {
            stack = new OpcodeStack();
            toStringRegisters = new HashMap<>();
            packageName = classContext.getJavaClass().getPackageName();
            super.visitClassContext(classContext);
        } finally {
            stack = null;
            toStringRegisters = null;
        }
    }
1118017
function templateNodeTransformation( $functionName, &$node,
                                         $tpl, $parameters, $privateData )
    {
        $tpl->ElseifCounter++;
        $newNodes       = array();
        $nodesToPrepend = array();
        $nodesToAppend  = array();
        $nodePlacement  = eZTemplateNodeTool::extractFunctionNodePlacement( $node );
        $uniqid        =  md5( $nodePlacement[2] ) . "_" . $tpl->ElseifCounter;
        $children       = eZTemplateNodeTool::extractFunctionNodeChildren( $node );


        $newNodes[] = eZTemplateNodeTool::createCodePieceNode( "// if begins" );
        $newNodes[] = eZTemplateNodeTool::createVariableNode( false, $parameters['condition'], $nodePlacement, array( 'treat-value-as-non-object' => true ), 'if_cond' );
        $newNodes[] = eZTemplateNodeTool::createCodePieceNode( "if ( \$if_cond )\n{" );
        $newNodes[] = eZTemplateNodeTool::createSpacingIncreaseNode();

        if ( is_array( $children ) )
        {
            foreach ( array_keys( $children ) as $childKey )
            {
                $child =& $children[$childKey];

                if ( $child[0] == eZTemplate::NODE_FUNCTION )
                {
                    $childFunctionName =& $child[2];
                    $childChildren     = eZTemplateNodeTool::extractFunctionNodeChildren( $child );
                    $childFunctionArgs =& $child[3];

                    if ( $childFunctionName == 'elseif' )
                    {
                        $compiledElseifCondition = eZTemplateCompiler::processElementTransformationList( $tpl, $child, $childFunctionArgs['condition'], $privateData );
                        $nodesToPrepend[] = eZTemplateNodeTool::createVariableNode( false, $compiledElseifCondition,
                                                                                    $nodePlacement,
                                                                                    array( 'text-result' => true ),
                                                                                    "elseif_cond_$uniqid" );
                        $newNodes[] = eZTemplateNodeTool::createSpacingDecreaseNode();
                        $newNodes[] = eZTemplateNodeTool::createCodePieceNode( "}\nelseif ( \$elseif_cond_$uniqid )\n{" );
                        $newNodes[] = eZTemplateNodeTool::createSpacingIncreaseNode();
                        $nodesToAppend[] = eZTemplateNodeTool::createVariableUnsetNode( "elseif_cond_$uniqid" );
                        // increment unique elseif counter
                        $uniqid        =  md5( $nodePlacement[2] ) . "_" . ++$tpl->ElseifCounter;
                    }
                    elseif ( $childFunctionName == 'else' )
                    {
                        $newNodes[] = eZTemplateNodeTool::createSpacingDecreaseNode();
                        $newNodes[] = eZTemplateNodeTool::createCodePieceNode( "}\nelse\n{" );
                        $newNodes[] = eZTemplateNodeTool::createSpacingIncreaseNode();
                    }
                    elseif ( $childFunctionName == 'break' )
                        $newNodes[] = eZTemplateNodeTool::createCodePieceNode( "break;\n" );
                    elseif ( $childFunctionName == 'continue' )
                        $newNodes[] = eZTemplateNodeTool::createCodePieceNode( "continue;\n" );
                    elseif ( $childFunctionName == 'skip' )
                        $newNodes[] = eZTemplateNodeTool::createCodePieceNode( "\$skipDelimiter = true;\ncontinue;\n" );

                    // let other functions (ones not listed in the conditions above) be transformed
                    if ( in_array( $childFunctionName, array( 'elseif', 'else', 'break', 'continue', 'skip' ) ) )
                         continue;
                }
                $newNodes[] = $child;
            }
        }

        $newNodes[] = eZTemplateNodeTool::createSpacingDecreaseNode();
        $newNodes[] = eZTemplateNodeTool::createCodePieceNode( "}" );
        $newNodes[] = eZTemplateNodeTool::createCodePieceNode( "unset( \$if_cond );" );
        $newNodes[] = eZTemplateNodeTool::createCodePieceNode( "// if ends\n" );

        $newNodes = array_merge( $nodesToPrepend, $newNodes, $nodesToAppend );

        return $newNodes;
    }
66470
private RuntimeException codeBug()
        throws RuntimeException
    {
        throw Kit.codeBug("ts.cursor=" + ts.cursor
                          + ", ts.tokenBeg=" + ts.tokenBeg
                          + ", currentToken=" + currentToken);
    }
584785
@Override
   public void generate(Definition def)
   {
      generatePackageInfo(def, "main", null);

      generateRaCode(def);
      generateOutboundCode(def);
      generateInboundCode(def);

      generateTestCode(def);

      switch (def.getBuild())
      {
         case "ivy":
            generateAntIvyXml(def, def.getOutputDir());
            break;
         case "maven":
            generateMavenXml(def, def.getOutputDir());
            break;
         case "gradle":
            generateGradle(def, def.getOutputDir());
            break;
         default:
            generateAntXml(def, def.getOutputDir());
            break;
      }

      generateRaXml(def, def.getOutputDir());
      if (def.isSupportOutbound())
         generateIronjacamarXml(def, def.getOutputDir());

      if (def.isGenMbean() &&
            def.isSupportOutbound() &&
            !def.getMcfDefs().get(0).isUseCciConnection())
      {
         generateMBeanCode(def);
         generateMbeanXml(def, def.getOutputDir());
      }

      if (def.isSupportEis() &&
            def.isSupportOutbound() &&
            !def.getMcfDefs().get(0).isUseCciConnection())
      {
         generateEisCode(def);
      }
   }
1079343
function getWebpackRunnableLambda(slsWebpack, stats, functionName) {
  const handler = slsWebpack.loadHandler(stats, functionName, true)
  const context = slsWebpack.getContext(functionName)
  return wrapHandler(handler, context)
}
499418
function buildTree(index, api) {
  const modules = {};

  const dependency = (module, parent) => {
    const filepath = api.resolve(module, parent);
    if (modules[filepath] != null) {
      return modules[filepath];
    }

    const src = api.getFileContents(module, parent, "utf8");
    const basic = api.parser(src);
    const [nestedImports, hasMemory] = parseImports(basic, api);

    const deps = {};

    Object.keys(nestedImports).forEach(mod => {
      if (mod.indexOf(".") === 0) {
        const dep = dependency(mod, filepath);
        deps[mod] = dep;
      }
    });

    const patched = inferImportTypes(basic, deps, api);
    const ast = api.semantics(patched);

    api.validate(ast, {
      lines: src.split("\n"),
      filename: module.split("/").pop(),
    });

    const result = {
      ast,
      deps,
      filepath,
      hasMemory,
    };
    modules[filepath] = result;

    return result;
  };

  const root = dependency(index, null);

  return {
    root,
    modules,
  };
}
455793
ScopeState visibilityIn(String pkg, QualifiedName type) {
    if (pkg == null) {
      return visibilityIn(UNIVERSALLY_VISIBLE_PACKAGE, type);
    } else if (isTopLevelType(pkg, type.getSimpleName())) {
      if (type.isTopLevel() && type.getPackage().equals(pkg)) {
        return ScopeState.IN_SCOPE;
      } else {
        return ScopeState.HIDDEN;
      }
    } else if (!pkg.equals(UNIVERSALLY_VISIBLE_PACKAGE)) {
      return visibilityIn(UNIVERSALLY_VISIBLE_PACKAGE, type);
    } else {
      return ScopeState.IMPORTABLE;
    }
  }
304285
public boolean performJavaCompilations(File binDir,
                                           String serverSettings,
                                           String[] args,
                                           Set<String> recentlyCompiled,
                                           boolean[] rcValue) {
        Map<String,Transformer> suffixRules = new HashMap<String,Transformer>();
        suffixRules.put(".java", compileJavaPackages);
        compileJavaPackages.setExtra(serverSettings);
        compileJavaPackages.setExtra(args);

        rcValue[0] = perform(binDir, suffixRules);
        recentlyCompiled.addAll(taintedPackages());
        clearTaintedPackages();
        boolean again = !packagesWithChangedPublicApis.isEmpty();
        taintPackagesDependingOnChangedPackages(packagesWithChangedPublicApis, recentlyCompiled);
        packagesWithChangedPublicApis = new HashSet<String>();
        return again && rcValue[0];
    }
691418
public static void main(Class main, String[] args, String[] packageNamesToWeave) throws Exception{
    for (String packageName : packageNamesToWeave) {
      weavePackage(packageName);
    }
    ArrayList<String> l = new ArrayList<String>(Arrays.asList(args));
    l.add(0, "-mainClass");
    l.add(1, main.getName());
    _init.boot2(l.toArray(new String[0]));
  }
522615
public static void typeCheck(INode classdef, Interpreter interpreter,
			CallSequence test, Environment outer) throws AnalysisException,
			Exception
	{
		FlatEnvironment env = null;

		if (classdef instanceof SClassDefinition)
		{
			env = new FlatEnvironment(interpreter.getAssistantFactory(), classdef.apply(interpreter.getAssistantFactory().getSelfDefinitionFinder()), outer);
		} else
		{
			List<PDefinition> defs = new Vector<>();
			
			if(classdef instanceof AModuleModules)
			{
				defs.addAll(((AModuleModules) classdef).getDefs());
			}
			
			env = new FlatEnvironment(interpreter.getAssistantFactory(), defs, outer);
		}

		for (int i = 0; i < test.size(); i++)
		{
			PStm statement = test.get(i);

			if (statement instanceof TraceVariableStatement)
			{
				((TraceVariableStatement) statement).typeCheck(env, NameScope.NAMESANDSTATE);
			} else
			{
				statement = statement.clone();
				test.set(i, statement);
				interpreter.typeCheck(statement, env);
			}
		}
	}