public void Start() { NativeShare.Share(); _globalContext.ImageLoaderComponent = globalContainer.ImageLoaderComponent; _globalContext.ImageLoaderComponent.Init(); _globalContext.CourseDetailsModel = new CourseDetailsModel(); var controller = new PreviewSliderController(globalContainer.PreviewSliderContainer); controller.Activate(); _generator.Add(new ReferencesGenerator()); _generator.Add(new ScreenChangerGenerator()); _generator.Add(new FootMenuGenerator()); _generator.Add(new AchievementsGenerator()); _generator.Add(new NotificationGenerator()); _generator.Generate(_globalContext, _controllerCollection, globalContainer); _controllerCollection.Activate(); _globalContext.ScreenChangerModel.SwitchScreen(ScreenType.Profile); }
private void Visit(ForStatement stmt) { var loopStartLabel = Generator.DefineLabel("loopstart"); var indexLocal = Local(stmt.VarName); var toLocal = Generator.DeclareLocal(typeof(ulong), "end"); var previousEndLabel = CurrentLoopEndLabel; var endLabel = CurrentLoopEndLabel = Generator.DefineLabel("forend"); Visit(stmt.From); Generator.Dup(); Generator.Ldobj(typeof(BitsValue)); Generator.Stloc(indexLocal); Visit(stmt.To); BitsValueToNumber(); Generator.Stloc(toLocal); BitsValueToNumber(); Generator.MarkLabel(loopStartLabel); Visit(stmt.Body); // Increment index Generator.Ldc_I8(1); Generator.Conv <ulong>(); Generator.Add(); NumberToBitsValue(); Generator.Ldobj(typeof(BitsValue)); Generator.Stloc(indexLocal); // Check index == max, if true branch to end Generator.Ldloca(indexLocal); BitsValueToNumber(); Generator.Dup(); Generator.Ldloc(toLocal); Generator.Bne_Un(loopStartLabel); Generator.MarkLabel(endLabel); CurrentLoopEndLabel = previousEndLabel; Generator.Pop(); }
private void Visit(SlotExpression expr, Index start = default, Index?end = null) { LoadMachine(); if (expr.Slot == Slots.Memory) { LoadMemory(); } LoadIndex(expr, start); // Calculate range length if (end == null) { Generator.Ldc_I4(1); } else { Generator.Dup(); // Duplicate start index for GetInputs parameter // length = -start + end Generator.Neg(); LoadIndex(expr, end.Value); Generator.Add(); } if (expr.Slot == Slots.In) { Generator.Call(Info.OfMethod <IMachine>(nameof(IMachine.GetInputs), "System.Int32,System.Int32")); } else if (expr.Slot == Slots.Memory) { Generator.Call(Info.OfMethod <IMemory>(nameof(IMemory.Read), "System.Int32,System.Int32")); } else { throw new LogicEngineException("Invalid slot", expr); } ValueToReference(); }
public static int Main(string[] args) { var input_paths = new List <string> (); string output_path = "-"; string generator_name = String.Empty; string source_root_path = null; string reduce_master_path = null; string reduce_retain_path = null; string android_input_strings_xml = null; string android_output_strings_xml = null; string analyer_config_path = null; LocalizationMetadata metadata = null; bool generate_pot = false; bool exclude_po_header = false; bool analyze = false; bool analyzer_warn_as_error = false; bool log = false; bool verbose = false; bool retain_order = false; bool show_help = false; bool count_words = false; int word_count = 0; Generator generator = null; var options = new OptionSet { { "i|input=", "Input directory, search pattern, or file to parse (non-recursive)", v => input_paths.Add(v) }, { "o|output=", "Output file for extracted string resources", v => output_path = v }, { "r|source-root=", "Root directory of source code", v => source_root_path = v }, { "g|generator=", String.Format("Generator to use ({0})", String.Join("|", Generator.GeneratorNames)), v => generator_name = v }, { "retain-order", "Retain the original input string order when generating. " + "Default behavior is to sort strings for better diff support.", v => retain_order = v != null }, { "a|analyze", "Run the string analyzer after generation", v => analyze = v != null }, { "analyzer-config=", "Path to a configuration file for the analyzer; use with --analyze", v => analyer_config_path = v }, { "analyzer-warnaserror", "Treat analyzer warnings as errors", v => analyzer_warn_as_error = v != null }, { "reduce-master=", "Reduce a master localized PO file, " + "keeping only strings defined by another unlocalized PO[T] file", v => reduce_master_path = v }, { "reduce-retain=", "An unlocalized PO[T] file used to " + "determine which strings from reduce-master should be retained", v => reduce_retain_path = v }, { "android-input-strings-xml=", "Input file of unlocalized Android Strings.xml " + "for preserving hand-maintained string resources", v => android_input_strings_xml = v }, { "android-output-strings-xml=", "Output file of localized Android Strings.xml " + "for preserving hand-maintained string resources", v => android_output_strings_xml = v }, { "pot", v => generate_pot = v != null }, { "exclude-po-header", v => exclude_po_header = v != null }, { "l|log", "Display logging", v => log = v != null }, { "m|meta=", "Add localization metadata (key=value)", v => { var parts = v.Split(new [] { '=' }, 2); if (parts != null && parts.Length == 2) { if (metadata == null) { metadata = new LocalizationMetadata(); } metadata.Add(parts[0].Trim(), parts[1].Trim()); } } }, { "wc", "Count words to translate, output goes in the po header and in the console (with -v)", v => count_words = v != null }, { "v|verbose", "Verbose logging", v => verbose = v != null }, { "h|help", "Show this help message and exit", v => show_help = v != null } }; try { options.Parse(args); if (show_help) { Console.WriteLine("Usage: vernacular [OPTIONS]+"); Console.WriteLine(); Console.WriteLine("Options:"); options.WriteOptionDescriptions(Console.Out); return(1); } if (source_root_path != null) { if (!Directory.Exists(source_root_path)) { throw new OptionException("invalid source-root", "source-root"); } source_root_path = new DirectoryInfo(source_root_path).FullName; } generator = Generator.GetGeneratorForName(generator_name.ToLower()); if (generator == null) { throw new OptionException("invalid generator", "generator"); } generator.RetainStringOrder = retain_order; if (generator is PoGenerator) { ((PoGenerator)generator).PotMode = generate_pot; ((PoGenerator)generator).ExcludeHeaderMetadata = exclude_po_header; } if (reduce_master_path != null && reduce_retain_path == null) { throw new OptionException("reduce-retain must be specified if reduce-master is", "reduce-retain"); } else if (reduce_master_path == null && reduce_retain_path != null) { throw new OptionException("reduce-master must be specified if reduce-retain is", "reduce-master"); } else if (reduce_master_path != null && reduce_retain_path != null) { var reduce_master = new PoParser { SourceRootPath = source_root_path }; var reduce_retain = new PoParser { SourceRootPath = source_root_path }; reduce_master.Add(reduce_master_path); reduce_retain.Add(reduce_retain_path); generator.Reduce(reduce_master, reduce_retain); generator.Generate(output_path); return(0); } } catch (OptionException e) { Console.WriteLine("vernacular: {0}", e.Message); Console.WriteLine("Try `vernacular --help` for more information."); return(1); } var parser = new AggregateParser { SourceRootPath = source_root_path }; if (verbose) { parser.LogLevel = 2; } else if (log) { parser.LogLevel = 1; } StringAnalyzer analyzer = null; if (analyze) { try { analyzer = new StringAnalyzer(analyer_config_path, analyzer_warn_as_error); } catch { return(1); } } foreach (var input_path in input_paths) { if (File.Exists(input_path)) { parser.Add(input_path); continue; } var search_pattern = "*"; var dir = input_path; if (!Directory.Exists(dir)) { search_pattern = Path.GetFileName(dir); dir = Path.GetDirectoryName(dir); if (!Directory.Exists(dir)) { continue; } } foreach (var path in Directory.EnumerateFiles(dir, search_pattern, SearchOption.TopDirectoryOnly)) { parser.Add(path); } } if (metadata != null) { generator.Add(metadata); } foreach (var localization_unit in parser.Parse()) { var localized_string = localization_unit as LocalizedString; if (count_words && localized_string != null) { var separators = new char[] { '.', '?', '!', ' ', ';', ':', ',' }; if (localized_string.UntranslatedSingularValue != null) { word_count += localized_string.UntranslatedSingularValue.Split(separators, StringSplitOptions.RemoveEmptyEntries). Count(); } if (localized_string.UntranslatedPluralValue != null) { word_count += localized_string.UntranslatedPluralValue.Split(separators, StringSplitOptions.RemoveEmptyEntries).Count(); } } generator.Add(localization_unit); if (analyzer != null) { analyzer.Add(localized_string); } } if (analyzer != null) { var error_count = analyzer.Analyze(); if (error_count > 0) { Console.WriteLine("The analyzer reported {0} errors. Generation skipped.", error_count); return(1); } } if (count_words) { var word_count_metadata = new LocalizationMetadata(); word_count_metadata.Add("Word-Count", word_count.ToString(CultureInfo.InvariantCulture)); generator.Add(word_count_metadata); } generator.Generate(output_path); if (generator is AndroidGenerator && android_input_strings_xml != null && android_output_strings_xml != null) { ((AndroidGenerator)generator).LocalizeManualStringsXml(android_input_strings_xml, android_output_strings_xml); } if (verbose && count_words) { Console.WriteLine("Total of words in untranslated messages: {0} words.", word_count); } return(0); }
private void Visit(OperatorExpression expr) { var convert = true; if (expr.Operator == Operator.Assign) { VisitAssignment(expr.Left, expr.Right); } else if (expr.Operator == Operator.BitShiftLeft || expr.Operator == Operator.BitShiftRight) { DoBitshift(); convert = false; } else if (!DoComparison()) { Visit(expr.Left); BitsValueToNumber(); Visit(expr.Right); BitsValueToNumber(); switch (expr.Operator) { case Operator.Add: Generator.Add(); break; case Operator.Subtract: Generator.Sub(); break; case Operator.Modulo: Generator.Rem(true); break; case Operator.Multiply: Generator.Mul(); break; case Operator.Divide: Generator.Div(true); break; case Operator.And: Generator.And(); break; case Operator.Or: Generator.Or(); break; case Operator.Xor: Generator.Xor(); break; } } if (convert) { NumberToBitsValue(); } void DoBitshift() { // Load left member (number), and store in Temp1 Visit(expr.Left); Generator.Dup(); Generator.Stloc(Temp1); BitsValueToNumber(); // Load right member (shift amount), and store in Temp2 Visit(expr.Right); BitsValueToNumber(); Generator.Dup(); Generator.Stloc(Temp2); // Do the shift if (expr.Operator == Operator.BitShiftLeft) { Generator.Shl(); } else { Generator.Shr(true); } // Calculate result length (add or subtract shift amount from operand length) Generator.Ldloc(Temp1); ValueLength(); Generator.Ldloc(Temp2); Generator.Conv <int>(); if (expr.Operator == Operator.BitShiftLeft) { Generator.Add(); } else { Generator.Sub(); } NumberToBitsValue(true); } bool DoComparison() { switch (expr.Operator) { case Operator.NotEquals: EmitCompare(() => Generator.Ldc_I4(1), () => { Generator.Ceq(); Generator.Sub(); }); break; case Operator.Equals: EmitCompare(null, () => Generator.Ceq()); break; case Operator.Greater: EmitCompare(null, () => Generator.Cgt(true)); break; case Operator.GreaterOrEqual: EmitCompare(null, () => { Generator.Clt(true); Generator.Ldc_I4(0); Generator.Ceq(); }); break; case Operator.Lesser: EmitCompare(null, () => Generator.Clt(true)); break; case Operator.LesserOrEqual: EmitCompare(null, () => { Generator.Cgt(true); Generator.Ldc_I4(0); Generator.Ceq(); }); break; default: return(false); } return(true); } void EmitCompare(Action before, Action after) { before?.Invoke(); Visit(expr.Left); BitsValueToNumber(); Visit(expr.Right); BitsValueToNumber(); after?.Invoke(); Generator.Conv <ulong>(); } }
public static void Main(string [] args) { var input_paths = new List <string> (); string output_path = "-"; string generator_name = String.Empty; string source_root_path = null; string reduce_master_path = null; string reduce_retain_path = null; string android_input_strings_xml = null; string android_output_strings_xml = null; bool analyze = false; bool log = false; bool verbose = false; bool show_help = false; Generator generator = null; var options = new OptionSet { { "i|input=", "Input directory, search pattern, or file to parse (non-recursive)", v => input_paths.Add(v) }, { "o|output=", "Output file for extracted string resources", v => output_path = v }, { "r|source-root=", "Root directory of source code", v => source_root_path = v }, { "g|generator=", String.Format("Generator to use ({0})", String.Join("|", Generator.GeneratorNames)), v => generator_name = v }, { "a|analyze", "Run the string analyzer after generation", v => analyze = v != null }, { "reduce-master=", "Reduce a master localized PO file, " + "keeping only strings defined by another unlocalized PO[T] file", v => reduce_master_path = v }, { "reduce-retain=", "An unlocalized PO[T] file used to " + "determine which strings from reduce-master should be retained", v => reduce_retain_path = v }, { "android-input-strings-xml=", "Input file of unlocalized Android Strings.xml " + "for preserving hand-maintained string resources", v => android_input_strings_xml = v }, { "android-output-strings-xml=", "Output file of localized Android Strings.xml " + "for preserving hand-maintained string resources", v => android_output_strings_xml = v }, { "l|log", "Display logging", v => log = v != null }, { "v|verbose", "Verbose logging", v => verbose = v != null }, { "h|help", "Show this help message and exit", v => show_help = v != null } }; try { options.Parse(args); if (show_help) { Console.WriteLine("Usage: vernacular [OPTIONS]+"); Console.WriteLine(); Console.WriteLine("Options:"); options.WriteOptionDescriptions(Console.Out); return; } if (source_root_path != null) { if (!Directory.Exists(source_root_path)) { throw new OptionException("invalid source-root", "source-root"); } source_root_path = new DirectoryInfo(source_root_path).FullName; } generator = Generator.GetGeneratorForName(generator_name.ToLower()); if (generator == null) { throw new OptionException("invalid generator", "generator"); } if (reduce_master_path != null && reduce_retain_path == null) { throw new OptionException("reduce-retain must be specified if reduce-master is", "reduce-retain"); } else if (reduce_master_path == null && reduce_retain_path != null) { throw new OptionException("reduce-master must be specified if reduce-retain is", "reduce-master"); } else if (reduce_master_path != null && reduce_retain_path != null) { var reduce_master = new PoParser { SourceRootPath = source_root_path }; var reduce_retain = new PoParser { SourceRootPath = source_root_path }; reduce_master.Add(reduce_master_path); reduce_retain.Add(reduce_retain_path); generator.Reduce(reduce_master, reduce_retain); generator.Generate(output_path); return; } } catch (OptionException e) { Console.WriteLine("vernacular: {0}", e.Message); Console.WriteLine("Try `vernacular --help` for more information."); return; } var parser = new AggregateParser { SourceRootPath = source_root_path }; if (verbose) { parser.LogLevel = 2; } else if (log) { parser.LogLevel = 1; } StringAnalyzer analyzer = null; if (analyze) { analyzer = new StringAnalyzer(); } foreach (var input_path in input_paths) { if (File.Exists(input_path)) { parser.Add(input_path); continue; } var search_pattern = "*"; var dir = input_path; if (!Directory.Exists(dir)) { search_pattern = Path.GetFileName(dir); dir = Path.GetDirectoryName(dir); if (!Directory.Exists(dir)) { continue; } } foreach (var path in Directory.EnumerateFiles(dir, search_pattern, SearchOption.TopDirectoryOnly)) { parser.Add(path); } } foreach (var localized_string in parser.Parse()) { generator.Add(localized_string); if (analyzer != null) { analyzer.Add(localized_string); } } if (analyzer != null) { analyzer.Analyze(); } generator.Generate(output_path); if (generator is AndroidGenerator && android_input_strings_xml != null && android_output_strings_xml != null) { ((AndroidGenerator)generator).LocalizeManualStringsXml(android_input_strings_xml, android_output_strings_xml); } }
public void AddHealth(float _howMuch) { moduleHealth.Add(_howMuch); }