Skip to content

Commit

Permalink
Merge branch 'refaktor:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
xypwn authored Aug 23, 2024
2 parents f885704 + f1affde commit 21f1c1c
Show file tree
Hide file tree
Showing 102 changed files with 2,147 additions and 1,879 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,8 @@ jobs:
- name: Build
# Enable all features for CI builds.
# TODO: add currently problematic tags: b_cayley,b_nng,b_qframe,b_ebitengine,b_webview
run: |
go build -v -tags "b_sqlite,b_http,b_sql,b_postgres,b_bson,b_crypto,b_smtpd,b_mail,b_bcrypt,b_telegram,b_html,b_contrib,b_openai,b_email,b_mail,b_mysql,b_psql,b_psutil,b_sxml,b_echo" -o bin/rye
go build -v -o bin/rye
ls -l bin/rye
file bin/rye
go version -m bin/rye
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/codeql.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ jobs:

# - name: Build
# run: |
# go build -v -tags "b_sqlite,b_http,b_sql,b_postgres,b_bson,b_crypto,b_smtpd,b_mail,b_bcrypt,b_telegram,b_html,b_contrib,b_openai,b_email,b_mail,b_mysql,b_nats,b_psql,b_psutil,b_sxml,b_echo" -o bin/rye
# go build -v -o bin/rye

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
Expand Down
48 changes: 24 additions & 24 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ jobs:
permissions: read-all
steps:
- name: Install the verifier
uses: slsa-framework/slsa-verifier/actions/installer@v2.5.1
uses: slsa-framework/slsa-verifier/actions/installer@v2.6.0

- name: Download assets
env:
Expand Down Expand Up @@ -152,27 +152,27 @@ jobs:
--certificate-identity-regexp '^https:/slsa-framework/slsa-github-generator/.github/workflows/generator_container_slsa3.yml@refs/tags/v[0-9]+.[0-9]+.[0-9]+$' \
$IMAGE@$DIGEST
docker-publish:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Login
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build Image
run: |
cp .docker/Dockerfile .
docker buildx build -t "refaktor/rye:latest" .
docker buildx build -t "refaktor/rye:${GITHUB_REF_NAME}" .
- name: Release
run: |
docker push "refaktor/rye:latest"
docker push "refaktor/rye:${GITHUB_REF_NAME}"
# docker-publish:
# runs-on: ubuntu-latest
# steps:
# - name: Checkout
# uses: actions/checkout@v4
#
# - name: Login
# uses: docker/login-action@v3
# with:
# registry: ghcr.io
# username: ${{ github.actor }}
# password: ${{ secrets.GITHUB_TOKEN }}
#
# - name: Build Image
# run: |
# cp .docker/Dockerfile .
# docker buildx build -t "refaktor/rye:latest" .
# docker buildx build -t "refaktor/rye:${GITHUB_REF_NAME}" .
#
# - name: Release
# run: |
# docker push "refaktor/rye:latest"
# docker push "refaktor/rye:${GITHUB_REF_NAME}"

2 changes: 1 addition & 1 deletion .github/workflows/scorecards.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ jobs:
persist-credentials: false

- name: "Run analysis"
uses: ossf/scorecard-action@dc50aa9510b46c811795eb24b2f1ba02a914e534 # v2.3.3
uses: ossf/scorecard-action@62b2cac7ed8198b15735ed49ab1e5cf35480ba46 # v2.4.0
with:
results_file: results.sarif
results_format: sarif
Expand Down
9 changes: 7 additions & 2 deletions CODE_OF_CONDUCT.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
CODE OF CONDUCT
# CODE OF CONDUCT

1. Be nice and respectfull to others
The idea is that we shouldn't have too many principles or rules. We are not trying to create a bureaucracy. Just the really necessary ones, the rest is more like advice or knowledge base.

## Principles we try to follow

1. Be nice and respectful to others
2. Try to add value with your activity
3. Criticism is perfectly OK, but be constructive and respect points 1. and 2.
4. When trying to contribute follow the [CONTRIBUTING](CONTRIBUTING.md) directives
24 changes: 20 additions & 4 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,25 @@
# Contributing

## Before PR-s
When trying to contribute try to follow directives below, to make the progress of the project streamlined and Rye up to certain quality.

## Before opening a PR
* Open and issue so we can make a discussion first

## Making PR-s
* Main branch shouldn't be left in a failed state (the red cross)
* PRs that are meant for merging should also pass all checks
## When making a PR
* PRs that are meant for merging should pass all checks
* Each new builtin should have a docstring written and at least few tests

## In general
* Main branch shouldn't be left in a failed state (the red cross)

## Q&A

### How to create commits / PR-s / merge them so that feed and release notes are as informative as possible?

If there is only one commit per PR then the message is stored and used.

If there are multiple commits's then messages get lost unless we merge with *Squash and merge*. This joins messages together and uses them (positive) but also joins all code changes into one commit.
A) If reason for multiple commits is iterating on a set of changes, or making them comple (adding tests, making golint-ci pass, ...) then this makes sense.
B) If PR is composed of multiple commits each for different set of changes then some information is lost with Squash, maybe these should be multiple PR-a.

_This is work in progress, you can propose improvements._
38 changes: 28 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ docker run -ti refaktor/rye

### Building Rye from source

Use official documentation or lines below to install Golang 1.19.3 https://go.dev/doc/install (at the time of writing):
Use official documentation or lines below to install Golang 1.21.5 https://go.dev/doc/install (at the time of writing):

wget https://go.dev/dl/go1.21.5.linux-amd64.tar.gz
rm -rf /usr/local/go && tar -C /usr/local -xzf go1.21.5.linux-amd64.tar.gz
Expand All @@ -239,40 +239,52 @@ Clone the main branch from the Rye repository:

git clone https:/refaktor/rye.git && cd rye

Build the tiny version of Rye:
Build the tiny version of Rye (with minimal modules):

go build -tags "b_tiny"
go build -tags "b_tiny" -o bin/rye

Build the normal version of Rye (with most "batteries" packed in):

go build -o bin/rye

# or just run
./build

Run the rye file:

./rye hello.rye
bin/rye hello.rye

Run the Rye Console

./rye
bin/rye

Install build-essential if you don't already have it, for packages that require cgo (like sqlite):

sudo apt install build-essential

#### Build Rye with specific modules
<!-- #### Build Rye with specific modules
Rye has many bindings, that you can determine at build time, so (currently) you get a specific Rye binary for your specific project. This is an example of a build with many bindings.
I've been working on a way to make this more elegant and systematic, but the manual version is:
go build -tags "b_tiny,b_sqlite,b_http,b_sql,b_postgres,b_openai,b_bson,b_crypto,b_smtpd,b_mail,b_postmark,b_bcrypt,b_telegram"

-->

#### Build WASM version

Rye can also work inside your browser or any other WASM container. I will add examples, html pages and info about it, but to build it:

GOOS=js GOARCH=wasm go build -tags "b_tiny" -o wasm/rye.wasm main_wasm.go

Run the demo server for testing WASM version

# or just use
./buildwasm
# which will also start a webserver, visit http://localhost:8085/ryeshell/ then

<!-- Run the demo server for testing WASM version
bin/rye serve_wasm.rye
Then visit http://localhost:8085 or http://localhost:8085/ryeshell/
Then visit http://localhost:8085 or http://localhost:8085/ryeshell/ -->

#### Tests and function reference

Expand All @@ -290,6 +302,12 @@ Build the function reference out of tests:

Rye has Syntax highlighting for Emacs and VS Code. For VS Code just search for **ryelang** in the Extension marketplace. For Emacs it will be published soon on github.

## Rye related projects

* [Rye-fyne](https:/refaktor/rye-fyne) - external binding for Fyne GUI toolkit (wip)
* [Rye-ebitengine](https:/refaktor/rye-ebitengine) - external binding for Ebitengine game engine (wip)
* [ryegen](https:/refaktor/ryegen) - Rye binging generation toolkit (wip)

## Related links

[**Rebol**](http://www.rebol.com) - Rebol's author Carl Sassenrath invented or combined together 90% of concepts that Rye builds upon.
Expand Down
2 changes: 1 addition & 1 deletion build
Original file line number Diff line number Diff line change
@@ -1 +1 @@
go build -tags "b_sqlite,b_http,b_sql,b_postgres,b_bson,b_mail,b_bcrypt,b_telegram,b_html,b_email,b_mail,b_mysql,b_fyne,b_contrib,b_bleve,b_devops,b_ssh," -o bin/rye
go build -o bin/rye
34 changes: 0 additions & 34 deletions code-of-repo-conduct.md

This file was deleted.

77 changes: 77 additions & 0 deletions env/env.go
Original file line number Diff line number Diff line change
Expand Up @@ -301,8 +301,17 @@ type ProgramState struct {
WorkingPath string // holds the path to CWD (can be changed in program with specific functions)
AllowMod bool
LiveObj *LiveEnv
Dialect DoDialect
Stack *EyrStack
}

type DoDialect int

const (
Rye2Dialect DoDialect = 1
EyrDialect DoDialect = 2
)

func NewProgramState(ser TSeries, idx *Idxs) *ProgramState {
ps := ProgramState{
ser,
Expand All @@ -324,6 +333,8 @@ func NewProgramState(ser TSeries, idx *Idxs) *ProgramState {
"",
false,
NewLiveEnv(),
Rye2Dialect,
NewEyrStack(),
}
return &ps
}
Expand All @@ -349,6 +360,8 @@ func NewProgramStateNEW() *ProgramState {
"",
false,
NewLiveEnv(),
Rye2Dialect,
NewEyrStack(),
}
return &ps
}
Expand All @@ -357,6 +370,10 @@ func (ps *ProgramState) Dump() string {
return ps.Ctx.DumpBare(*ps.Idx)
}

func (ps *ProgramState) ResetStack() {
ps.Stack = NewEyrStack()
}

func AddToProgramState(ps *ProgramState, ser TSeries, idx *Idxs) *ProgramState {
ps.Ser = ser
ps.Res = nil
Expand Down Expand Up @@ -428,3 +445,63 @@ func (le *LiveEnv) Add(file string) {
func (le *LiveEnv) ClearUpdates() {
le.Updates = make([]string, 0)
}

const STACK_SIZE int = 1000

type EyrStack struct {
D []Object
I int
}

func NewEyrStack() *EyrStack {
st := EyrStack{}
st.D = make([]Object, STACK_SIZE)
st.I = 0
return &st
}

// IsEmpty checks if our stack is empty.
func (s *EyrStack) IsEmpty() bool {
return s.I == 0
}

// Push adds a new number to the stack
func (s *EyrStack) Push(es *ProgramState, x Object) {
//// *s = append(*s, x)
if s.I+1 >= STACK_SIZE {
es.ErrorFlag = true
es.Res = NewError("stack overflow (maxed)")
return
}
s.D[s.I] = x
s.I++
// appending takes a lot of time .. pushing values ...
}

// Pop removes and returns the top element of stack.
func (s *EyrStack) Pop(es *ProgramState) Object {
if s.IsEmpty() {
es.ErrorFlag = true
es.Res = NewError("stack underflow (empty)")
return es.Res
}
s.I--
x := s.D[s.I]
return x
}

// Pop removes and returns the top element of stack.
func (s *EyrStack) Peek(es *ProgramState, offset int) Object {
if s.IsEmpty() {
es.ErrorFlag = true
es.Res = NewError("stack underflow (empty 2)")
return es.Res
}
if s.I-offset < 0 {
es.ErrorFlag = true
es.Res = NewError("stack underflow (offset)")
return es.Res
}
x := s.D[s.I-offset]
return x
}
Loading

0 comments on commit 21f1c1c

Please sign in to comment.