예제 #1
0
파일: Helpers.cs 프로젝트: keithshort/HOPE
        /// <summary>
        /// Creates a root semantic type.
        /// </summary>
        public static SemanticTypeStruct CreateSemanticType(string name, bool unique, List<SemanticTypeDecl> decls, List<SemanticTypeStruct> structs)
        {
            SemanticTypeDecl decl = new SemanticTypeDecl() { OfTypeName = "Noun" };
            decl.AttributeValues.Add(new AttributeValue() { Name = "Name", Value = name });
            SemanticTypeStruct sts = new SemanticTypeStruct() { DeclTypeName = name, Unique = unique };

            decls.Add(decl);
            structs.Add(sts);

            return sts;
        }
예제 #2
0
파일: Helpers.cs 프로젝트: keithshort/HOPE
        public static void InitializeNoun(STS ssys, List<SemanticTypeDecl> decls, List<SemanticTypeStruct> structs)
        {
            // Reflective noun necessary for self-referential definition.
            SemanticTypeDecl decl = new SemanticTypeDecl() { OfTypeName = "Noun" };
            decl.AttributeValues.Add(new AttributeValue() { Name = "Name", Value = "Noun" });
            decls.Add(decl);

            SemanticTypeStruct sts = new SemanticTypeStruct() { DeclTypeName = "Noun" };
            sts.NativeTypes.Add(new Clifton.SemanticTypeSystem.NativeType() { Name = "Name", ImplementingType = "string" });
            structs.Add(sts);
        }
예제 #3
0
        /// <summary>
        /// Creates a custom type of the given name and known child protocols.
        /// </summary>
        public void CreateCustomType(string name, List <string> childProtocols)
        {
            List <SemanticTypeDecl>   decls   = new List <SemanticTypeDecl>();
            List <SemanticTypeStruct> structs = new List <SemanticTypeStruct>();

            SemanticTypeDecl   decl;
            SemanticTypeStruct sts;

            // Noun Decl.
            decl = new SemanticTypeDecl()
            {
                OfTypeName = "Noun"
            };
            decl.AttributeValues.Add(new AttributeValue()
            {
                Name = "Name", Value = "Noun"
            });
            decls.Add(decl);

            // Noun Struct.
            sts = new SemanticTypeStruct()
            {
                DeclTypeName = "Noun"
            };
            sts.NativeTypes.Add(new Clifton.SemanticTypeSystem.NativeType()
            {
                Name = "Name", ImplementingType = "string"
            });
            structs.Add(sts);

            // Custom type decl and struct.
            decl = new SemanticTypeDecl()
            {
                OfTypeName = "Noun"
            };
            decl.AttributeValues.Add(new AttributeValue()
            {
                Name = "Name", Value = name
            });
            sts = new SemanticTypeStruct()
            {
                DeclTypeName = name
            };
            decls.Add(decl);
            structs.Add(sts);

            // Elements of the custom type.
            foreach (string childProtocol in childProtocols)
            {
                sts.SemanticElements.Add(new Clifton.SemanticTypeSystem.SemanticElement()
                {
                    Name = childProtocol
                });
                // Recursively copy decls and structs of the existing types into our decls and structs lists.
                SemanticTypeStruct existingSts = (SemanticTypeStruct)GetSemanticTypeStruct(childProtocol);
                CopyDeclStruct(decls, structs, existingSts);
            }

            // Compile it.
            Parse(decls, structs);
            string code = GenerateCode();

            System.Reflection.Assembly assy = Compiler.Compile(code);
            CompiledAssembly = assy;
        }
예제 #4
0
파일: STS.cs 프로젝트: keithshort/HOPE
		/// <summary>
		/// Creates a custom type of the given name and known child protocols.
		/// </summary>
		public void CreateCustomType(string name, List<string> childProtocols)
		{
			List<SemanticTypeDecl> decls = new List<SemanticTypeDecl>();
			List<SemanticTypeStruct> structs = new List<SemanticTypeStruct>();

			SemanticTypeDecl decl;
			SemanticTypeStruct sts;

			// Noun Decl.
			decl = new SemanticTypeDecl() { OfTypeName = "Noun" };
			decl.AttributeValues.Add(new AttributeValue() { Name = "Name", Value = "Noun" });
			decls.Add(decl);

			// Noun Struct.
			sts = new SemanticTypeStruct() { DeclTypeName = "Noun" };
			sts.NativeTypes.Add(new Clifton.SemanticTypeSystem.NativeType() { Name = "Name", ImplementingType = "string" });
			structs.Add(sts);

			// Custom type decl and struct.
			decl = new SemanticTypeDecl() { OfTypeName = "Noun" };
			decl.AttributeValues.Add(new AttributeValue() { Name = "Name", Value = name });
			sts = new SemanticTypeStruct() { DeclTypeName = name };
			decls.Add(decl);
			structs.Add(sts);

			// Elements of the custom type.
			foreach (string childProtocol in childProtocols)
			{
				sts.SemanticElements.Add(new Clifton.SemanticTypeSystem.SemanticElement() { Name = childProtocol});
				// Recursively copy decls and structs of the existing types into our decls and structs lists.
				SemanticTypeStruct existingSts = (SemanticTypeStruct)GetSemanticTypeStruct(childProtocol);
				CopyDeclStruct(decls, structs, existingSts);
			}

			// Compile it.
			Parse(decls, structs);
			string code = GenerateCode();
			System.Reflection.Assembly assy = Compiler.Compile(code);
			CompiledAssembly = assy;
		}