/// <summary> /// Declare a user PHP function. /// </summary> /// <param name="routine">Routine to be declared. Its index is initialized lazily.</param> public void DeclarePhpRoutine(RoutineInfo routine) { Debug.Assert(routine != null); int index = routine.Index; if (index == 0) { index = s_nameToIndex.GetOrAdd(routine.Name, newname => { return(s_contextRoutinesCounter.GetNewIndex()); }); if (index < 0) { // redeclaring over app context function RedeclarationError(routine.Name); } // routine.Index = index; } Debug.Assert(routine.Index > 0); // if (_contextRoutines.Length < index) { Array.Resize(ref _contextRoutines, index * 2); } DeclarePhpRoutine(ref _contextRoutines[index - 1], routine); }
/// <summary> /// Declare a user PHP function. /// </summary> /// <param name="routine">Routine to be declared. Its index is initialized lazily.</param> public void DeclarePhpRoutine(RoutineInfo routine) { Debug.Assert(routine != null); int index = routine.Index; if (index == 0) { lock (_nameToIndex) { if (_nameToIndex.TryGetValue(routine.Name, out index)) { if (index < 0) // redeclaring over an app context function { _redeclarationCallback(routine); } } else { index = _contextRoutinesCounter.GetNewIndex() + 1; _nameToIndex[routine.Name] = index; } } // routine.Index = index; } Debug.Assert(routine.Index > 0); // if (_contextRoutines.Length < index) { Array.Resize(ref _contextRoutines, index * 2); } DeclarePhpRoutine(ref _contextRoutines[index - 1], routine); }