Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion buildwasm
Original file line number Diff line number Diff line change
@@ -1 +1,4 @@
env GOOS=js GOARCH=wasm go build -ldflags="-s -w" -tags "wasm,b_wasm,no_sqlite,no_psql,no_mysql,no_io,no_git,no_chitosocket,no_termui" -o wasm/tryrye/main.wasm main_wasm.go ; bin/rye serve_wasm.rye
env GOOS=js GOARCH=wasm go build -ldflags="-s -w" -tags "wasm,b_wasm,no_sqlite,no_psql,no_mysql,no_io,no_git,no_chitosocket,no_termui,no_telegram,no_smtpd,no_tui,no_mcp,no_os,no_pipes,no_mail,no_smtpd,no_prometheus" -o wasm/tryrye/main.wasm main_wasm.go
# ; bin/rye serve_wasm.rye

# no_termui,no_os,no_pipes,no_mail,no_crypto,no_bcrypt,no_bson,no_echarts,no_email,no_imap,no_mqtt,no_prometheus,no_smtpd,no_telegram,no_validation,no_sxml,no_markdown,no_cli,no_tui,no_mcp" \
23 changes: 14 additions & 9 deletions env/context.go
Original file line number Diff line number Diff line change
Expand Up @@ -587,11 +587,17 @@ func (e *RyeCtx) MarkAsVariable(word int) {

// Check if a word is a variable
func (e *RyeCtx) IsVariable(word int) bool {
isVar, exists := e.varFlags[word]
if exists && isVar {
// Fast path: check current context first
if isVar, exists := e.varFlags[word]; exists && isVar {
return true
}
// Not a variable in this context
// Walk parent chain without recursion
for ctx := e.Parent; ctx != nil; ctx = ctx.Parent {
if isVar, exists := ctx.varFlags[word]; exists && isVar {
return true
}
}
// Not a variable in this context or any parent
return false
}

Expand All @@ -612,16 +618,17 @@ func (e *RyeCtx) Mod(word int, val Object) bool {
// ModWithInfo modifies a word and returns detailed information about the result
// Returns (ModResult, existingType) where existingType is the type of the existing value if there's a mismatch
func (e *RyeCtx) ModWithInfo(word int, val Object) (ModResult, Type) {
if existingVal, exists := e.state[word]; exists {
if _, exists := e.state[word]; exists {
// Word exists, check if it's a variable
if !e.IsVariable(word) {
// Cannot modify constants
return ModErrConstant, 0
}
// bug ... Mod retuns always false, even if error is different type of value than previous
// Type check - compare Object.Type()
if existingVal.Type() != val.Type() {
return ModErrTypeMismatch, existingVal.Type()
}
//if existingVal.Type() != val.Type() {
// return ModErrTypeMismatch, existingVal.Type()
//}
} else {
// Word doesn't exist, create it as a variable
e.MarkAsVariable(word)
Expand Down Expand Up @@ -1176,8 +1183,6 @@ func (ps *ProgramState) GetValue(word string, typ Type) (Object, bool) {
return v, true
}



const STACK_SIZE int = 1000

type EyrStack struct {
Expand Down
Loading
Loading