public Completion Assign(ExecutionEnvironment environment, object value) { if (environment.HasValue(Raw)) { environment.SetValue(Raw, value); } return(Completion.Exception(string.Format(Properties.Language.VariableNotDefined, Raw), this)); }
public bool HasValue(string variable) { if (currentVariables.ContainsKey(variable)) { return(true); } if (_parent != null) { return(_parent.HasValue(variable)); } return(false); }
protected override Completion ExecuteImpl(ExecutionEnvironment enviroment) { if (enviroment.HasValue("$$ReflectionOnTouchSide&&")) { enviroment.SetValue("$$ReflectionOnTouchSide&&", true); } else { enviroment.RegisterValue("$$ReflectionOnTouchSide&&", true); } return(Completion.Void); }
public static SpeechSynthesizer GetSpeech(ExecutionEnvironment environment) { SpeechSynthesizer Speach = null; if (environment.HasValue(Name)) { Speach = environment.GetValue(Name) as SpeechSynthesizer; } else { Speach = new SpeechSynthesizer(); environment.GetBaseEnvironment().RegisterValue(Name, Speach); } return(Speach); }
public bool HasValue(string variable) { if (IsAborting) { throw new ExecutionAbortException(Properties.Language.ExecutionAborted); } if (currentVariables.ContainsKey(variable)) { return(true); } if (_parent != null) { return(_parent.HasValue(variable)); } return(false); }
public static ConsoleWindow GetConsole(ExecutionEnvironment enviroment) { if (!enviroment.HasValue("#$Console$#")) { Application.Current.Dispatcher.Invoke(() => { consoleWindow = new ConsoleWindow(); consoleWindow.Owner = Application.Current.MainWindow; consoleWindow.Show(); }); enviroment.GetBaseEnvironment().RegisterValue("#$Console$#", consoleWindow); } else { consoleWindow = enviroment.GetValue("#$Console$#") as ConsoleWindow; } return(consoleWindow); }
public Completion Assign(ExecutionEnvironment enviroment, object value) { if (value != null && !(value is BinaryTree)) { return(Completion.Exception("value is not a binary tree type", this)); } if (Node == null) { return(Completion.Exception("Null Exception", this)); } if ((Node is Identifier)) { string var = (Node as Identifier).Variable; if (!enviroment.HasValue(var)) { return(Completion.Exception("varaible was not defined", Node)); } BinaryTree tree = enviroment.GetValue(var) as BinaryTree; if (tree == null) { return(Completion.Exception("variable is not binary tree", Node)); } tree.Left = value as BinaryTree; return(new Completion(value)); } else { var c = Node.Execute(enviroment); if (!c.IsValue) { return(c); } if (c.ReturnValue is BinaryTree) { (c.ReturnValue as BinaryTree).Left = value as BinaryTree; return(new Completion(value)); } else { return(Completion.Exception("value is not binary tree", Node)); } } }
public Completion Assign(ExecutionEnvironment enviroment, object value) { if (value != null && !(value is LinkedListEx)) { return(Completion.Exception("value is not a linked list type", this)); } if (Node == null) { return(Completion.Exception("Null Exception", this)); } if ((Node is Identifier)) { string var = (Node as Identifier).Variable; if (!enviroment.HasValue(var)) { return(Completion.Exception("varaible was not defined", Node)); } LinkedListEx tree = enviroment.GetValue(var) as LinkedListEx; if (tree == null) { return(Completion.Exception("variable is not linked list", Node)); } tree.Previous = value as LinkedListEx; return(new Completion(value)); } else { var c = Node.Execute(enviroment); if (!c.IsValue) { return(c); } if (c.ReturnValue is LinkedListEx) { (c.ReturnValue as LinkedListEx).Previous = value as LinkedListEx; return(new Completion(value)); } else { return(Completion.Exception("value is not linked list", Node)); } } }
public static ConsoleWindow GetConsole(ExecutionEnvironment enviroment) { ConsoleWindow wnd = null; if (!enviroment.HasValue("#$Console$#")) { Application.Current.Dispatcher.Invoke(() => { wnd = new ConsoleWindow(); wnd.Owner = Application.Current.MainWindow; wnd.Show(); }); enviroment.GetBaseEnvironment().RegisterValue("#$Console$#", wnd); ConsoleBaseStatement.consoleWindow = wnd; } else { wnd = enviroment.GetValue("#$Console$#") as ConsoleWindow; } return(wnd); }
protected override Completion ExecuteImpl(ExecutionEnvironment enviroment) { if (Node == null) { return(Completion.Exception("Null Exception", this)); } if ((Node is Identifier)) { string var = (Node as Identifier).Variable; if (!enviroment.HasValue(var)) { return(Completion.Exception("varaible was not defined", Node)); } BinaryTree tree = enviroment.GetValue(var) as BinaryTree; if (tree == null) { return(Completion.Exception("variable is not binary tree", Node)); } return(new Completion(tree.Left)); } else { var c = Node.Execute(enviroment); if (!c.IsValue) { return(c); } if (c.ReturnValue is BinaryTree) { return(new Completion((c.ReturnValue as BinaryTree).Left)); } else { return(Completion.Exception("value is not binary tree", Node)); } } }
protected override Completion ExecuteImpl(ExecutionEnvironment enviroment) { if (Node == null) { return(Completion.Exception("Null Exception", this)); } if (Node is Identifier) { string var = (Node as Identifier).Variable; if (!enviroment.HasValue(var)) { return(Completion.Exception("varaible was not defined", Node)); } LinkedListEx tree = enviroment.GetValue(var) as LinkedListEx; if (tree == null) { return(Completion.Exception("variable is not linked list", Node)); } return(new Completion(tree.Previous)); } else { var c = Node.Execute(enviroment); if (!c.IsValue) { return(c); } if (c.ReturnValue is LinkedListEx) { return(new Completion((c.ReturnValue as LinkedListEx).Previous)); } else { return(Completion.Exception("value is not linked list", Node)); } } }
public static DrawWindow GetCanvas(ExecutionEnvironment environment) { DrawWindow canvas = null; if (!environment.HasValue(CanvasName)) { ExecutionEnvironment b = environment.GetBaseEnvironment(); Application.Current.Dispatcher.Invoke(() => { canvas = new DrawWindow(); if (Application.Current.MainWindow != null) { canvas.Owner = Application.Current.MainWindow; } canvas.Show(); }); b.RegisterValue(CanvasName, canvas); } else { canvas = environment.GetValue(CanvasName) as DrawWindow; } return(canvas); }
protected override Completion ExecuteImpl(ExecutionEnvironment enviroment) { if (Step == null) { return(Completion.Void); } double degree = 0; try { var c = Step.Execute(enviroment); if (c.Type != CompletionType.Value) { return(c); } degree = TypeConverters.GetValue <double>(c.ReturnValue); } catch { return(Completion.Exception("Wrong number format", Step)); } bool reflection = false; if (enviroment.HasValue("$$ReflectionOnTouchSide&&") && enviroment.GetValue <bool>("$$ReflectionOnTouchSide&&")) { reflection = true; } Sprite sp = enviroment.GetValue("$$INSTANCE$$") as Sprite; int x = sp.X + (int)(Math.Cos(sp.Direction * Math.PI / 180) * degree); int y = sp.Y + (int)(Math.Sin(sp.Direction * Math.PI / 180) * degree); int direction = sp.Direction; if (reflection) { while (x < 0) { x = -x; direction = 180 - direction; } while (x > CurrentEnviroment.ScreenWidth) { x = CurrentEnviroment.ScreenWidth * 2 - x; direction = 180 - direction; } while (y < 0) { y = -y; direction = -direction; } while (y > CurrentEnviroment.ScreenHeight) { y = CurrentEnviroment.ScreenHeight * 2 - y; direction = -direction; } } sp.X = x; sp.Y = y; sp.Direction = direction; App.Current.Dispatcher.InvokeAsync(new Action(() => { (enviroment.GetValue("$$Player") as ScriptPlayer).DrawScript(); })); return(Completion.Void); }