/* reads the contents of the file identified by a file register
  * and stores it in a string register in the Puppet Master */
 public void Read(int fileRegister, Semantics semantics, int contentRegister)
 {
     if (ReadHandler != null)
     {
         ReadHandler(fileRegister, semantics, contentRegister);
     }
 }
Example #2
0
 /// <summary>
 /// Write instruction operands into bytecode stream.
 /// </summary>
 /// <param name="writer">Bytecode writer.</param>
 public override void WriteOperands(WordWriter writer)
 {
     Pointer.Write(writer);
     Memory.Write(writer);
     Semantics.Write(writer);
     Value.Write(writer);
 }
Example #3
0
        private void addPixelShaderButton_Click(object sender, EventArgs e)
        {
            EffectComponent component = new EffectComponent();

            component.Name     = "NewPixelShader";
            component.IsInline = false;

            HlslSemantic outputSemantic = Semantics.Find("COLOR", true, false);

            outputSemantic.ResourceNumber = 0;
            component.ReturnType.Add(new EffectParameterDefinition(
                                         "Color",
                                         outputSemantic.Type,
                                         outputSemantic));

            mEffectDefinition.PixelShaders.Add(component);

            effectEdit_pixelShaderListChanged(sender, e);

            pixelShadersList.SelectedItem = component;

            if (mEffectDefinition.PixelShaders.Count > 0)
            {
                pixelShaderEditor.Enabled = true;
            }
        }
Example #4
0
 public void Start()
 {
     Semantics.Set();
     Meta.Set();
     Content.Set();
     PostContent.Set();
 }
Example #5
0
        private void addVertexShaderButton_Click(object sender, EventArgs e)
        {
            EffectComponent component = new EffectComponent();

            component.Name     = "NewVertexShader";
            component.IsInline = false;

            HlslSemantic inputSemantic = Semantics.Find("POSITION", true, true);

            inputSemantic.ResourceNumber = 0;
            component.Parameters.Add(new EffectParameterDefinition(
                                         "Position",
                                         inputSemantic.Type,
                                         inputSemantic));
            HlslSemantic outputSemantic = Semantics.Find("POSITION", true, false);

            outputSemantic.ResourceNumber = 0;
            component.ReturnType.Add(new EffectParameterDefinition(
                                         "Position",
                                         outputSemantic.Type,
                                         outputSemantic));

            mEffectDefinition.VertexShaders.Add(component);

            effectEdit_vertexShaderListChanged(sender, e);

            vertexShadersList.SelectedItem = component;

            if (mEffectDefinition.VertexShaders.Count > 0)
            {
                vertexShaderEditor.Enabled = true;
            }
        }
Example #6
0
        /// <summary>
        /// Execute all synthesized codes on the merge conflict
        /// </summary>
        /// <param name="input">Merge conflict</param>
        /// <param name="programList">List of synthesized programs</param>
        /// <param name="type">1=include, 2= macro related conflicts</param>
        /// <returns>List of all matched resolutions</returns>
        internal static List <IReadOnlyList <Node> > LoadAllSynthesizedCode(MergeConflict input, List <Program> programList, int type)
        {
            List <IReadOnlyList <Node> > outputQueue = new List <IReadOnlyList <Node> >();

            if (type == 1)
            {
                outputQueue.Add(programList[0].Run(input));
                outputQueue.Add(programList[1].Run(input));
                outputQueue.Add(programList[2].Run(input));
                outputQueue.Add(programList[3].Run(input));
                if (Semantics.NodeValue(input.Upstream[0], "path") != "")
                {
                    outputQueue.Add(programList[4].Run(input));
                }
                outputQueue.Add(programList[5].Run(input));
                outputQueue.Add(programList[6].Run(input));
                outputQueue.Add(programList[7].Run(input));
                outputQueue.Add(programList[8].Run(input));
            }
            else
            {
                outputQueue.Add(programList[9].Run(input));
                outputQueue.Add(programList[10].Run(input));
            }
            return(outputQueue);
        }
Example #7
0
 private void tryExpectValue(Semantics expected, Semantics expect)
 {
     if (expected != expect)
     {
         throw new Exception(string.Format("Expecting token {0} but it is {1} with surrounding tokens '{2}' and '{3}'", expected, expect, Previous.Value, Next.Value));
     }
 }
Example #8
0
        /// <summary>
        /// Gets the symbol of a node.
        /// </summary>
        /// <param name="node">The target node.</param>
        /// <param name="identifierName">An optional identifier name.</param>
        /// <returns>The associated symbol.</returns>
        private Symbol GetSymbol(SyntaxNode node, string identifierName = null)
        {
            Symbol symbol = null;

            // find symbol of declaration
            symbol = ((ISemanticModel)Semantics).GetDeclaredSymbol(node) as Symbol;

            if (symbol == null)
            {
                // find symbol of an expression
                var symbolInfo = ((ISemanticModel)Semantics).GetSymbolInfo(node);
                symbol = symbolInfo.Symbol as Symbol;

                if (symbol == null)
                {
                    if (symbolInfo.CandidateSymbols.Count == 1)
                    {
                        symbol = symbolInfo.CandidateSymbols[0] as Symbol;
                    }

                    // attempt using symbol lookup
                    if (symbol == null && identifierName != null)
                    {
                        symbol = Semantics.LookupSymbols(node.Span.Start, name: identifierName).SingleOrDefault();
                    }
                }
            }

            return(symbol);
        }
Example #9
0
        /// <summary>
        /// -99 = null input
        /// -1 = wrong type
        /// 0 = same type, wrong id
        /// 1 = same reference (same id, same type)
        /// </summary>
        /// <param name="obj"></param>
        /// <returns></returns>
        public int CompareTo(IDictata other)
        {
            if (other != null)
            {
                try
                {
                    if (other.GetType() != GetType())
                    {
                        return(-1);
                    }

                    if (other.Name.Equals(Name, StringComparison.InvariantCultureIgnoreCase) && other.WordType == WordType &&
                        Semantics.Count() == other.Semantics.Count() && Semantics.All(semantic => other.Semantics.Contains(semantic)))
                    {
                        return(1);
                    }

                    return(0);
                }
                catch (Exception ex)
                {
                    LoggingUtility.LogError(ex);
                }
            }

            return(-99);
        }
 /* reads the content of file whose metadata is stored in
 * file-register1, and writes as new contents of the file with
 * metadata in file-register2, the concatenation of the content of
 * the first file with a string (to be stored as a byte array),
 * that serves as salt to make them slightly different */
 public void Copy(int fileRegister1, Semantics semantics, int fileRegister2, byte[] salt)
 {
     if (CopyHandler != null)
     {
         CopyHandler(fileRegister1, semantics, fileRegister2, salt);
     }
 }
Example #11
0
 public Sentence(string text, Semantics semantics)
 {
     Words = new List <Word>();
     foreach (var t in text.Split(semantics.WordEnding))
     {
         Words = Words.Add(new Word(t));
     }
 }
Example #12
0
        public DataDTO Read(string localFileName, Semantics semantics)
        {
            freezer.WaitOne();
            Data data = files[localFileName];

            Console.WriteLine("\"" + localFileName + "\" read by a client.");
            return(new DataDTO(data.version, data.content));
        }
Example #13
0
        static void Main()
        {
            var result  = Semantics.Substring("Hello World", Semantics.RegexFunction(0, SimpleLearner.regexList[0], "Hello World"), 2);
            var myRegex = new Regex(@"[A-Z]", RegexOptions.Compiled);
            var matches = myRegex.Matches("dies ist ein test, Wie viele grossbuchstaben vorkommen...");

            Console.WriteLine();
        }
Example #14
0
 public Paragraph(string text, Semantics semantics)
 {
     Sentences = new List <Sentence>();
     foreach (var t in text.Split(new [] { semantics.SentenceEnding }, StringSplitOptions.None))
     {
         Sentences = Sentences.Add(new Sentence(t, semantics));
     }
 }
Example #15
0
 /// <summary>
 /// Gets semantic type names (qualified with Vocabulary ID) for the Schema.
 /// </summary>
 /// <returns>The semantic type names.</returns>
 public string[] GetSemanticTypeNames()
 {
     if (_semanticTypeNames == null)
     {
         _semanticTypeNames = Semantics.Select(s => SemanticMapping.GetQualifiedTypeName(s.Entity, s.Prefix, Localization)).ToArray();
     }
     return(_semanticTypeNames);
 }
Example #16
0
        /// <summary>
        /// Load the output after running all the testcases. If there is no pattern returned then the default behavior is concatenating the main and the
        /// for branch. Since we only concentrate on the structural conflicts, the order of the conflicts do not matter. So, we validate the solution
        /// with the resolved conflict by main followed by fork and fork followed by main.
        /// </summary>
        /// <param name="input">Merge conflict</param>
        /// <param name="programList">List of synthesized programs</param>
        /// <param name="testcasePath">Location of the testcase</param>
        /// <param name="number">Test case index</param>
        /// <returns>True if matches with the resolution provided by user, false otherwise</returns>
        public static bool ValidOutput(MergeConflict input, List <Program> programList, string testcasePath, string number)
        {
            string resolvedFilename                  = testcasePath + number + "_Resolved.txt";
            string conflict                          = testcasePath + number + "_Conflict.txt";
            int    typeOfConflict                    = conflictType(conflict);
            IReadOnlyList <Node>         output      = readResolvedConflicts(resolvedFilename, typeOfConflict);
            List <bool>                  checkOutput = new List <bool>();
            List <IReadOnlyList <Node> > outputQueue = LoadAllSynthesizedCode(input, programList, typeOfConflict);
            bool flagStart = false;
            bool flagValid = false;

            foreach (IReadOnlyList <Node> n in outputQueue)
            {
                if (n != null)
                {
                    if (n.Count > 0)
                    {
                        flagStart = true;
                        if (Equal(n, output))
                        {
                            flagValid = true;
                        }
                    }
                }
            }
            if (flagValid)
            {
                checkOutput.Add(true);
            }
            else if (flagStart == false)
            {
                if (Equal(Semantics.Concat(input.Downstream, input.Upstream), output) == true || Equal(Semantics.Concat(input.Upstream, input.Downstream), output) == true)
                {
                    checkOutput.Add(true);
                }
                else if (Semantics.NodeValue(input.Upstream[0], "path") == "")
                {
                    if (Equal(input.Downstream, output) == true)
                    {
                        checkOutput.Add(true);
                    }
                    else
                    {
                        checkOutput.Add(false);
                    }
                }
                else
                {
                    checkOutput.Add(false);
                }
            }
            else
            {
                checkOutput.Add(false);
            }
            return(checkOutput[0]);
        }
        public static Lambda Decompile(this Semantics semantics, MethodBase mb)
        {
            var domain = new Domain(semantics);

            if (semantics == Domain.Current.Semantics)
            {
                domain = Domain.Current;
            }
            return(mb.Decompile(domain));
        }
Example #18
0
        /// <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 += Pointer.GetWordCount();
            wordCount += Memory.GetWordCount();
            wordCount += Semantics.GetWordCount();
            wordCount += Value.GetWordCount();
            return(wordCount);
        }
Example #19
0
        //private static DataSet ConvertJsonStringToDataSet(string jsonString)
        //{
        //    try
        //    {
        //        //XmlDocument xd = new XmlDocument();
        //        jsonString = jsonString.Trim().TrimStart('\"').TrimEnd('\"') ;
        //        string xd = JsonConvert.DeserializeXmlNode(jsonString).ToString();
        //        DataSet ds = new DataSet();
        //        //DataSet ds = JsonConvert.DeserializeObject<DataSet>(jsonString);
        //        //ds.ReadXml(new System.Xml.XmlNodeReader(xd));
        //        return ds;



        //        //Newtonsoft.Json.JsonSerializer json = new Newtonsoft.Json.JsonSerializer();

        //        //json.NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore;
        //        //json.ObjectCreationHandling = Newtonsoft.Json.ObjectCreationHandling.Replace;
        //        //json.MissingMemberHandling = Newtonsoft.Json.MissingMemberHandling.Ignore;
        //        //json.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore;

        //        //StringReader sr = new StringReader(jsonString);
        //        //Newtonsoft.Json.JsonTextReader reader = new JsonTextReader(sr);
        //        //DataSet result = json.Deserialize<DataSet>(reader);
        //        //reader.Close();

        //        //return result;

        //    }
        //    catch (Exception ex)
        //    {
        //        throw new ArgumentException(ex.Message);
        //    }
        //}


        protected void DDLBinding(int id, Semantics Stype)
        {
            String type      = Stype.ToString();
            string strResult = ProxyService.GetSemanticLists(id, type);

            strResult = strResult.Replace("\\", String.Empty);
            strResult = strResult.Trim().TrimStart('\"').TrimEnd('\"');
            var           objSerializer = new JavaScriptSerializer();
            var           obj           = objSerializer.Deserialize <List <SemanticList> >(strResult);
            RibbonGallery rbbnGallary   = null;

            switch (Stype)
            {
            case Semantics.abbreviation: rbbnGallary = glyAbbrevations;
                break;

            case Semantics.cite: rbbnGallary = glyCites;
                break;

            case Semantics.idiom: rbbnGallary = glyIdioms;
                break;

            case Semantics.variable: rbbnGallary = glyVariables;
                break;

            case Semantics.definition: rbbnGallary = glyDefinitions;
                break;

            case Semantics.links: rbbnGallary = glyLinks;
                break;

                //case "new": rbbnGallary = null;
                //    break;
            }
            if (rbbnGallary != null)
            {
                try
                {
                    for (int loop = 0; loop < obj.Count; loop++)
                    {
                        string strNameOfItem = obj[loop].Text;
                        Microsoft.Office.Tools.Ribbon.RibbonDropDownItem menuItem = Factory.CreateRibbonDropDownItem();
                        menuItem.Tag = obj[loop].Value;
                        //menuItem.Id = obj[loop].Value.ToString();
                        menuItem.Label = obj[loop].Text;

                        rbbnGallary.Items.Add(menuItem);
                        rbbnGallary.Items[loop].Label = strNameOfItem;
                    }
                }
                catch
                {
                }
            }
        }
Example #20
0
        public static IntPtr Pin(this Semantics semantic)
        {
            switch (semantic)
            {
            case Semantics.POSITION: return(position_pin.Ptr);

            case Semantics.COLOR: return(color_pin.Ptr);
            }

            throw new NotImplementedException();
        }
 //Read - Returns version and content
 public DataDTO Read(string localFileName, Semantics semantics)
 {
     if (ReadHandler != null)
     {
         return(ReadHandler(localFileName, semantics));
     }
     else
     {
         return(null);  //is there a more proper way to report this failure?
     }
 }
Example #22
0
 /// <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 += IdResultType.GetWordCount();
     wordCount += IdResult.GetWordCount();
     wordCount += Pointer.GetWordCount();
     wordCount += Memory.GetWordCount();
     wordCount += Semantics.GetWordCount();
     wordCount += Value.GetWordCount();
     return wordCount;
 }
Example #23
0
        public Document(string path, Semantics semantics)
        {
            Filename = Path.GetFileName(path);
            using (var reader = new StreamReader(path))
            {
                Title = reader.ReadLine();
                Text  = new List <Paragraph>();

                foreach (var paragraph in reader.ReadToEnd().Split(new [] { semantics.ParagraphEnding }, StringSplitOptions.None))
                {
                    Text = Text.Add(new Paragraph(paragraph, semantics));
                }
            }
        }
Example #24
0
        public void On(InitiationStage stage, Action action)
        {
            var executor = new GenericExecutor(action);

            switch (stage)
            {
            case InitiationStage.Semantics: Semantics.Execute(executor); break;

            case InitiationStage.Meta: Meta.Execute(executor); break;

            case InitiationStage.Content: Content.Execute(executor); break;

            case InitiationStage.PostContent: PostContent.Execute(executor); break;
            }
        }
Example #25
0
 public void SetVertexAttribute(Semantics semantic, Memory <byte> bytes, int stride)
 {
     if (m_vertexCount == 0)
     {
         m_vertexCount = bytes.Length / stride;
     }
     else
     {
         if (m_vertexCount != bytes.Length / stride)
         {
             throw new Exception("different vertex count");
         }
     }
     m_vertexBufferMap[semantic] = new VertexBuffer(bytes, stride, D3D11_BIND_FLAG._VERTEX_BUFFER);
 }
Example #26
0
        // get the symbol for from the identifier
        private ISymbol GetSymbol(SimpleNameSyntax node)
        {
            var info = Semantics.GetSymbolInfo(node);

            if (info.Symbol != null)
            {
                return(info.Symbol);
            }

            if (info.CandidateSymbols.Count == 1)
            {
                return(info.CandidateSymbols[0]);
            }

            return(null);
        }
Example #27
0
        /// <summary>
        /// Compares this object to another one to see if they are the same object
        /// </summary>
        /// <param name="other">the object to compare to</param>
        /// <returns>true if the same object</returns>
        public bool Equals(IDictata other)
        {
            if (other != default(IDictata))
            {
                try
                {
                    return(other.Name.Equals(Name, StringComparison.InvariantCultureIgnoreCase) && other.WordType == WordType &&
                           Semantics.Count() == other.Semantics.Count() && Semantics.All(semantic => other.Semantics.Contains(semantic)));
                }
                catch (Exception ex)
                {
                    LoggingUtility.LogError(ex);
                }
            }

            return(false);
        }
        public void Copy(int fileRegister1, Semantics semantics, int fileRegister2, byte[] salt)
        {
            print("Copy command execution started");
            /* Read the contents into the dataRegisterForCopy */
            Read(fileRegister1, semantics, -1);
            /*Add the salt */
            byte[] newContent = new byte[dataRegisterForCopy.content.Length + salt.Length];
            dataRegisterForCopy.content.CopyTo(newContent, 0);
            salt.CopyTo(newContent, dataRegisterForCopy.content.Length);
            /*Store the NewContent in  */
            //Write(fileRegister2, newContent);
            Console.WriteLine("Storing the new contenst in dataRegister=" + fileRegister2);
            Data d = new Data(1, newContent);

            addContentRegister(d, fileRegister2);
            print("Copy Command execution complete");
        }
Example #29
0
        public void SetAttribute(Semantics semantics, VertexAttribute attribute)
        {
            m_attributes[semantics] = attribute;

            if (semantics == Semantics.POSITION)
            {
                VertexCount = attribute.Value.Count / attribute.ElementSize;

                _positions = new Vector3[VertexCount];
                var pinnedArray = GCHandle.Alloc(_positions, GCHandleType.Pinned);
                {
                    var ptr       = pinnedArray.AddrOfPinnedObject();
                    var positions = attribute.Value;
                    Marshal.Copy(positions.Array, positions.Offset, ptr, positions.Count);
                }
                pinnedArray.Free();
            }
        }
Example #30
0
        /// <summary>
        /// Validates two tree objects and checks if all the nodes are the same.
        /// </summary>
        /// <param name="tree1">Tree 1</param>
        /// <param name="tree2">Tree 2</param>
        /// <returns>True if trees are the same, false otherwise</returns>
        public static bool Equal(IReadOnlyList <Node> tree1, IReadOnlyList <Node> tree2)
        {
            List <string> retainTree1 = new List <string>();
            List <string> retainTree2 = new List <string>();

            foreach (Node n in tree1)
            {
                if (Semantics.NodeValue(n, "path") != "")
                {
                    retainTree1.Add(Semantics.NodeValue(n, "path"));
                }
            }
            foreach (Node n in tree2)
            {
                if (Semantics.NodeValue(n, "path") != "")
                {
                    retainTree2.Add(Semantics.NodeValue(n, "path"));
                }
            }
            return(retainTree1.SequenceEqual(retainTree2));
        }
Example #31
0
 public void Expect(Semantics expect)
 {
     tryExpectValue(expect, Current.Token);
 }
Example #32
0
 public SemanticalData(Semantics token, string value)
 {
     this.token = token;
     this.value = value;
 }
Example #33
0
 public SemanticalData(Semantics token)
     : this(token, null)
 {
 }
Example #34
0
 /// <summary>
 /// Constructs a new instance of the Semantics Attribute with parameters.
 /// </summary>
 /// <param name="type">The type of the semantics.</param>
 public SemanticsAttribute(Semantics type)
 {
     Type = type;
 }
Example #35
0
 private void tryExpectValue(Semantics expected, Semantics expect)
 {
     if (expected != expect)
     {
         throw new Exception(string.Format("Expecting token {0} but it is {1} with surrounding tokens '{2}' and '{3}'", expected, expect, Previous.Value, Next.Value));
     }
 }
Example #36
0
 private bool expectValue(Semantics expected, Semantics expect)
 {
     return expected == expect;
 }
Example #37
0
 public static Lambda Decompile(this MethodBase mb, Semantics semantics)
 {
     var domain = new Domain(semantics);
     if (semantics == Domain.Current.Semantics) domain = Domain.Current;
     return mb.Decompile(domain);
 }