language

package
v0.3.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 28, 2023 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type File

type File struct {
	Name   string
	Source io.Reader
}

type Language

type Language interface {
	Id() string
	Name() string
	DefaultFileName() string
	Compile(Sandbox, File, io.Writer, io.Writer, []File) error
	Run(Sandbox, io.Reader, io.Reader, io.Writer, time.Duration, int) (Status, error)

	Test(Sandbox) error
}

func StoreAllExcept

func StoreAllExcept(s Store, except []string) []Language

type LanguageTest

type LanguageTest struct {
	Language        Language
	Source          string
	ExpectedVerdict Verdict
	Input           string
	ExpectedOutput  string
	TimeLimit       time.Duration
	MemoryLimit     int
}

func (LanguageTest) Run

func (test LanguageTest) Run(sandbox Sandbox) error

type LanguageWrapper

type LanguageWrapper struct {
	Language
	// contains filtered or unexported fields
}

func (LanguageWrapper) Id

func (lw LanguageWrapper) Id() string

type ListStore

type ListStore struct {
	// contains filtered or unexported fields
}

func NewListStore

func NewListStore() *ListStore

func (*ListStore) Get

func (m *ListStore) Get(id string) Language

func (*ListStore) List

func (m *ListStore) List() []Language

func (*ListStore) Register

func (m *ListStore) Register(id string, l Language)

type Sandbox

type Sandbox interface {
	Id() string
	Init(*log.Logger) error

	Pwd() string

	CreateFile(string, io.Reader) error
	GetFile(string) (io.Reader, error)
	MakeExecutable(string) error

	SetMaxProcesses(int) Sandbox
	Env() Sandbox
	SetEnv(string) Sandbox
	AddArg(string) Sandbox
	TimeLimit(time.Duration) Sandbox
	MemoryLimit(int) Sandbox
	Stdin(io.Reader) Sandbox
	Stderr(io.Writer) Sandbox
	Stdout(io.Writer) Sandbox
	MapDir(string, string, []string, bool) Sandbox
	WorkingDirectory(string) Sandbox
	Verbose() Sandbox
	Run(string, bool) (Status, error)

	Cleanup() error
}

type SandboxProvider

type SandboxProvider struct {
	// contains filtered or unexported fields
}

func NewSandboxProvider

func NewSandboxProvider() *SandboxProvider

func (*SandboxProvider) Get

func (sp *SandboxProvider) Get() (Sandbox, error)

func (*SandboxProvider) MustGet

func (sp *SandboxProvider) MustGet() Sandbox

func (*SandboxProvider) Put

func (sp *SandboxProvider) Put(s Sandbox)

type Status

type Status struct {
	Verdict Verdict
	Signal  int
	Memory  int
	Time    time.Duration
}

type Store

type Store interface {
	Register(id string, l Language)
	List() []Language
	Get(id string) Language
}
var DefaultStore Store

type Verdict

type Verdict int
const (
	VerdictOK Verdict = 1 << iota
	VerdictTL
	VerdictML
	VerdictRE
	VerdictXX
	VerdictCE
)

func (Verdict) String

func (v Verdict) String() string

Directories

Path Synopsis
langs
cpp
nim
zip

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL