Ejemplo n.º 1
0
        public wolFunction GetStaticMethod(string name)
        {
            wolFunction func = null;

            try
            {
                func = methods[name];
            }
            catch (KeyNotFoundException)
            {
                VirtualMachine.ThrowVMException($"Method by name {name} not found in {strtype}", VirtualMachine.position, ExceptionType.NotFoundException);
            }
            try
            {
                if (func.arguments["this"] == this)
                {
                    VirtualMachine.ThrowVMException($"Method by name {name} in {strtype} is not static", VirtualMachine.position, ExceptionType.InitilizateException);
                }
            }
            catch (KeyNotFoundException)
            {
                //so ok
            }
            return(func);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Create default value with type, security modifer and flag which ask of generator of setter
        /// </summary>
        /// <param name="wolclass">Type of generated value</param>
        /// <param name="modifer">Security modifer of generated value</param>
        /// <param name="isConstant">Flag which ask of generator of setter</param>
        public Value(wolClass wolclass, SecurityModifer modifer = SecurityModifer.PRIVATE, bool isConstant = false)
        {
            type   = wolclass;
            getter = new wolFunction(modifer, "return @this;");
            if (!isConstant)
            {
                setter = new wolFunction(SecurityModifer.PRIVATE, "set : &@this, @_this ;");
            }

            /*{
             *  security = SecurityModifer.PRIVATE, body = "set : &@this, @_this ;",
             *  arguments = new Dictionary<string, wolClass> { { "_this", wolclass } }
             * };*/
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Create function how constructor
        /// </summary>
        /// <param name="type">Type of constructor</param>
        /// <param name="args">Arguments of constructor</param>
        /// <returns></returns>
        public static wolFunction NewDefaultConstructor(wolClass type, params KeyValuePair <string, wolClass>[] args)
        {
            wolFunction constr = new wolFunction
            {
                returnType = type,
                body       = "",
                security   = SecurityModifer.PUBLIC
            };

            for (int i = 0; i < args.Length; i++)
            {
                constr.arguments.Add(args[i].Key, args[i].Value); //да я знаю про foreach, но for быстрее
                constr.body += "&@this." + args[i].Key + ".#set : <null:void>;\n";
            }
            return(constr);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Get not static method in this value
        /// </summary>
        /// <param name="name">Name of not static method</param>
        /// <returns></returns>
        public wolFunction GetMethod(string name)
        {
            wolFunction meth = new wolFunction(); //create empty funciton for that compiler don`t get error

            try
            {
                meth = type.methods[name];
            }
            catch (KeyNotFoundException)
            {
                VirtualMachine.ThrowVMException("Method by name  not found", VirtualMachine.position, ExceptionType.NotFoundException);
            }
            if (meth.arguments.ContainsKey("this"))
            {
                return(meth);                                    //check on 'static'
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 5
0
 public wolFunc(wolFunction func) : this()
 {
     value = func;
 }