Skip to content

Commit

Permalink
feat: remove unused code
Browse files Browse the repository at this point in the history
  • Loading branch information
emil14 committed Sep 16, 2023
1 parent 9150dd9 commit f3451b2
Show file tree
Hide file tree
Showing 36 changed files with 79 additions and 3,341 deletions.
17 changes: 17 additions & 0 deletions ARCHITECHTURE.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Components

## Interpreter

Runs source code without separate step of saving IR to the disc. Usage example `neva run cmd/server`

## Compiler

Reads source code, analyzes it and, if no errors found, generates IR and writes it to the disc as a file so it later can be used by VM

## Virtual Machine

Reads IR file from the disc and passes the data to the runtime

## Runtime

Executes IR
49 changes: 35 additions & 14 deletions cmd/interpreter/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,13 @@ package main

import (
"context"
"os"

"github.com/nevalang/neva/internal/interpreter"
"github.com/nevalang/neva/internal/llrgen"
"github.com/nevalang/neva/internal/irgen"
"github.com/nevalang/neva/internal/parser"
"github.com/nevalang/neva/internal/runtime"
"golang.org/x/exp/slog"
)

var prog = `
Expand Down Expand Up @@ -36,19 +38,38 @@ components {
`

func main() {
interceptor := runtime.DefaultInterceptor{}
connector, _ := runtime.NewDefaultConnector(interceptor)
repo := map[runtime.FuncRef]runtime.Func{}
runner, _ := runtime.NewDefaultFuncRunner(repo)
runTime, _ := runtime.New(connector, runner)
transformer := interpreter.MustNewTransformer()
llrGen := llrgen.New()
p := parser.New()

intr := interpreter.MustNew(p, llrGen, transformer, runTime)

_, err := intr.Interpret(context.Background(), []byte(prog))
logger := slog.New(slog.NewJSONHandler(os.Stdout, nil))

connector, err := runtime.NewDefaultConnector(runtime.DefaultInterceptor{})
if err != nil {
logger.Error(err.Error())
return
}

runner, err := runtime.NewDefaultFuncRunner(map[runtime.FuncRef]runtime.Func{})
if err != nil {
logger.Error(err.Error())
return
}

rt, err := runtime.New(connector, runner)
if err != nil {
logger.Error(err.Error())
return
}

intr := interpreter.MustNew(
parser.New(),
irgen.New(),
interpreter.MustNewTransformer(),
rt,
)

code, err := intr.Interpret(context.Background(), []byte(prog))
if err != nil {
panic(err)
logger.Error(err.Error())
return
}

os.Exit(code)
}
1 change: 1 addition & 0 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ require (
github.com/davecgh/go-spew v1.1.1 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
golang.org/x/exp v0.0.0-20230515195305-f3d0a9c9a5cc // indirect
golang.org/x/sync v0.3.0
gopkg.in/yaml.v3 v3.0.1 // indirect
)
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLL
golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM=
golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM=
golang.org/x/sync v0.3.0 h1:ftCYgMx6zT/asHUrPw8BLLscYtGznsLAnjq5RH9P66E=
golang.org/x/sync v0.3.0/go.mod h1:FU7BRWz2tNW+3quACPkgCx/L+uEAv1htQ0V83Z9Rj+Y=
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
Expand Down
220 changes: 0 additions & 220 deletions internal/compiler/backend/golang/golang.go

This file was deleted.

Loading

0 comments on commit f3451b2

Please sign in to comment.