Exemple #1
0
 public Value(wolClass wolclass, string constr_name, params Value[] arguments) : this(wolclass, SecurityModifer.PUBLIC)
 {
     if (wolclass.classType == wolClassType.STRUCT)
     {
         //pass
     }
     else if (wolclass.classType == wolClassType.ENUM)
     {
         //pass
     }
     else
     {
         if (wolclass is wolDouble)
         {
             //pass
         }
         else if (wolclass is wolString)
         {
             //pass
         }
         else
         {
             try
             {
                 Script.Parse(type.constructors[constr_name].body);
             }
             catch (KeyNotFoundException)
             {
                 VirtualMachine.ThrowVMException($"Constructor by name {constr_name} not found in {wolclass}", VirtualMachine.position, ExceptionType.NotFoundException);
             }
         }
     }
 }
Exemple #2
0
 public wolFunction(SecurityModifer sec = SecurityModifer.PRIVATE, string _body = "return <null:void>;")
 {
     security   = sec;
     returnType = new Void();
     arguments  = new Dictionary <string, wolClass>();
     body       = _body;
 }
Exemple #3
0
 public wolFunction(SecurityModifer sec = SecurityModifer.PRIVATE, params KeyValuePair <string, wolClass>[] args)
 {
     security  = sec;
     arguments = new Dictionary <string, wolClass>(args.Length);
     for (int i = 0; i < args.Length; i++)
     {
         arguments.Add(args[i].Key, args[i].Value); //да я знаю про foreach, но for быстрее
     }
     body       = "return <null:void>;";
     returnType = new Void();
 }
Exemple #4
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 } }
             * };*/
        }
Exemple #5
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);
        }
        public wolClass ToParentClass(string parent_name)
        {
            wolClass parent = null;

            try
            {
                parent = parents[parent_name];
            }
            catch (KeyNotFoundException)
            {
                VirtualMachine.ThrowVMException($"Parent by name '{parent_name}' not found of '{strtype}'", VirtualMachine.position, ExceptionType.NotFoundException);
            }
            if (parent.classType != wolClassType.ENUM)
            {
                foreach (KeyValuePair <string, wolFunction> method in methods)
                {
                    if (!method.Value.close)
                    {
                        try
                        {
                            parent.methods.Add(method.Key, method.Value);
                        }
                        catch (ArgumentException)
                        {
                            continue;
                        }
                    }
                }
                foreach (KeyValuePair <string, Value> field in fields)
                {
                    try
                    {
                        parent.fields.Add(field.Key, field.Value);
                    }
                    catch (ArgumentException)
                    {
                        continue;
                    }
                }
            }
            if ((parent.classType == wolClassType.DEFAULT) || (parent.classType == wolClassType.STRUCT))
            {
                foreach (KeyValuePair <string, wolFunction> constructor in constructors)
                {
                    if (!constructor.Value.close)
                    {
                        try
                        {
                            parent.constructors.Add(constructor.Key, constructor.Value);
                        }
                        catch (ArgumentException)
                        {
                            continue;
                        }
                    }
                }
                foreach (wolFunction destructor in destructors)
                {
                    if (!destructor.close)
                    {
                        try
                        {
                            parent.destructors.Add(destructor);
                        }
                        catch (ArgumentException)
                        {
                            continue;
                        }
                    }
                }
            }
            if ((parent.classType == wolClassType.ENUM) || (parent.classType == wolClassType.STRUCT))
            {
                foreach (KeyValuePair <string, Value> constant in parent.constants)
                {
                    try
                    {
                        parent.constants.Add(constant.Key, constant.Value);
                    }
                    catch (ArgumentException)
                    {
                        continue;
                    }
                }
            }
            else
            {
                foreach (KeyValuePair <string, Value> stfield in static_fields)
                {
                    try
                    {
                        parent.static_fields.Add(stfield.Key, stfield.Value);
                    }
                    catch (ArgumentException)
                    {
                        continue;
                    }
                }
            }
            return(parent);
        }
Exemple #7
0
 public wolCollection(wolClass type) : this()
 {
     generic_type = type;
 }
Exemple #8
0
 public wolType(string type_name) : this()
 {
     value = VirtualMachine.GetWolClass(type_name);
 }
Exemple #9
0
 public wolArray(wolClass type) : this()
 {
     generic_type = type;
 }