/* * O_NEXT_KEY * sp: unchanged * in: S[top-2] = arrayref * out: R = arrayref->cindex * op: if (arrayref->cindex >= arrayref->size) { * R = END-OF-READ; * } * else { * R = arrayref->cindex; arrayref->cindex++; * } */ public override void Eval(EvaluatorState ev) { //Console.WriteLine(this.ToString()); // get the array reference IValue tableValue = ev.Stack.ReadN(ev.Stack.StackTop - 2); // work with arrays only if (tableValue.TypeOf() == ValueTypeID.TYPE_TABLEREF) { ValueTable table = (ValueTable)tableValue.GetObjectValue(); ValueTableItem vti = table.Next(); if (vti == null) { ev.RegR = new DoneValue(); } else { ev.RegR = new StringValue(vti.Key); } } else { throw new SharpNektonException(new SharpNektonError(SharpNektonErrorID.E_EXPTYPETABLEREF)); } }
/* * O_NEXT * sp: unchanged * in: S[top-1] = arrayref * out: R = arrayref[arrayref->cindex]; * op: if (arrayref->cindex >= arrayref->size) { * R = END-OF-READ; * } * else { * R = arrayref[arrayref->cindex]; arrayref->cindex++; * } */ public override void Eval(EvaluatorState ev) { //Console.WriteLine(this.ToString()); // get the array reference IValue tableValue = ev.Stack.ReadN(ev.Stack.StackTop - 1); // work with arrays only if (tableValue.TypeOf() == ValueTypeID.TYPE_TABLEREF) { ValueTable table = (ValueTable)tableValue.GetObjectValue(); ValueTableItem vti = table.Next(); if (vti == null) { ev.RegR = new DoneValue(); } else { ev.RegR = new TableDataRefValue(vti); // should be TYPE_STOREREF? } } else { //Console.WriteLine(">> nextop tableval.type = {0}", tableValue.TypeOf().ToString()); throw new SharpNektonException(new SharpNektonError(SharpNektonErrorID.E_EXPTYPETABLEREF)); } }
/// <summary> /// Initializes a new instance of the <see cref="MockBuildState"/> class /// </summary> public MockBuildState() { ActiveState = new ValueTable(); SharedState = new ValueTable(); _buildOperations = new List <BuildOperation>(); }
public override void Eval(EvaluatorState ev) { //Console.WriteLine(this.ToString()); // second operand (table) is in R IValue tableValue = ev.GetVal(); if (tableValue.TypeOf() != ValueTypeID.TYPE_TABLEREF) { throw new SharpNektonException(new SharpNektonError(SharpNektonErrorID.E_EXPTYPETABLEREF)); } // first operand (key) IValue key = ev.GetStackTopVal(); ev.Stack.Pop(); // pop the key ValueTable table = (ValueTable)tableValue.GetObjectValue(); if (table.Search(key.GetStringValue()) != null) { ev.RegR = new BooleanValue(true); } else { ev.RegR = new BooleanValue(false); } }
/* * O_FSTORE * sin: S[top] = varref; S[top-1] = arrayref * sout: S[top] = arrayref * in: R = index; S[top] = varref; S[top-1] = arrayref * out: R = arrayref[index]; S[top] = arrayref; * op: R = arrayref[index]; store; */ public override void Eval(EvaluatorState ev) { //Console.WriteLine(this.ToString()); // get the array reference IValue tableValue = ev.Stack.ReadN(ev.Stack.StackTop - 1); // work with arrays only if (tableValue.TypeOf() == ValueTypeID.TYPE_TABLEREF) { ValueTable table = (ValueTable)tableValue.GetObjectValue(); // if this creates a new array item, foreach fall into a endless loop! ValueTableItem vti = table.Search(ev.RegR.GetStringValue()); if (vti != null) { ev.RegR = new TableDataRefValue(vti); } else { throw new SharpNektonException(new SharpNektonError(SharpNektonErrorID.E_BADKEYINFOREACH)); } } else { throw new SharpNektonException(new SharpNektonError(SharpNektonErrorID.E_EXPTYPETABLEREF)); } // store the R to the var // TODO: remove the new opcode creation here AOpCode storeOpCode = new StoreOpCode(this.line, this.linePosition, TokenID.T_ASSIGN_OP); storeOpCode.Eval(ev); }
public override void Eval(EvaluatorState ev) { //Console.WriteLine(this.ToString()); // index is in R IValue keyValue = ev.GetVal(); // get table (it is on the stack[top]) IValue tableValue = ev.GetStackTopVal(); ev.Stack.Pop(); // for array returns ptr to array[index] as TYPE_TABLEDATAREF // else raises an error if (tableValue.TypeOf() == ValueTypeID.TYPE_TABLEREF) { string key = keyValue.GetStringValue(); ValueTable table = (ValueTable)tableValue.GetObjectValue(); ValueTableItem vti = table.Search(key); if (vti == null) { vti = table.Insert(key, new UndefinedValue()); } ev.RegR = new TableDataRefValue(vti); } else { throw new SharpNektonException(new SharpNektonError(SharpNektonErrorID.E_EXPTYPETABLEREF)); } }
protected DatFile BuildGenericDatFile(DatFileAttribute attribute) { DatHeader header = new DatHeader(Convert.ToUInt32(attribute.Translations.Count)); List <IndexTableRecord> indexTableRecords = new List <IndexTableRecord>(); List <ValueTableRecord> valueTableRecords = new List <ValueTableRecord>(); List <KeyTableRecord> keyTableRecords = new List <KeyTableRecord>(); foreach (Translation translation in attribute.Translations) { ValueTableRecord valueTableRecord = new ValueTableRecord(translation.Value); valueTableRecords.Add(valueTableRecord); KeyTableRecord keyTableRecord = new KeyTableRecord(translation.Key); keyTableRecords.Add(keyTableRecord); IndexTableRecord indexTableRecord = new IndexTableRecord( translation.Crc32, Convert.ToUInt32(keyTableRecord.Key.Length), Convert.ToUInt32(valueTableRecord.Value.Length)); indexTableRecords.Add(indexTableRecord); } IndexTable indexTable = new IndexTable(indexTableRecords); ValueTable valueTable = new ValueTable(valueTableRecords); KeyTable keyTable = new KeyTable(keyTableRecords); return(new DatFile(header, indexTable, valueTable, keyTable)); }
/// <summary> /// Initializes a new instance of the <see cref="Recipe"/> class. /// </summary> public Recipe() { _table = new ValueTable(); _mirrorSyntax = null; Name = string.Empty; Language = string.Empty; }
public static ValueTable AddTableWithSyntax(this ValueTable table, string name) { // Create a new table and matching syntax var newSyntaxTable = new TableSyntax(name); var newTable = new ValueTable() { MirrorSyntax = newSyntaxTable, }; // Add the model to the parent table model table.Add(name, new Value(newTable)); // Add the new syntax to the parent table syntax switch (table.MirrorSyntax) { case DocumentSyntax documentSyntax: documentSyntax.Tables.Add(newSyntaxTable); break; default: throw new InvalidOperationException("Unknown Syntax on ValueTable"); } return(newTable); }
public override void Eval(EvaluatorState ev) { //Console.WriteLine(this.ToString()); // second operand (source) ev.GetVal(); // first operand (destination) IValue storeValue = ev.Stack.ReadTop(); ev.Stack.Pop(); // pop destination or index if (storeValue.TypeOf() == ValueTypeID.TYPE_STOREREF) { DoStoreOp((ValueStore)storeValue.GetObjectValue(), ev.RegR, variation); } else if (storeValue.TypeOf() == ValueTypeID.TYPE_TABLEDATAREF) { ValueTableItem vti = (ValueTableItem)storeValue.GetObjectValue(); if (ev.RegR.TypeOf() == ValueTypeID.TYPE_UNDEFINED) { ValueTable table = vti.Parent; table.Delete(vti.Key); } else { DoTableOp(vti, ev.RegR, variation); } } else { throw new SharpNektonException(new SharpNektonError(SharpNektonErrorID.E_EXPTYPESTOREREF)); } }
public void SetResults(ValueTable results) { foreach (var section in _sections) { section.SetResults(results); } }
private void SetResults(ValueTable results) { foreach (var page in _pages) { page.SetResults(results); } }
/// <summary> /// Load the value table from the target file /// </summary> public static bool TryLoadState( Path valueTableFile, out IValueTable result) { // Verify the requested file exists if (!System.IO.File.Exists(valueTableFile.ToString())) { Log.Info("Value Table file does not exist"); result = new ValueTable(); return(false); } // Open the file to read from using (var fileStream = System.IO.File.OpenRead(valueTableFile.ToString())) using (var reader = new System.IO.BinaryReader(fileStream)) { // Read the contents of the build state file try { result = ValueTableReader.Deserialize(reader); return(true); } catch (Exception ex) { Log.Error($"Failed to parse value table: {ex.Message}"); result = new ValueTable(); return(false); } } }
protected DatFile FromBytesInternal([NotNull] byte[] bytes) { DatHeader header = BuildDatHeaderFromBytesInternal(bytes); IndexTable indexTable = BuildIndexTableFromBytesInternal(bytes, header.KeyCount); ValueTable valueTable = BuildValueTableFromBytesInternal(bytes, indexTable, header.KeyCount); KeyTable keyTable = BuildKeyTableFromBytesInternal(bytes, indexTable, header.KeyCount); return(new DatFile(header, indexTable, valueTable, keyTable)); }
/// <summary> /// Initializes a new instance of the <see cref="Recipe"/> class. /// </summary> public Recipe( string name, string language) { _table = new ValueTable(); _mirrorSyntax = null; Name = name; Language = language; }
private static void PrintAllValues( GamblersWorld world, ValueTable <GamblersWorldState, GamblersWorldAction> values) { foreach (var state in world.AllStates()) { Console.WriteLine($"{state}: {values.Value(state)}"); } }
public DatFile Build(byte[] bytes) { DatHeader header = BuildDatHeader(bytes); IndexTable indexTable = BuildIndexTable(bytes, header.KeyCount); ValueTable valueTable = BuildValueTable(bytes, indexTable, header.KeyCount); KeyTable keyTable = BuildKeyTable(bytes, indexTable, header.KeyCount); return(new DatFile(header, indexTable, valueTable, keyTable)); }
public void Execute() { // Register the test systems var testListener = new TestTraceListener(); using (var scopedTraceListener = new ScopedTraceListenerRegister(testListener)) { // Setup the input build state var buildState = new MockBuildState(); var state = buildState.ActiveState; // Set the sdks var sdks = new ValueList(); sdks.Add(new Value(new ValueTable() { { "Name", new Value("Roslyn") }, { "Properties", new Value(new ValueTable() { { "ToolsRoot", new Value("C:/Roslyn/ToolsRoot/") } }) }, })); // Setup parameters table var parametersTable = new ValueTable(); state.Add("Parameters", new Value(parametersTable)); parametersTable.Add("SDKs", new Value(sdks)); parametersTable.Add("System", new Value("win32")); parametersTable.Add("Architecture", new Value("x64")); // Setup build table var buildTable = new ValueTable(); state.Add("Build", new Value(buildTable)); var factory = new ValueFactory(); var uut = new ResolveToolsTask(buildState, factory); uut.Execute(); // Verify expected logs Assert.Equal( new List <string>() { }, testListener.GetMessages()); // Verify build state var expectedBuildOperations = new List <BuildOperation>(); Assert.Equal( expectedBuildOperations, buildState.GetBuildOperations()); } }
/// <summary> /// Generate the collection of build extensions /// </summary> private IList <Path> GenerateBuildExtensionSet( Recipe recipe, ValueTable dependenciesSharedState) { var buildExtensionLibraries = new List <Path>(); // Run the RecipeBuild extension to inject core build tasks var recipeBuildExtensionPath = new Path(); var language = recipe.Language; if (language == "C++") { var moduleFolder = new Path(Assembly.GetExecutingAssembly().Location).GetParent(); recipeBuildExtensionPath = moduleFolder + new Path("Extensions/Soup.Cpp/Soup.Cpp.dll"); } else if (language == "C#") { var moduleFolder = new Path(Assembly.GetExecutingAssembly().Location).GetParent(); recipeBuildExtensionPath = moduleFolder + new Path("Extensions/Soup.CSharp/Soup.CSharp.dll"); } else { throw new InvalidOperationException("Unknown language."); } buildExtensionLibraries.Add(recipeBuildExtensionPath); // Check for any dynamic libraries in the shared state if (dependenciesSharedState.TryGetValue("Build", out var buildDependenciesValue)) { foreach (var dependencyValue in buildDependenciesValue.AsTable()) { var dependency = dependencyValue.Value.AsTable(); if (dependency.TryGetValue("Build", out var buildTableValue)) { var buildTable = buildTableValue.AsTable(); if (buildTable.TryGetValue("TargetFile", out var targetFileValue)) { var targetFile = new Path(targetFileValue.AsString().ToString()); buildExtensionLibraries.Add(targetFile); } else { Log.Warning("Found build dependency with no target file."); } } else { Log.Warning("Found build dependency with no build table."); } } } return(buildExtensionLibraries); }
/// <summary> /// Erstellt eine Liste von Knöpfen für vorhandene Graph-Aktionen im Bezug auf eine gegebene Datentabelle /// </summary> /// <param name="actionLinkedTable"></param> /// <returns>Dynamische Liste von Knöpfen</returns> public List <Button> GetActionsList(ValueTable actionLinkedTable) { Button drawPlotButton = new Button { Text = "Zeichne Graphen" }; drawPlotButton.Click += (object s, EventArgs e) => { ClearLineMemory(); ForceResize(); PlotPolynomialFunction(ValueTable.AmpereFunction, Options.PlotColors[0]); PlotPolynomialFunction(ValueTable.VoltageFunction, Options.PlotColors[1]); PlotPolynomialFunction(ValueTable.PowerFunction, Options.PlotColors[2]); ReplotGraph(); }; Button drawDataMarksButton = new Button { Text = "Zeichne Datenpunkte" }; drawDataMarksButton.Click += (object s, EventArgs e) => { double[,] data = actionLinkedTable.GetTableContents(); int columnCount = data.GetLength(0); int rowCount = data.GetLength(1); // first column are X-values // loop through other columns for Y-values for (int column = 1; column < columnCount; column += 1) { for (int row = 0; row < rowCount; row += 1) { PlotMark(new GraphCoord((float)data[0, row], (float)data[column, row]), Options.PlotColors[column - 1], false); } } ForceResize(); }; Button deleteButton = new Button { Text = "Lösche Graphen" }; deleteButton.Click += (object s, EventArgs e) => { ClearLineMemory(); ForceResize(); }; List <Button> buttonList = new List <Button> { drawPlotButton, drawDataMarksButton, deleteButton }; return(buttonList); }
private ValueTable CollectAnswers() { var answers = new ValueTable(); foreach (QuestionWidget questionWidget in QuestionFlowLayout.Controls) { answers.Add(questionWidget.QuestionName, questionWidget.GetValue()); } return(answers); }
public override void Visit(InlineTableSyntax inlineTable) { var parentTable = _currentTable; _currentTable = new ValueTable() { MirrorSyntax = inlineTable, }; base.Visit(inlineTable); _currentValue = new Value(_currentTable); _currentTable = parentTable; }
private void InitTable() { try { TreeViewColumn ImgColumn = new TreeViewColumn(); TreeViewColumn TypeColumn = new TreeViewColumn(); TreeViewColumn WBColumn = new TreeViewColumn(); TreeViewColumn TintColumn = new TreeViewColumn(); TreeViewColumn EVColumn = new TreeViewColumn(); CellRendererText ImgCell = new CellRendererText(); CellRendererText TypeCell = new CellRendererText(); CellRendererText WBCell = new CellRendererText(); CellRendererText TintCell = new CellRendererText(); CellRendererText EVCell = new CellRendererText(); ImgColumn.Title = "Image"; ImgColumn.MinWidth = 100; ImgColumn.PackStart(ImgCell, true); TypeColumn.Title = "Type"; TypeColumn.MinWidth = 100; TypeColumn.PackStart(TypeCell, true); TypeColumn.Title = "WB Change"; TypeColumn.MinWidth = 100; TypeColumn.PackStart(WBCell, true); TypeColumn.Title = "Tint Change"; TypeColumn.MinWidth = 100; TypeColumn.PackStart(TintCell, true); TypeColumn.Title = "EV Change"; TypeColumn.MinWidth = 100; TypeColumn.PackStart(EVCell, true); ValueTable.AppendColumn(ImgColumn); ValueTable.AppendColumn(TypeColumn); ValueTable.AppendColumn(WBColumn); ValueTable.AppendColumn(TintColumn); ValueTable.AppendColumn(EVColumn); ImgColumn.AddAttribute(ImgCell, "text", 0); TypeColumn.AddAttribute(TypeCell, "text", 1); ImgColumn.AddAttribute(WBCell, "text", 2); TypeColumn.AddAttribute(TintCell, "text", 3); ImgColumn.AddAttribute(EVCell, "text", 4); ValueTable.Model = table; } catch (Exception ex) { ErrorReport.ReportError("Init Table (Create Filterset)", ex); } }
private IValueTable EnsureValueTable(IValueTable table, string key) { if (table.ContainsKey(key)) { return(table[key].AsTable()); } else { var value = new ValueTable(); table.Add(key, new Value(value)); return(value); } }
public void AddTableWithSyntax() { var uut = new ValueTable() { MirrorSyntax = new DocumentSyntax(), }; uut.AddTableWithSyntax("NewTable"); var content = uut.MirrorSyntax.ToString(); Assert.Equal("[NewTable]\n", content); }
private TableMapping[] ExtractTableMappingsFromCom(object comTable) { var tableRowsToProcess = new ValueTable(comTable) .OrderByDescending(delegate(ValueTableRow tableRow) { var purpose = tableRow.GetString("Назначение"); if (purpose == "Основная") { return(10); } if (purpose == "ТабличнаяЧасть") { return(5); } return(0); }) .ToArray(); var tableMappingByQueryName = new Dictionary <string, TableMapping>(); var result = new List <TableMapping>(); for (var i = 0; i < tableRowsToProcess.Length; i++) { var tableRow = tableRowsToProcess[i]; var queryTableName = tableRow.GetString("ИмяТаблицы"); if (!string.IsNullOrEmpty(queryTableName)) { if (AccountingRegisterTables.balanceName == queryTableName) { throw new NotSupportedException(AccountingRegisterTables.balanceName); } var isAccountingRegisterTable = queryTableName == AccountingRegisterTables.subkontoName; var tableMapping = isAccountingRegisterTable ? CreateAccountingRegisterTableMapping(tableRow) : CreateDefaultTableMapping(tableRow, tableMappingByQueryName); if (tableMapping != null) { result.Add(tableMapping); if (!isAccountingRegisterTable) { tableMappingByQueryName.Add(queryTableName, tableMapping); } } } if ((i + 1) % 50 == 0) { Console.Out.WriteLine("processed [{0}] from [{1}], {2}%", i + 1, tableRowsToProcess.Length, (double)(i + 1) / tableRowsToProcess.Length * 100); } } return(result.ToArray()); }
public override void Eval(EvaluatorState ev) { //Console.WriteLine(this.ToString()); // R -> value ev.GetVal(); // if it is an table, make a copy of it... if (ev.RegR.TypeOf() == ValueTypeID.TYPE_TABLEREF) { ValueTable table = (ValueTable)ev.RegR.GetObjectValue(); ev.RegR = new TableRefValue(table.Copy()); } }
public static void Evaluates_to_same_values_as_gridworld_value_table() { var gridWorld = new GridWorld(); var rewarder = new NegativeAtNonTerminalStatesGridWorldRewarder(); var policy = new UniformRandomGridWorldPolicy(); var gridValues = new GridWorldValueTable(gridWorld); var genericValues = new ValueTable <GridWorldState, GridWorldAction>(gridWorld); gridValues.Evaluate(policy, rewarder); genericValues.Evaluate(policy, rewarder); Assert.That(() => AllValuesAreEqual(gridWorld, genericValues, gridValues)); }
public void Build_Executable() { // Register the test systems var testListener = new TestTraceListener(); using (var scopedTraceListener = new ScopedTraceListenerRegister(testListener)) { // Setup the input build state var buildState = new MockBuildState(); var state = buildState.ActiveState; state.Add("PlatformLibraries", new Value(new ValueList())); state.Add("PlatformIncludePaths", new Value(new ValueList())); state.Add("PlatformLibraryPaths", new Value(new ValueList())); state.Add("PlatformPreprocessorDefinitions", new Value(new ValueList())); // Setup recipe table var buildTable = new ValueTable(); state.Add("Recipe", new Value(buildTable)); buildTable.Add("Name", new Value("Program")); // Setup parameters table var parametersTable = new ValueTable(); state.Add("Parameters", new Value(parametersTable)); parametersTable.Add("TargetDirectory", new Value("C:/Target/")); parametersTable.Add("PackageDirectory", new Value("C:/PackageRoot/")); parametersTable.Add("Compiler", new Value("MOCK")); parametersTable.Add("Flavor", new Value("debug")); var factory = new ValueFactory(); var uut = new RecipeBuildTask(buildState, factory); uut.Execute(); // Verify expected logs Assert.Equal( new List <string>() { }, testListener.GetMessages()); // Verify build state var expectedBuildOperations = new List <BuildOperation>(); Assert.Equal( expectedBuildOperations, buildState.GetBuildOperations()); // TODO: Verify output build state } }
private static async Task SumUp(int value) { var valueTable = new ValueTable( _configuration["AzureWebJobsStorage"] , _configuration["TableName"]); await valueTable.InitializeIfNotExists(); CommonSenseResult commonSenseValue = await valueTable.RetrieveValue("JeepCompass", "JeepCompass"); commonSenseValue.Update(value); valueTable.Update(commonSenseValue); }
public void Reload() { using (var connector = Connect()) { var connection = connector.Connection; var server = GetServer(connection); var database = GetDatabase(server); if (!database.Schemas.Contains(_tableConfiguration.Schema)) { var schema = new Schema(database, _tableConfiguration.Schema); database.Schemas.Add(schema); schema.Create(); } _partTable = new PartTable(connection, database, _tableConfiguration); _localeTable = new LocaleTable(connection, database, _tableConfiguration); _valueTable = new ValueTable(connection, database, _tableConfiguration); _logTable = new LogTable(database, _tableConfiguration); } }
public ValueTableRow(ValueTable Owner) { _owner = new WeakReference(Owner); }