public void If() { ILispEnvironment environment = new GlobalEnvironment(); environment.Set(new Symbol("kablooey"), new NativeLambda { Body = parameters => { throw new LispException("kablooey!"); } }); // Ensure only the "then" clause is evaluated on a true condition. LispAssert.EvaluatesTo(Lisp.Constant(1), Lisp.List(Lisp.Symbol("if"), Lisp.Constant(true), Lisp.Constant(1), Lisp.List(Lisp.Symbol("kablooey"))), environment); LispAssert.ThrowsWhenEvaluated( Lisp.List(Lisp.Symbol("if"), Lisp.Constant(true), Lisp.List(Lisp.Symbol("kablooey")), Lisp.Constant(1)), environment); // Ensure only the "else" clause is evaluated on a false condition. LispAssert.EvaluatesTo(Lisp.Constant(1), Lisp.List(Lisp.Symbol("if"), Lisp.Constant(false), Lisp.List(Lisp.Symbol("kablooey")), Lisp.Constant(1)), environment); LispAssert.ThrowsWhenEvaluated( Lisp.List(Lisp.Symbol("if"), Lisp.Constant(false), Lisp.Constant(1), Lisp.List(Lisp.Symbol("kablooey"))), environment); // Ensure the test condition clause is evaluated. In this case, a non-empty list would be true if not // evaluated, but evaluating the expression will produce false. LispAssert.EvaluatesTo(Lisp.Constant(2), Lisp.List(Lisp.Symbol("if"), Lisp.List(Lisp.Symbol("number?"), Lisp.Symbol("car")), Lisp.Constant(1), Lisp.Constant(2))); // Test truth / falsiness of non-boolean - only #f and () should count as false. LispAssert.EvaluatesTo(Lisp.Constant(2), Lisp.List(Lisp.Symbol("if"), Lisp.Nil, Lisp.Constant(1), Lisp.Constant(2))); LispAssert.EvaluatesTo(Lisp.Constant(1), Lisp.List(Lisp.Symbol("if"), Lisp.Quote(Lisp.List(Lisp.Constant(false))), Lisp.Constant(1), Lisp.Constant(2))); LispAssert.EvaluatesTo(Lisp.Constant(1), Lisp.List(Lisp.Symbol("if"), Lisp.Constant(""), Lisp.Constant(1), Lisp.Constant(2))); LispAssert.EvaluatesTo(Lisp.Constant(1), Lisp.List(Lisp.Symbol("if"), Lisp.Symbol("cdr"), Lisp.Constant(1), Lisp.Constant(2))); }
private void Login() { Security.Account acc; do { acc = Security.Account.DoLogin(); } while(!acc.OK); GlobalEnvironment.Init(acc); CommandInit.Init(); Shell.StartShell(); }
internal SkryptEngine CreateGlobals() { var block = ProgramContext.block(); foreach (var v in block.LexicalEnvironment.Variables) { GlobalEnvironment.AddVariable(v.Value); } return(this); }
internal WorldState(ControlPoint cp, GlobalEnvironment ge) { this.cp = cp; this.ge = ge; this.defaultObject = Constant.DefaultObject; this.eofObject = Constant.EofObject; this.aux = Constant.theAuxMarker; this.key = Constant.theKeyMarker; this.optional = Constant.theOptionalMarker; this.rest = Constant.theRestMarker; this.externalUnassigned = Constant.ExternalUnassigned; this.unspecific = Constant.Unspecific; }
static void Main(string[] filesToPreload) { foreach (var file in filesToPreload) { using var fileStream = File.Open(file, FileMode.Open); GlobalEnvironment.Repl( null, new Parser(fileStream), false); } GlobalEnvironment.Repl(); }
public static LexicalMap Make(GlobalEnvironment env) { return(new GlobalLexicalMap(env)); }
GlobalLexicalMap(GlobalEnvironment env) : base() { this.environment = env; }
/// <summary> /// Assign a value to a name in the global environment. /// </summary> /// <param name="name">The name.</param> /// <param name="expression">The symbol.</param> public void SetSymbol(string name, SymbolicExpression expression) { CheckEngineIsRunning(); GlobalEnvironment.SetSymbol(name, expression); }
/// <summary> /// Gets a symbol defined in the global environment. /// </summary> /// <param name="name">The name.</param> /// <returns>The symbol.</returns> public SymbolicExpression GetSymbol(string name) { CheckEngineIsRunning(); return(GlobalEnvironment.GetSymbol(name)); }
public MelonEngine FastAdd(string name, MelonObject value) { GlobalEnvironment.AddVariable(name, value, new TypeReference(this, GetTypeFromValue(value))); return(this); }
public static LexicalMap Make(GlobalEnvironment env) { return new GlobalLexicalMap (env); }
private void Enlist() { //Step 1.Set Global Environments GlobalEnvironment.DDKHome = txtDDKPath.Text; //Step 2.Enlist From Server String enlistLocalPath = txtEnlistmentPath.Text.TrimEnd('\\'); String winDDKHomePath = txtDDKPath.Text.TrimEnd('\\'); if (!Directory.Exists(enlistLocalPath)) { try { Directory.CreateDirectory(enlistLocalPath); } catch { MessageBox.Show("Invalid Path!", "Enlist Wizard", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } //Check if it exits normally Boolean runSuccessfully = SvnService.SvnCheckoutWorkspace(this.accountName, this.password, enlistLocalPath); if (!runSuccessfully) { MessageBox.Show("Svn Checkout Failed", "Enlist Wizard", MessageBoxButtons.OK, MessageBoxIcon.Error); return; } //Step 3.Modify Razzle.bat String razzleFile = enlistLocalPath + RazzleFilePath.RAZZLETEMPLATE_BAT_FILEPATH; int razzleIndex = GlobalEnvironment.RazzleCount + 1; String destRazzleBatName = String.Format(@"\Razzle_{0}.bat", razzleIndex); String destRazzleBatPathName = Environment.GetFolderPath(Environment.SpecialFolder.System) + destRazzleBatName; StreamReader sr = new StreamReader(razzleFile); String content = sr.ReadToEnd(); sr.Close(); //Step 3.1 Replace %%ENLISTMENT_PROJ_ROOT%% in Razzle.bat content = content.Replace(TemplateStrings.LOCAL_ENLISTMENT_PROJ_ROOT_STRING, enlistLocalPath + @"\MadDog"); //Step 3.2 Replace %%ENLISTMENT_PROJ_ROOT%% in Razzle.bat content = content.Replace(TemplateStrings.LOCAL_RAZZLE_INDEX, razzleIndex.ToString()); //Step 3.3 Replace %%WINDDK_HOME%% in Razzle.bat //BUG FIX - Can't set WinDDKHome in Razzle.bat content = content.Replace(TemplateStrings.LOCAL_WINDDKHOME_STRING, winDDKHomePath); //Step 3.4 Replace %%ENLISTMENT_PROJ_ROOT%% in Razzle.bat content = content.Replace(TemplateStrings.LOCAL_CURRENT_USER_STRING, this.accountName); StreamWriter sw = new StreamWriter(destRazzleBatPathName); sw.Write(content); sw.Close(); //Step 4.Create User specified environment String fullUserEnvFolder = enlistLocalPath + RazzleFilePath.RAZZLE_USER_ENVBAT_FOLDERPATH + this.accountName; String defaultEnvFolder = enlistLocalPath + RazzleFilePath.RAZZLETEMPLATE_USER_ENV_FILEPATH; if (!Directory.Exists(fullUserEnvFolder)) { try { Directory.CreateDirectory(fullUserEnvFolder); foreach (String filePath in Directory.GetFiles(defaultEnvFolder)) { String fileName = Path.GetFileName(filePath); File.Copy(filePath, fullUserEnvFolder + @"\" + fileName); } SvnService.SvnAddFolder(this.accountName, this.password, fullUserEnvFolder); } catch { MessageBox.Show("Invalid User Enviroment Path,Try a different Account Name", "Enlist Wizard", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } } //Step 5.Create Shortcut on the desktop. String shortCutFileName = Environment.GetFolderPath(System.Environment.SpecialFolder.Desktop) + String.Format(@"\Razzle_{0}.lnk", razzleIndex); //Step 5.1 Set Razzle Build Env x86 Checked in Default. ShortcutHelper.CreateShortcut(shortCutFileName, destRazzleBatPathName, RazzleFilePath.RAZZLE_BAT_DEFAULT_PARAMETER, enlistLocalPath); //Step 6. Increment Razzle_Count Value GlobalEnvironment.IncreaseRazzleCount(); MessageBox.Show("Enlist successfully"); }
public StorySetting(Guid id, Name name, Description description, Moment moment, GlobalEnvironment globalEnvironment) : base(id, name, description) { Moment = moment; GlobalEnvironment = globalEnvironment; }