示例#1
0
        // not sure we need to override? but I'm not chancing
        public override mysToken Call(
			List<mysToken> arguments,
			mysState state,
			Stack<mysSymbolSpace> spaceStack
		)
        {
            arguments = arguments.Select( t =>
                t.Type == typeof(mysSymbol) && !t.Quoted
                ? ( t.Value as mysSymbol ).Value( spaceStack )
                : t
            ).ToList();

            // do we need to push our own internal space here?
            // I mean, maybe?

            mysSymbolSpace internalSpace = new mysSymbolSpace();

            spaceStack.Push( internalSpace );

            mysToken result = Function( arguments, state, spaceStack );

            spaceStack.Pop();

            return result;
        }
示例#2
0
        public static void DefineInGlobal(
			string name,
			mysFunctionGroup fg,
			mysSymbolSpace global
		)
        {
            mysSymbol symbol = global.Create( name );
            global.Define( symbol, new mysToken( fg ) );
        }
示例#3
0
        public mysState()
        {
            nameSpaces = new Dictionary<string, mysSymbolSpace>();
            exposedAssemblies = new List<Assembly>();

            Global = new mysSymbolSpace();

            Global.Define(
                Global.Create( "true" ),
                new mysToken( true )
            );

            Global.Define(
                Global.Create( "false" ),
                new mysToken( false )
            );

            nameSpaces.Add( "global" , Global );

            mysBuiltins.Setup( Global );
        }
示例#4
0
        public static void AddVariant(
			string name,
			mysFunction variant,
			mysSymbolSpace global
		)
        {
            mysSymbol symbol = new mysSymbol( name );
            mysFunctionGroup fg;

            if ( !global.Defined( symbol ) ) {
                global.Define(
                    symbol,
                    new mysToken( new mysFunctionGroup() )
                );
            }

            fg = global
                .GetValue( new mysSymbol( name ) )
                .Value as mysFunctionGroup
            ;

            fg.Variants.Add( variant );
        }
示例#5
0
        public virtual mysToken Call(
			List<mysToken> arguments,
			mysState state,
			Stack<mysSymbolSpace> spaceStack
		)
        {
            arguments = arguments.Select( t =>
                t.Type == typeof(mysSymbol) && !t.Quoted
                ? ( t.Value as mysSymbol ).Value( spaceStack )
                : t
            ).ToList();

            // future, cache somehow?
            mysSymbolSpace internalSpace = new mysSymbolSpace();

            Symbols.DoPaired(
                arguments,
                (s, a) => internalSpace.Define( s, a )
            );

            spaceStack.Push( internalSpace );

            EvaluationMachine em = new EvaluationMachine(
                Function,
                state,
                spaceStack
            );
            mysToken result = em.Evaluate();

            spaceStack.Pop();

            return result;
        }