Example #1
0
        /// <summary>
        /// Creates new instance with default Functions/Types/Scope.
        /// </summary>
        public Context()
        {
            Types             = new RegisteredTypes();
            ExternalFunctions = new ExternalFunctions();
            Functions         = new RegisteredFunctions();
            Words             = new RegisteredWords();
            Plugins           = new RegisteredPlugins();
            Symbols           = new Symbols();
            Memory            = new Memory();
            Limits            = new Limits(this);
            TokenAliases      = new Dictionary <string, Token>();
            var stack = new CallStack(Limits.CheckCallStack);

            Callbacks = new Callbacks();
            State     = new LangState(stack);
            Units     = new Units();
            Methods   = new RegisteredMethods();
            Plugins.Init();
        }
Example #2
0
 /// <summary>
 /// Creates new instance with default Functions/Types/Scope.
 /// </summary>
 public Context()
 {
     Types = new RegisteredTypes();
     ExternalFunctions = new ExternalFunctions();
     Words = new RegisteredWords();
     Plugins = new RegisteredPlugins();
     PluginsMeta = new MetaPluginContainer();
     Symbols = new Symbols();
     Memory = new Memory();
     Limits = new Limits(this);
     TokenAliases = new Dictionary<string, Token>();
     var stack = new CallStack(Limits.CheckCallStack);
     Callbacks = new Callbacks();
     State = new LangState(stack);
     Units = new Units();
     Methods = new RegisteredMethods();
     Plugins.Init();
 }
Example #3
0
        /// <summary>
        /// Whether or not the variable name provided is an external host language( C# ) type name.
        /// </summary>
        /// <param name="memory">The memory space of the runtime.</param>
        /// <param name="types">The collection of registered external types.</param>
        /// <param name="varName">The name associated with the member access.</param>
        /// <returns></returns>
        public static BoolMsgObj IsExternalTypeName(Memory memory, RegisteredTypes types, string varName)
        {
            Type type = null;
            var isStatic = false;

            // 1. Class name : "Person" as in "Person.Create" -> so definitely a static method call on custom object.
            if (types.Contains(varName))
            {
                type = types.Get(varName);
            }
            // 2. Case insensitive Class name: "person" as in "Person.Create" but "person" variable doesn't exist.
            else if (!memory.Contains(varName))
            {
                // Only do this check for "user" -> "User" class / static method.
                var first = Char.ToUpper(varName[0]);
                var name = first + varName.Substring(1);
                if (types.Contains(name))
                {
                    type = types.Get(name);
                }
            }
            if (type != null) isStatic = true;
            return new BoolMsgObj(type, isStatic, string.Empty);
        }