aspclassic-core/AspClassic.Scripting/ScriptCode.cs
Jelle Luteijn 484dbfc9d9 progress
2022-05-15 11:19:49 +02:00

36 lines
739 B
C#

using AspClassic.Scripting.Runtime;
using AspClassic.Scripting.Utils;
namespace AspClassic.Scripting;
public abstract class ScriptCode
{
private readonly SourceUnit _sourceUnit;
public LanguageContext LanguageContext => _sourceUnit.LanguageContext;
public SourceUnit SourceUnit => _sourceUnit;
protected ScriptCode(SourceUnit sourceUnit)
{
ContractUtils.RequiresNotNull(sourceUnit, "sourceUnit");
_sourceUnit = sourceUnit;
}
public virtual Scope CreateScope()
{
return new Scope();
}
public virtual object Run()
{
return Run(CreateScope());
}
public abstract object Run(Scope scope);
public override string ToString()
{
return $"ScriptCode '{SourceUnit.Path}' from {LanguageContext.GetType().Name}";
}
}