36 lines
739 B
C#
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}";
|
|
}
|
|
}
|