public static void Main(String[] args) { Console.WriteLine("CO_Interlocked ..."); Fred f = new Fred( ); Inc inc = new Inc(f); Dec dec = new Dec(f); Thread Incer = new Thread(new ThreadStart(inc.ThreadStart)); Thread Incer2 = new Thread(new ThreadStart(inc.ThreadStart)); Thread Decer = new Thread(new ThreadStart(dec.ThreadStart)); Thread Decer2 = new Thread(new ThreadStart(dec.ThreadStart)); Thread Decer3 = new Thread(new ThreadStart(dec.ThreadStart)); try { Incer.Start( ); Incer2.Start( ); Decer.Start( ); Decer2.Start( ); Decer3.Start( ); Incer.Join( ); Incer2.Join( ); Decer.Join( ); Decer2.Join( ); Decer3.Join( ); } catch (ThreadStateException e) {Console.WriteLine(e);} catch (ThreadInterruptedException e) {Console.WriteLine(e);} Console.WriteLine("... CO_Interlocked"); Environment.ExitCode = 0; return; }
public Node StatementInc() { Expect(TokenCategory.INC); var inc = new Inc(); Expect(TokenCategory.SEMICOL); return(inc); }
public static int RepeatedRecursion(int number, int count, Inc func) { if (count == 0) { return(number); } number = func(number); return(Repeated(number, count - 1, func)); }
public void IncBoolTest() { var parameters = new ParameterCollection() { new Parameter("x", true) }; var inc = new Inc(Variable.X); Assert.Throws <NotSupportedException>(() => inc.Execute(parameters)); }
public void IncCalcTest() { var parameters = new ParameterCollection() { new Parameter("x", 10) }; var inc = new Inc(Variable.X); var result = (double)inc.Execute(parameters); Assert.Equal(11.0, result); Assert.Equal(11.0, parameters["x"]); }
public static int Repeated(int number, int count, Inc func) { var counter = 0; while (counter < count) { number = func(number); counter = counter + 1; } return(number); }
public Node StmtInc() { var result = new Inc() { AnchorToken = Expect(TokenCategory.INC) }; result.Add(new Identifier() { AnchorToken = Expect(TokenCategory.IDENTIFIER) }); Expect(TokenCategory.SEMICOLON); return(result); }
//----------------------------------------------------------- public void Visit(Inc node) { var variableName = node.AnchorToken.Lexeme; if (Table[funName].table.Contains(variableName) || GlobalVars.Contains(variableName)) { VisitChildren(node); } else { throw new SemanticError( "Undeclared variable: " + variableName, node.AnchorToken); } }
public string Visit(Inc node) { var variableName = node[0].AnchorToken.Lexeme; var sb = new StringBuilder(); var props = FunTable[currentFunction]; if (props.reference.ContainsKey(variableName)) { sb.Append($" local.set ${variableName}\n"); } else { sb.Append($" global.set ${variableName}\n"); } return(Visit((dynamic)node[0]) + $" i32.const 1\n" + $" i32.add\n" + sb.ToString()); }
private void label1_DragDrop(object sender, DragEventArgs e) { this.Activate(); string[] s = (string[])e.Data.GetData(DataFormats.FileDrop, false); ArrayList imgpaths = new ArrayList(); foreach (string fpath in s) { if (Inc.IsWebImg(fpath)) { imgpaths.Add(fpath); } } if (imgpaths.Count != 0) { foreach (string item in imgpaths) { Inc.ImgToBase64(item); } MessageBox.Show("转换完成!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
public static void Run(Module module) { var functions = module.GetFunctionEnumerator(); while (functions.MoveNext()) { Block block = functions.Current.Code; var maths = from Statement s in block where s is Add || s is Sub select s; foreach (MathStatement op in maths) { Immediate imm = op.RValue as Immediate; if (imm != null) { int immValue = int.Parse(imm.ToString()); if (immValue <= 4) { int offset = block.Statements.IndexOf(op); block.Statements.Remove(op); for (int i = 0; i < immValue; i++) { Statement replacement = null; if (op is Sub) { replacement = new Dec(op.LValue); } else { replacement = new Inc(op.LValue); } block.Statements.Insert(offset, replacement); } } } } } }
static void Main(string[] args) { if (args.Length != 0) { string a = Inc.IsCssOrImg(args[0].ToString()).ToString(); switch (a) { case "img": Inc.ImgToBase64(args[0].ToString()); break; case "css": Inc.Base64ToImg(args[0].ToString(), Inc.GenerateTimeStamp()); break; } } else { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); } }
private void label2_DragDrop(object sender, DragEventArgs e) { this.Activate(); string[] s = (string[])e.Data.GetData(DataFormats.FileDrop, false); ArrayList csspaths = new ArrayList(); foreach (string csslj in s) { if (Path.GetExtension(csslj) == ".css" || Path.GetExtension(csslj) == ".txt") { csspaths.Add(csslj); } } if (csspaths.Count != 0) { int j = 0; foreach (string item in csspaths) { j++; Inc.Base64ToImg(item, j.ToString()); } MessageBox.Show("转换完成!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); } }
/// <summary> /// Analyzes the specified expression. /// </summary> /// <param name="exp">The expression.</param> /// <returns> /// The result of analysis. /// </returns> /// <exception cref="System.NotSupportedException">Always.</exception> public virtual TResult Analyze(Inc exp) { throw new NotSupportedException(); }
/// <summary> /// Analyzes the specified expression. /// </summary> /// <param name="exp">The expression.</param> /// <returns>The result of analysis.</returns> public string Analyze(Inc exp) { return(ToString(exp, "{0}++")); }
public void TestIncNumber() { var exp = new Inc(new Number(3)); Test(exp, ResultType.Number); }
public void IncToString() { var exp = new Inc(Variable.X); Assert.Equal("x++", exp.ToString(commoonFormatter)); }
public void Visit(Inc node) { Visit((dynamic)node[0]); }
public bool Equals(Inc other) { return(Register == other.Register); }
protected static bool Add <T>(SortedDictionary <DateTime, T> dict, DateTime key, Inc <T> incrementor, T defaultvalue) { T count = default(T); bool result = dict.TryGetValue(key, out count); if (result) { count = incrementor(count); } else { count = defaultvalue; } dict[key] = count; return(result); }
//----------------------------------------------------------- public string Visit(Inc node) { return("\t\tldloc '" + node.AnchorToken.Lexeme + "'\n" + "\t\tldc.i4.1\n" + "\t\tadd.ovf\n"); }
public ISearchParameterGeneric Parse(Hl7.Fhir.Rest.SearchParams SearchParams) { this.ParameterList = new List <Tuple <string, string> >(); //We need to go through the SearchParams.Parameters and pull out the //includes. This is because the API correctly pulls out the normal '_includes' //into it's set property yet '_includes:recurse' incorrectly are placed in the //SearchParams.Parameters list. if (SearchParams.Include != null && SearchParams.Include.Count > 0) { if (this.Include == null) { this.Include = new List <Tuple <string, string> >(); } foreach (var Inc in SearchParams.Include) { this.Include.Add(new Tuple <string, string>(SearchParams.SEARCH_PARAM_INCLUDE, Inc.Trim())); } } if (SearchParams.RevInclude != null && SearchParams.RevInclude.Count > 0) { if (this.RevInclude == null) { this.RevInclude = new List <Tuple <string, string> >(); } foreach (var Inc in SearchParams.RevInclude) { this.RevInclude.Add(new Tuple <string, string>(SearchParams.SEARCH_PARAM_REVINCLUDE, Inc.Trim())); } } foreach (var Para in SearchParams.Parameters) { bool IsNoramlParameter = true; if (ParseIncludeSearchParameters(Para.Item1, Para.Item2) != null) { if (this.Include == null) { this.Include = new List <Tuple <string, string> >(); } this.Include.Add(ParseIncludeSearchParameters(Para.Item1, Para.Item2)); IsNoramlParameter = false; } if (ParseRevIncludeSearchParameters(Para.Item1, Para.Item2) != null) { if (this.RevInclude == null) { this.RevInclude = new List <Tuple <string, string> >(); } this.RevInclude.Add(ParseRevIncludeSearchParameters(Para.Item1, Para.Item2)); IsNoramlParameter = false; } //Add parameters left to the main search parameter list if (IsNoramlParameter) { this.ParameterList.Add(Para); } } this.Sort = SearchParams.Sort; this.Count = SearchParams.Count; this.SummaryType = SearchParams.Summary; return(this); }
public void IncNumberTest() { var inc = new Inc(new Number(1)); Assert.Equal(2.0, inc.Execute()); }