Alternate signing constructs #1

Merged
lmika merged 12 commits from feature/assign into main 2025-05-24 00:12:24 +00:00
3 changed files with 1 additions and 61 deletions
Showing only changes of commit 2e8e60f904 - Show all commits

View file

@ -14,7 +14,7 @@ jobs:
- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: 1.22.4
go-version: 1.24
- uses: actions/setup-node@v4
with:
node-version: 21.1

View file

@ -180,64 +180,6 @@ func modBuiltin(ctx context.Context, args invocationArgs) (Object, error) {
return IntObject(n), nil
}
// TODO: this may need to be a macro
func setBuiltin(ctx context.Context, args invocationArgs) (Object, error) {
if err := args.expectArgn(2); err != nil {
return nil, err
}
name, err := args.stringArg(0)
if err != nil {
return nil, err
} else if len(name) == 0 {
return nil, fmt.Errorf("attempt to set empty string")
}
newVal := args.args[1]
if strings.HasPrefix(name, "@") {
pname := name[1:]
pvar, ok := args.ec.getPseudoVar(pname)
if ok {
if err := pvar.set(ctx, pname, newVal); err != nil {
return nil, err
}
return newVal, nil
}
if pvar := args.inst.missingPseudoVarHandler; pvar != nil {
if err := pvar.set(ctx, pname, newVal); err != nil {
return nil, err
}
return newVal, nil
}
return nil, fmt.Errorf("attempt to set '%v' to a non-existent pseudo-variable", name)
}
args.ec.setOrDefineVar(name, newVal)
return newVal, nil
}
func mustSetBuiltin(ctx context.Context, args invocationArgs) (Object, error) {
if err := args.expectArgn(2); err != nil {
return nil, err
}
name, err := args.stringArg(0)
if err != nil {
return nil, err
}
newVal := args.args[1]
if newVal == nil {
return nil, fmt.Errorf("attempt to set '%v' to a nil value", args.args[0])
}
args.ec.setOrDefineVar(name, newVal)
return newVal, nil
}
func eqBuiltin(ctx context.Context, args invocationArgs) (Object, error) {
if err := args.expectArgn(2); err != nil {
return nil, err

View file

@ -57,8 +57,6 @@ func New(opts ...InstOption) *Inst {
rootEC.root = rootEC
rootEC.addCmd("echo", invokableFunc(echoBuiltin))
rootEC.addCmd("set", invokableFunc(setBuiltin))
rootEC.addCmd("set!", invokableFunc(mustSetBuiltin))
rootEC.addCmd("len", invokableFunc(lenBuiltin))
rootEC.addCmd("index", invokableFunc(indexBuiltin))
rootEC.addCmd("call", invokableFunc(callBuiltin))