Ejemplo n.º 1
0
        private void Body_()
        {
            new Validator("body")
            .OneParameter()
            .SymbolOrStringOnTop()
            .Validate(this.stack);

            var x    = this.Pop();
            var name = x switch
            {
                Value.String s => s.Value,
                Value.Symbol s => s.Value,
                _ => throw new NotSupportedException(),
            };

            if (this.usrdefs.TryGetValue(name, out var usr))
            {
                this.Push(usr);
                return;
            }

            var msg = $"undefined `{name}`";

            throw new RuntimeException(msg);
        }
Ejemplo n.º 2
0
        private void Intern_()
        {
            new Validator("intern")
            .OneParameter()
            .StringOnTop()
            .Validate(this.stack);

            var s   = this.Pop <Value.String>();
            var sym = new Value.Symbol(s.Value);

            this.Push(sym);
        }
Ejemplo n.º 3
0
        private void Name_()
        {
            new Validator("name")
            .OneParameter()
            .Validate(this.stack);

            var sym  = this.Pop();
            var name = sym switch
            {
                Value.Int x => "int",
                Value.Float x => "float",
                Value.Bool x => "bool",
                Value.Char x => "char",
                Value.String x => "string",
                Value.List x => "list",
                Value.Set x => "set",
                Value.Stream x => "stream",
                Value.Symbol x => x.Value,
                _ => throw new NotSupportedException(),
            };

            this.Push(new Value.String(name));
        }