private void CreateProxyFuncs() { MethodInfo[] methods = Type.GetMethods(SEARCH_TYPE); for (int i = 0; i < methods.Length; i++) { var method = methods[i]; ZXParseAttribute attr = GetAttribute(method); // Add The Method if (attr != null) { // If There Is No String, This Is Not A Proxy if (attr.Key == null) { continue; } ZXPFunc v = new ZXPFunc(attr.Key, method); Funcs.Add(v); FuncsDict[v.Key] = v; } else { ZXPFunc v = new ZXPFunc(method.Name, method); Funcs.Add(v); FuncsDict[v.Key] = v; } } }
public Host() { Funcs.Add("Add", Add); Funcs.Add("Echo", Echo); Funcs.Add("Set", SetVar); Funcs.Add("Get", GetVar); }
public void AddFunc(Func <MasterSerialPort, CancellationToken, Task> action) { if (action != null) { Funcs.Add(action); } }
public Wait Then(Action f) { if (f != null) { Funcs.Add(f); } return(this); }
public Host(Conf cf) { _conf = cf; if (cf != null && cf.InitialVariables != null) { foreach (var kv in cf.InitialVariables) { this._vars.Add(kv.Key, kv.Value); } } Funcs.Add("Add", Add); Funcs.Add("Echo", Echo); Funcs.Add("Equal", Equal); Funcs.Add("Not", Not); Funcs.Add("Concat", Concat); }
public void SetFuncs(List <string> funcs) { AEElem sin = new AEElem("sin", "sin(?L)", "\\sin{(?L)}", default); AEElem cos = new AEElem("cos", "cos(?L)", "\\cos{(?L)}", default); AEElem tan = new AEElem("tan", "tan(?L)", "\\tan{(?L)}", default); AEElem atan = new AEElem("atan", "atan(?L)", "\\arctan{(?L)}", default); AEElem scobs = new AEElem("scobs", "(?L)", "(?L)", default); AEElem log10 = new AEElem("log10", "log10(?L)", "\\log_{10}{(?L)}", "((?L) > 1.0e-6 && fabs((?L) - 1.0) > 1.0e-6)"); AEElem ln = new AEElem("ln", "ln(?L)", "\\ln{(?L)}", "((?L) > 1.0e-6 && fabs((?L) - 1.0) > 1.0e-6)"); AEElem sqrt = new AEElem("sqrt", "sqrt(?L)", "\\sqrt{?L}", "((?L) > 1.0e-6)"); if (funcs.Contains("sin")) { Funcs.Add(sin); } if (funcs.Contains("cos")) { Funcs.Add(cos); } if (funcs.Contains("tan")) { Funcs.Add(tan); } if (funcs.Contains("atan")) { Funcs.Add(atan); } if (funcs.Contains("log10")) { Funcs.Add(log10); } if (funcs.Contains("ln")) { Funcs.Add(ln); } if (funcs.Contains("sqrt")) { Funcs.Add(sqrt); } Funcs.Add(scobs); }
internal void Add(Delegate f) { Funcs.Add(f); }
/// <summary> /// The function Add gets as a parameter a function /// which gets a double parameter and returns a double return value. /// It adds the function to the functions list of the expression /// it concatenates it to the other functions until now. /// <param name="func">function to concatenate to the expression</para> /// <retValue>ComposedMission of this to enable fluent programming</retValue> /// </summary> public ComposedMission Add(FunctionsContainer.Func func) { Funcs.Add(func); return(this); }
public Lexer(string compiledCode) { Func currentFunc = null; Block currentBlock = null; int blockNumber = 0; Stack <Block> blockstack = new Stack <Block>(); foreach (string line in compiledCode.Replace(((char)13).ToString(), "").Split('\n')) { if (line.StartsWith(":")) { string op = line.Substring(1); if (currentFunc == null) { currentFunc = new Func(op, Code.buffer.Count); } else { Code.Write(Opcodes.ret); Funcs.Add(currentFunc); currentFunc = new Func(op, Code.buffer.Count); } } else if (line.StartsWith("e:")) { string op = line.Substring(2); if (currentFunc == null) { currentFunc = new Func(op, Code.buffer.Count); } else { Code.Write(Opcodes.ret); Funcs.Add(currentFunc); currentFunc = new Func(op, Code.buffer.Count); } Events.Add(currentFunc); } else if (line.StartsWith(".")) { string name = line.Substring(1); Label l = new Label(name, Code.buffer.Count()); currentFunc.labels.Add(l); } else if (line.StartsWith($"{nameof(Opcodes.pushInt)} ")) { int value = Convert.ToInt32(line.Substring(8)); Code.Write(Opcodes.pushInt); Code.Write(value); _pushVarValue = value.ToString(); } else if (line.StartsWith($"{nameof(Opcodes.pushString)} ")) { string temp = line.Substring(11); string value = temp.Substring(temp.IndexOf("\"") + 1, temp.LastIndexOf("\"") - 1); Code.Write(Opcodes.pushString); Code.Write(value); _pushVarValue = value; } else if (line.StartsWith($"{nameof(Opcodes.pushVar)} ")) { string name = line.Substring(8); Code.Write(Opcodes.pushVar); Code.Write(name); } else if (line.Equals(nameof(Opcodes.pop))) { Code.Write(Opcodes.pop); } else if (line.Equals(nameof(Opcodes.popa))) { Code.Write(Opcodes.popa); } else if (line.StartsWith($"{nameof(Opcodes.decVar)} ")) { string name = line.Substring(7); Code.Write(Opcodes.decVar); Code.Write(name); } else if (line.StartsWith($"{nameof(Opcodes.setGlobalVar)} ")) { string name = line.Substring(13); Code.Write(Opcodes.setGlobalVar); Code.Write(name); if (_pushVarValue != null) { GlobalVars.Add(new Var(name, _pushVarValue)); } } else if (line.StartsWith($"{nameof(Opcodes.setVar)} ")) { string name = line.Substring(7); Code.Write(Opcodes.setVar); Code.Write(name); } else if (line.Equals(nameof(Opcodes.add))) { Code.Write(Opcodes.add); } else if (line.Equals(nameof(Opcodes.sub))) { Code.Write(Opcodes.sub); } else if (line.Equals(nameof(Opcodes.mul))) { Code.Write(Opcodes.mul); } else if (line.Equals(nameof(Opcodes.div))) { Code.Write(Opcodes.div); } else if (line.Equals(nameof(Opcodes.clear))) { Code.Write(Opcodes.clear); } else if (line.StartsWith("if")) { string op = line.Substring(2); if (currentBlock != null) { blockstack.Push(currentBlock); } currentBlock = new IfBlock(blockNumber); if (op.Equals("e")) { Code.Write(Opcodes.ife); } else if (op.Equals("n")) { Code.Write(Opcodes.ifn); } else if (op.Equals("gt")) { Code.Write(Opcodes.ifgt); } else if (op.Equals("gte")) { Code.Write(Opcodes.ifgte); } else if (op.Equals("lt")) { Code.Write(Opcodes.iflt); } else if (op.Equals("lte")) { Code.Write(Opcodes.iflte); } Code.Write(blockNumber); blockNumber++; } else if (line.StartsWith("elseif")) { string op = line.Substring(6); if (currentBlock != null) { blockstack.Push(currentBlock); } currentBlock = new ElseIfBlock(blockNumber); if (op.Equals("e")) { Code.Write(Opcodes.elseife); } else if (op.Equals("n")) { Code.Write(Opcodes.elseifn); } else if (op.Equals("gt")) { Code.Write(Opcodes.elseifgt); } else if (op.Equals("gte")) { Code.Write(Opcodes.elseifgte); } else if (op.Equals("lt")) { Code.Write(Opcodes.elseiflt); } else if (op.Equals("lte")) { Code.Write(Opcodes.elseiflte); } Code.Write(blockNumber); blockNumber++; } else if (line.Equals("else")) { if (currentBlock != null) { blockstack.Push(currentBlock); } currentBlock = new ElseBlock(blockNumber); Code.Write(Opcodes.els); Code.Write(blockNumber); blockNumber++; } else if (line.Equals(nameof(Opcodes.endif))) { Code.Write(Opcodes.endif); currentBlock.endBlock = Code.buffer.Count(); Blocks.Add(currentBlock); if (blockstack.Count > 0) { currentBlock = blockstack.Pop(); } else { currentBlock = null; } } else if (line.StartsWith($"{nameof(Opcodes.call)} ")) { string name = line.Substring(5); Code.Write(Opcodes.call); Code.Write(name); } else if (line.StartsWith("goto ")) { string name = line.Substring(6); Code.Write(Opcodes.got); Code.Write(name); } else if (line.Equals(nameof(Opcodes.print))) { Code.Write(Opcodes.print); } else if (line.Equals(nameof(Opcodes.printLine))) { Code.Write(Opcodes.printLine); } else if (line.Equals(nameof(Opcodes.read))) { Code.Write(Opcodes.read); } else if (line.Equals(nameof(Opcodes.readLine))) { Code.Write(Opcodes.readLine); } else if (line.Equals(nameof(Opcodes.delay))) { Code.Write(Opcodes.delay); } else if (line.Equals(nameof(Opcodes.captureScreen))) { Code.Write(Opcodes.captureScreen); } else if (line.Equals(nameof(Opcodes.getClipboard))) { Code.Write(Opcodes.getClipboard); } else if (line.Equals(nameof(Opcodes.setClipboard))) { Code.Write(Opcodes.setClipboard); } else if (line.Equals(nameof(Opcodes.write))) { Code.Write(Opcodes.write); } else if (line.Equals(nameof(Opcodes.exit))) { Code.Write(Opcodes.exit); } else if (line.StartsWith(nameof(Opcodes.msg))) { Code.Write(Opcodes.msg); } else if (line.Equals(nameof(Opcodes.inputInt32))) { Code.Write(Opcodes.inputInt32); } else if (line.Equals(nameof(Opcodes.inputString))) { Code.Write(Opcodes.inputString); } else if (line.Equals(nameof(Opcodes.ret))) { Code.Write(Opcodes.ret); } } Code.Write(Opcodes.ret); Funcs.Add(currentFunc); }