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); }
/// <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 } } * };*/ }
/// <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); }
/// <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); } }
public wolFunc(wolFunction func) : this() { value = func; }