public object Include(string/*!*/ relativeSourcePath, bool once)
{
ApplicationConfiguration app_config = Configuration.Application;
// searches for file:
FullPath included_full_path = SearchForIncludedFile(PhpError.Error, relativeSourcePath, FullPath.Empty);
if (included_full_path.IsEmpty) return false;
ScriptInfo info;
bool already_included = scripts.TryGetValue(included_full_path.ToString(), out info);
// skips inclusion if script has already been included and inclusion's type is "once":
if (already_included)
{
if(once)
return ScriptModule.SkippedIncludeReturnValue;
// script type loaded, info cannot be null
}
else
{
PhpSourceFile included_source_file = new PhpSourceFile(app_config.Compiler.SourceRoot, included_full_path);
// loads script type:
info = LoadDynamicScriptType(included_source_file);
// script not found:
if (info == null)
return false;
if (MainScriptFile == null)
// the first script becomes the main one:
DefineMainScript(info, included_source_file);
else
// adds included file into the script list
scripts.Add(included_full_path.ToString(), info);
}
Debug.Assert(info != null);
return GuardedCall((ScriptInfo scriptInfo) =>
{
//return PhpScript.InvokeMainHelper(
// (Type)scriptType,
return scriptInfo.Main(
this,
null, // no local variables
null, // no object context
null, // no class context
true);
}, info, true);
}