コード例 #1
0
    static void Main(string[] args)
    {
        if (args.Length == 0)
            PrintUsage ();

        filename = args[0];
        if (!File.Exists (filename)) {
            Console.WriteLine ("File not found: {0}", filename);
            return;
        }

        string lang = (args.Length > 1)?  args[1] : "c-sharp";
        language = SourceLanguageManager.Default.GetLanguage (lang);
        if (language == null) {
            Console.WriteLine ("Invalid language ID: {0}", lang);
            return;
        }

        if (args.Length > 2)
            PrintUsage ();

        Application.Init ();
        new SourceViewTest ();
        Application.Run ();
    }
コード例 #2
0
        protected bool CheckIncomingParameters()
        {
            // check that the root item is specified and exists
            // make sure the target language is different from the source language (as long as not adding all other languages)
            lblMessage.Visible = false;

            if (String.IsNullOrEmpty(txtItemPath.Text))
            {
                lblMessage.Visible = true;
                lblMessage.Text    = "Please enter a path.";
                return(false);
            }
            var rootItem = RootItem;

            if (rootItem == null)
            {
                lblMessage.Visible = true;
                lblMessage.Text    = "Cannot find root item: /sitecore" + txtItemPath.Text;
                return(false);
            }


            if ((Action != "DeleteTarget") && !AddAllOtherLanguages && SourceLanguage.Equals(TargetLanguage))
            {
                lblMessage.Visible = true;
                lblMessage.Text    = "Source and Target languages should not be identical";
                return(false);
            }

            return(true);
        }
コード例 #3
0
        public void Start()
        {
            ConsoleWriteLine("Checking \'" + SourceFile + "\'...");
            int line = 0;

            using (StreamReader streamReader = new StreamReader(SourceFile))
            {
                while (!streamReader.EndOfStream)
                {
                    line++;
                    string lineText = streamReader.ReadLine();
                    if (lineText == null)
                    {
                        continue;
                    }
                    lineText = lineText.Replace(SourceLanguage.ToString(), TargetLanguage.ToString());
                    _lines.Add(lineText);
                    //if (lineText.Contains("\"") && lineText.Contains(".Add"))
                    //    ConsoleWriteLine(line + ": " + GetSourceText(lineText));
                    //else
                    //    ConsoleWriteLine(line + ": " + lineText);
                }
            }
            ProcessLines();
        }
コード例 #4
0
        public ShowTextDialog(string text, string mimeType)
        {
            this.Build();

            SourceLanguagesManager lm   = new SourceLanguagesManager();
            SourceLanguage         lang = null;

            if (String.IsNullOrEmpty(mimeType))
            {
                lang = lm.GetLanguageFromMimeType(mimeType);
            }

            SourceBuffer buf = null;

            if (lang == null)
            {
                SourceTagTable table = new SourceTagTable();
                buf = new SourceBuffer(table);
            }
            else
            {
                buf           = new SourceBuffer(lang);
                buf.Highlight = true;
            }
            sourceView = new SourceView(buf);
            sourceView.ShowLineNumbers = true;
            sourceView.Editable        = false;

            vboxContent.PackStart(sourceView, true, true, 0);
            vboxContent.ShowAll();
            if (text != null)
            {
                sourceView.Buffer.Text = text;
            }
        }
コード例 #5
0
        public static string[] GetLanguageKeywords(SourceLanguage language)
        {
            switch (language)
            {
            case SourceLanguage.CSharp:
            {
                return(new string[2]
                    {
                        "class extends implements import interface new case do while else if for in switch throw get set function var try catch finally while with default break continue delete return each const namespace package include use is as instanceof typeof author copy default deprecated eventType example exampleText exception haxe inheritDoc internal link mtasc mxmlc param private return see serial serialData serialField since throws usage version langversion playerversion productversion dynamic private public partial static intrinsic internal native override protected AS3 final super this arguments null Infinity NaN undefined true false abstract as base bool break by byte case catch char checked class const continue decimal default delegate do double descending explicit event extern else enum false finally fixed float for foreach from goto group if implicit in int interface internal into is lock long new null namespace object operator out override orderby params private protected public readonly ref return switch struct sbyte sealed short sizeof stackalloc static string select this throw true try typeof uint ulong unchecked unsafe ushort using var virtual volatile void while where yield",
                        "void Null ArgumentError arguments Array Boolean Class Date Error EvalError Function int Math Namespace Number Object RangeError ReferenceError RegExp SecurityError String SyntaxError TypeError uint XML XMLList Boolean Byte Char DateTime Decimal Double Int16 Int32 Int64 IntPtr SByte Single UInt16 UInt32 UInt64 UIntPtr Void Path File System Runtime"
                    });
            }

            case SourceLanguage.Python:
            {
                return(new string[2]
                    {
                        "class finally is return continue for lambda try def from nonlocal while and del global not with as elif if or yield assert else import pass break except in raise",
                        "False True None Runtime"
                    });
            }

            default: return(new string[0] {
                });
            }
        }
コード例 #6
0
        /// <summary>
        /// Initialize the variables.
        /// </summary>
        /// <param name="program">The source Boogie program.</param>
        /// <param name="sourceLanguage">The source language of the input program.</param>
        /// <param name="disableInspection">Disables inspection of programmer inserted barriers.</param>
        /// <param name="disableGridBarriers">Disables grid-level barriers during instrumentation.</param>
        /// <param name="useAxioms">Use axioms for instrumentation instead of variable assignments.</param>
        public Instrumentor(Microsoft.Boogie.Program program, SourceLanguage sourceLanguage,
                            bool disableInspection, bool disableGridBarriers, bool useAxioms)
        {
            this.program             = program;
            this.sourceLanguage      = sourceLanguage;
            this.disableInspection   = disableInspection;
            this.disableGridBarriers = disableGridBarriers;
            this.useAxioms           = useAxioms;

            analyzer = new GraphAnalyzer(program);
            foreach (Declaration declaration in program.TopLevelDeclarations)
            {
                if (declaration is Procedure)
                {
                    Procedure procedure = declaration as Procedure;
                    if (procedure.Name == "$bugle_barrier")
                    {
                        barrier_definition = procedure;
                    }
                    else if (procedure.Name == "$bugle_grid_barrier")
                    {
                        grid_barrier_definition = procedure;
                    }
                }
            }

            _1bv1 = new LiteralExpr(Token.NoToken, BigNum.ONE, 1);

            Logger.Log($"Blocks;{program.Blocks().Count()}");
            Logger.Log($"Commands;{program.Blocks().Sum(x => x.Cmds.Count)}");
        }
コード例 #7
0
ファイル: Program.cs プロジェクト: spicysoft/h5-count-shape
        internal static string ExtensionForLanguage(SourceLanguage lang)
        {
            switch (lang)
            {
            case SourceLanguage.JavaScript:
                return(".js");

            case SourceLanguage.CPlusPlus:
                return(".cpp");

            case SourceLanguage.CPlusPlusHeader:
                return(".h");

            case SourceLanguage.CSharp:
                return(".cs");

            case SourceLanguage.JSDoc:
                return(".jsdoc");

            case SourceLanguage.TypeScriptDefinition:
                return(".d.ts");

            case SourceLanguage.ExportsList:
                return(".exportlist");
            }
            throw new Exception();
        }
コード例 #8
0
        public void ConstructorTest()
        {
            Int32 quoteID = 25;
            SourceLanguage sourceLanguage = new SourceLanguage("en-gb");
            TargetLanguage[] targetLanguage = new TargetLanguage[2] { new TargetLanguage("en-us"),
                                                                      new TargetLanguage("it-it")};
            Int32 totalTranslations = 14;
            Int32 translationCredit = 4;
            String currency = "USD";
            Decimal totalCost = 100.54m;
            Decimal prepaidCredit = 30.4m;
            Decimal amountDue = 1.4m;
            DateTime creationDate = DateTime.Now;

            var projects = new List<Project>();

            var quote = new Quote(quoteID: quoteID,
                                 creationDate: creationDate,
                                 totalTranslations: totalTranslations,
                                 translationCredit: translationCredit,
                                 currency: currency,
                                 totalCost: totalCost,
                                 prepaidCredit: prepaidCredit,
                                 amountDue: amountDue,
                                 projects: projects);

            Assert.AreEqual(quote.QuoteID, quoteID);
            Assert.AreEqual(quote.TotalTranslations, totalTranslations);
            Assert.AreEqual(quote.TranslationCredit, translationCredit);
            Assert.AreEqual(quote.Currency, currency);
            Assert.AreEqual(quote.TotalCost, totalCost);
            Assert.AreEqual(quote.PrepaidCredit, prepaidCredit);
            Assert.AreEqual(quote.AmountDue, amountDue);
        }
コード例 #9
0
ファイル: MainWindow.cs プロジェクト: cbguder/tuxmate
        public MainWindow()
            : base(Gtk.WindowType.Toplevel)
        {
            Build();

            Preferences.AddNotify(new GConf.NotifyEventHandler(OnGConfChanged));

            manager  = new SourceLanguageManager();
            language = manager.GetLanguage("c-sharp");
            buffer   = new SourceBuffer(language);

            textView = new SourceView(buffer);
            textView.TabWidth = 4;

            OnGConfChanged(null, null);

            buffer.Changed += new EventHandler(OnBufferChanged);
            buffer.MarkSet += new MarkSetHandler(OnBufferMarkSet);

            scrolledwindow.Add(textView);
            scrolledwindow.ShowAll();

            Focus = textView;
            originalBuffer = "";
            NewFile();
        }
コード例 #10
0
ファイル: Program.cs プロジェクト: cs17resch01003/gpurepair
        /// <summary>
        /// The entry point of the program.
        /// </summary>
        /// <param name="args">The command line arguments.</param>
        public static void Main(string[] args)
        {
            try
            {
                // standard command line options for Boogie
                CommandLineOptions.Install(new GRCommandLineOptions());
                if (!CommandLineOptions.Clo.Parse(args))
                {
                    return;
                }

                CommandLineOptions.Clo.PrintUnstructured = 2;
                if (!CommandLineOptions.Clo.Files.Any())
                {
                    throw new Exception("An input file must be provided!");
                }
                else if (CommandLineOptions.Clo.Files.Count > 1)
                {
                    throw new Exception("GPURepair can work on only one file at a time!");
                }

                Logger.FileName        = CommandLineOptions.Clo.Files.First();
                Logger.DetailedLogging = ((GRCommandLineOptions)CommandLineOptions.Clo).DetailedLogging;

                Microsoft.Boogie.Program program;
                Parser.Parse(Logger.FileName, new List <string>()
                {
                    "FILE_0"
                }, out program);

                CommandLineOptions.Clo.DoModSetAnalysis     = true;
                CommandLineOptions.Clo.PruneInfeasibleEdges = true;

                ResolutionContext context = new ResolutionContext(null);
                program.Resolve(context);

                program.Typecheck();
                new ModSetCollector().DoModSetAnalysis(program);

                // start instrumenting the program
                SourceLanguage sourceLanguage      = ((GRCommandLineOptions)CommandLineOptions.Clo).SourceLanguage;
                bool           disableInspection   = ((GRCommandLineOptions)CommandLineOptions.Clo).DisableInspection;
                bool           disableGridBarriers = ((GRCommandLineOptions)CommandLineOptions.Clo).DisableGridBarriers;
                bool           useAxioms           = ((GRCommandLineOptions)CommandLineOptions.Clo).UseAxioms;

                Instrumentor instrumentor = new Instrumentor(program, sourceLanguage,
                                                             disableInspection, disableGridBarriers, useAxioms);
                instrumentor.Instrument();

                // create the instrumented Boogie IR for the next steps
                using (TokenTextWriter writer = new TokenTextWriter(Logger.FileName.Replace(".gbpl", ".repair.gbpl"), true))
                    program.Emit(writer);
            }
            catch (Exception ex)
            {
                Console.Error.WriteLine(ex.Message);
                Environment.Exit(200);
            }
        }
コード例 #11
0
 public int GeneratedSourceWeight(SourceLanguage lang)
 {
     if (lang != SourceLanguage.TypeScriptDefinition)
     {
         return(0);
     }
     return(100);
 }
コード例 #12
0
 public int GeneratedSourceWeight(SourceLanguage lang)
 {
     if (lang == SourceLanguage.CSharp)
     {
         return(100);
     }
     return(0);
 }
コード例 #13
0
ファイル: SourceView.cs プロジェクト: arleyschrock/opentf
    static public MyTextView CreateNewTextView()
    {
        SourceLanguage lang   = MyTextView.LanguageManager.GetLanguageFromMimeType("text/x-csharp");
        SourceBuffer   buffer = new SourceBuffer(lang);

        buffer.Highlight = true;
        return(new MyTextView(buffer));
    }
コード例 #14
0
 public int GeneratedSourceWeight(SourceLanguage lang)
 {
     if (lang != SourceLanguage.JSDoc)
     {
         return(0);
     }
     return(100);
 }
コード例 #15
0
 public string GetGeneratedSource(SourceLanguage lang)
 {
     if (lang != SourceLanguage.JSDoc)
     {
         return(String.Empty);
     }
     return(docStr.ToString());
 }
コード例 #16
0
 public string GetGeneratedSource(SourceLanguage lang)
 {
     if (lang == SourceLanguage.CSharp)
     {
         return(csharpSrc.ToString());
     }
     return(null);
 }
コード例 #17
0
        public void ProcessOneCommand()
        {
            SourceLanguage syntaxType = GetSyntaxType();

            if (syntaxType == SourceLanguage.Unknown)
            {
                return;
            }

            WriteLine("TCPDEBUG: SockClient type=" + syntaxType);
            if (syntaxType == SourceLanguage.Lisp)
            {
                try
                {
                    tcpStreamWriter.WriteLine("200 " + botclient.evalLispReaderString(new ScopedTextReader(this.tcpStreamReader)));
                }
                catch (Exception e)
                {
                    tcpStreamWriter.WriteLine("500 \"" + e.ToString().Replace("\\", "\\\\").Replace("\"", "\\\"") + "\"");
                }
                return;
            }
            if (syntaxType == SourceLanguage.Xml)
            {
                try
                {
                    tcpStreamWriter.WriteLine(botclient.evalXMLString(new ScopedTextReader(this.tcpStreamReader)));
                }
                catch (Exception e)
                {
                    WriteLine("error occured: " + e.Message);
                    WriteLine("        Stack: " + e.StackTrace.ToString());
                    tcpStreamWriter.WriteLine("<error><response></response><errormsg>" + e.Message.ToString() +
                                              "</errormsg>\n<stack>\n" + e + "\n</stack>\n</error>");
                }
                return;
            }
            WriteLine("TCPDEBUG: SockClient do read text");
            string clientMessage = tcpStreamReader.ReadLine().Trim();

            WriteLine("TCPDEBUG: SockClient read text " + clientMessage);
            try
            {
                if (clientMessage.Contains("xml") || clientMessage.Contains("http:"))
                {
                    tcpStreamWriter.WriteLine(botclient.XmlInterp.EvaluateXmlDocument(clientMessage));
                }
                else
                {
                    tcpStreamWriter.WriteLine(EvaluateCommand(clientMessage));
                }
            }
            catch (Exception e)
            {
                tcpStreamWriter.WriteLine("500 \"" + e.ToString().Replace("\\", "\\\\").Replace("\"", "\\\"") + "\"");
            }
        }
コード例 #18
0
 /// <summary>
 /// Initializes a new instance of the <see cref="GenerateVersioningInfo"/> class.
 /// </summary>
 public GenerateVersioningInfo()
 {
     // Default instance initialization
     language = SourceLanguage.CSharp;
     outputName = DefaultOutputName;
     outputPath = null;
     overrideExisiting = true;
     versioningFile = null;
 }
コード例 #19
0
        public static string GetLanguageName(SourceLanguage language)
        {
            switch (language)
            {
            case SourceLanguage.CSharp: return("C#");

            default: return(language.ToString());
            }
        }
コード例 #20
0
 public override int GetHashCode()
 {
     unchecked
     {
         int result = (SourceLanguage != null ? SourceLanguage.GetHashCode() : 0);
         result = (result * 397) ^ (TargetLanguage != null ? TargetLanguage.GetHashCode() : 0);
         return(result);
     }
 }
コード例 #21
0
 public int GeneratedSourceWeight(SourceLanguage lang)
 {
     if (lang == SourceLanguage.CPlusPlus ||
         lang == SourceLanguage.CPlusPlusHeader)
     {
         return(100);
     }
     return(0);
 }
コード例 #22
0
ファイル: OpSource.cs プロジェクト: gleblebedev/Toe.SPIRV
        /// <summary>
        /// Calculate number of words to fit complete instruction bytecode.
        /// </summary>
        /// <returns>Number of words in instruction bytecode.</returns>
        public override uint GetWordCount()
        {
            uint wordCount = 0;

            wordCount += SourceLanguage.GetWordCount();
            wordCount += Version.GetWordCount();
            wordCount += File.GetWordCount();
            wordCount += Value?.GetWordCount() ?? 0u;
            return(wordCount);
        }
コード例 #23
0
        public SourceFile(string fileName, IEnumerable <ISourceLine> lines, IEnumerable <ISourceClass> classes, SourceLanguage language, ICoverageStats stats)
        {
            Name = fileName;
            var sourceLines = lines as ISourceLine[] ?? lines.ToArray();

            Lines         = sourceLines;
            Classes       = classes;
            Language      = language;
            CoverageStats = stats;
        }
コード例 #24
0
        internal unsafe ShaderModule(SpirvReflectNative.SpvReflectShaderModule module)
        {
            NativeShaderModule = module;

            // Convert to managed
            Generator             = (ReflectGenerator)module.generator;
            EntryPointName        = new string(module.entry_point_name);
            EntryPointId          = module.entry_point_id;
            SourceLanguage        = (SourceLanguage)module.source_language;
            SourceLanguageVersion = module.source_language_version;
            SPIRVExecutionModel   = (ExecutionModel)module.spirv_execution_model;
            ShaderStage           = (ReflectShaderStage)module.shader_stage;
            SourceFile            = new string(module.source_file);
            SourceSource          = new string(module.source_source);

            // Entry point extraction
            EntryPoints = new ReflectEntryPoint[module.entry_point_count];
            for (int i = 0; i < module.entry_point_count; i++)
            {
                EntryPoints[i] = new ReflectEntryPoint()
                {
                    Id                  = module.entry_points[i].id,
                    Name                = new string(module.entry_points[i].name),
                    ShaderStage         = (ReflectShaderStage)module.entry_points[i].shader_stage,
                    SpirvExecutionModel = (ExecutionModel)module.entry_points[i].spirv_execution_model,

                    UsedPushConstants = new uint[module.entry_points[i].used_push_constant_count],
                    UsedUniforms      = new uint[module.entry_points[i].used_uniform_count],

                    DescriptorSets = new ReflectDescriptorSet[module.entry_points[i].descriptor_set_count]
                };
                // Enumerate used push constants
                for (int j = 0; j < module.entry_points[i].used_push_constant_count; j++)
                {
                    EntryPoints[i].UsedPushConstants[j] = module.entry_points[i].used_push_constants[j];
                }
                // Enumerate used uniforms
                for (int j = 0; j < module.entry_points[i].used_uniform_count; j++)
                {
                    EntryPoints[i].UsedUniforms[j] = module.entry_points[i].used_uniforms[j];
                }
                // Enumerate descriptor sets
                for (int j = 0; j < module.entry_points[i].descriptor_set_count; j++)
                {
                    var desc = module.entry_points[i].descriptor_sets[j];
                    EntryPoints[i].DescriptorSets[j].Set      = desc.set;
                    EntryPoints[i].DescriptorSets[j].Bindings = new ReflectDescriptorBinding[desc.binding_count];

                    for (int k = 0; k < desc.binding_count; k++)
                    {
                        EntryPoints[i].DescriptorSets[j].Bindings[k] = new ReflectDescriptorBinding(*desc.bindings[k]);
                    }
                }
            }
        }
コード例 #25
0
 internal static string FormatMethodParameterMatcher(Type paramType, SourceLanguage language)
 {
     if (paramType.IsByRef)
     {
         return(String.Format("ArgExpr.Ref({0})", FormatMethodParameterMatcher(paramType.GetElementType(), language)));
     }
     else
     {
         return(String.Format("ArgExpr.IsAny{0}()", FormatGenericArg(paramType, language)));
     }
 }
コード例 #26
0
        public void UserAgent_is_known()
        {
            var userAgent = new UserAgentBuilder(
                Platform.Analyze(),
                Sdk.Anaylze(),
                SourceLanguage.Analyze(this.GetType().Assembly)).GetUserAgent();

            userAgent.ShouldNotContain("unknown");

            this.output.WriteLine($"UserAgent: {userAgent}");
        }
コード例 #27
0
 /// <inheritdoc/>
 public BitcodeModule CreateBitcodeModule(string moduleId
                                          , SourceLanguage language
                                          , string srcFilePath
                                          , string producer
                                          , bool optimized          = false
                                          , string compilationFlags = ""
                                          , uint runtimeVersion     = 0
                                          )
 {
     return(ModuleCache.CreateBitcodeModule(moduleId, language, srcFilePath, producer, optimized, compilationFlags, runtimeVersion));
 }
コード例 #28
0
 static string GetLanguage(SourceLanguage sourceLanguage)
 {
     if (sourceLanguage == SourceLanguage.FSharp)
     {
         return(fs);
     }
     else if (sourceLanguage == SourceLanguage.VB)
     {
         return(vb);
     }
     return(cs);
 }
コード例 #29
0
ファイル: DslUstConverter.cs プロジェクト: Yikez978/PT.PM
        public UstNode VisitPatternId([NotNull] DslParser.PatternIdContext context)
        {
            string patternId = context.GetText();

            if (SourceLanguage.IsCaseInsensitive() && !patternId.StartsWith("(?i)"))
            {
                patternId = "(?i)" + patternId;
            }
            IdToken result = new PatternIdToken(patternId, context.GetTextSpan());

            return(result);
        }
コード例 #30
0
        /// <summary>
        /// Attempts to translate the text.
        /// </summary>
        public void Translate()
        {
            // Validate source and target languages
            if (string.IsNullOrEmpty(SourceLanguage) ||
                string.IsNullOrEmpty(TargetLanguage) ||
                SourceLanguage.Trim().Equals(TargetLanguage.Trim()))
            {
                throw new Exception("An invalid source or target language was specified.");
            }

            // Delegate to base class
            FetchResource();
        }
コード例 #31
0
ファイル: OpSource.cs プロジェクト: gleblebedev/Toe.SPIRV
 /// <summary>
 /// Write instruction operands into bytecode stream.
 /// </summary>
 /// <param name="writer">Bytecode writer.</param>
 public override void WriteOperands(WordWriter writer)
 {
     SourceLanguage.Write(writer);
     Version.Write(writer);
     if (File != null)
     {
         File.Write(writer);
     }
     if (Value != null)
     {
         Value.Write(writer);
     }
 }
コード例 #32
0
        public string GetSrcLang(string text)
        {
            url = string.Format(AppCache.UrlDetectSourceLanguage, AppCache.Key, text);
            SourceLanguage translate = GetObjectFromAPI <SourceLanguage>(url);

            if (translate.Code.Equals(200))
            {
                return(translate.Lang);
            }
            else
            {
                throw new Exception($"Status code: {translate.Code}");
            }
        }
コード例 #33
0
        public string Translate(string id)
        {
            if (SourceLanguage.Equals(CurrentLanguage))
            {
                return(id);
            }
            var result = InternalTranslate(m_CurrentLanguageLines, id);

            if (m_CurrentTranslit != null)
            {
                result = m_CurrentTranslit.Transliterate(result);
            }
            return(result);
        }
コード例 #34
0
        public static string GetExtension(SourceLanguage language)
        {
            switch (language)
            {
            case SourceLanguage.CSharp: return(".cs");

            case SourceLanguage.Assembly: return(".asm");

            case SourceLanguage.Java: return(".java");

            case SourceLanguage.Python: return(".py");

            default: return(null);
            }
        }
コード例 #35
0
 public SourceLanguage RestoreDefaults(SourceLanguage lang)
 {
     foreach (SourceTag tag in lang.Tags)
     {
         lang.SetTagStyle (tag.Name, lang.GetTagDefaultStyle (tag.Name));
     }
     return lang;
 }
コード例 #36
0
 private void OnRestoreClicked(object sender, EventArgs a)
 {
     currentLanguage = svs.RestoreDefaults (currentLanguage);
     OnStyleChanged (stylesTreeView.Selection, EventArgs.Empty);
 }
コード例 #37
0
 void SetCurrentLanguage(string name)
 {
     currentLanguage = svs.FindLanguage (name);
     SetTreeValues ();
 }
コード例 #38
0
			void SetCurrentLanguage (string name)
			{
				currentLanguage = SourceViewService.FindLanguage (name);
				SetTreeValues ();
			}