public void EqualityComparison_SameValue_WorksForInt() { var _SUT1 = new SemanticType<int>(_TestInt); var _SUT2 = new SemanticType<int>(_TestInt); Assert.That(_SUT1 == _SUT2); Assert.False(_SUT1 != _SUT2); }
public void EqualityComparison_SameValue_WorksForString() { var _SUT1 = new SemanticType<string>(_TestString); var _SUT2 = new SemanticType<string>(_TestString); Assert.That(_SUT1 == _SUT2); Assert.False(_SUT1 != _SUT2); }
public ListView(SemanticType c) : base(c) { this.Size = new SizeF(250, 100); items.CollectionChanged += items_CollectionChanged; columns.CollectionChanged += columns_CollectionChanged; }
public FlowLayoutContainer(SemanticType c) : base(c) { this.ControlAdded += FlowLayoutContainer_ControlAdded; this.ControlRemoved += FlowLayoutContainer_ControlRemoved; this.SetLayout(); }
public UniformParameter( GpuProgramParameters.GpuConstantType type, string name, SemanticType semantic, int index, ContentType content, int variability, int size ) : base( type, name, semantic, index, content, size ) { this.isAutoConstantInt = false; this.isAutoConstantReal = false; this.autoConstantIntData = 0; this.variability = variability; this._params = null; this.physicalIndex = -1; }
/// <summary> /// Creates a new instance of the SimilarityMeasureBase class /// </summary> /// <param name="name">Specifies the name</param> /// <param name="semanticTypes">Specifies the <see cref="SemanticType"/></param> /// <param name="description">Specifies the description</param> protected SimilarityMeasureBase(string name, SemanticType semanticTypes, string description) { // Validate the provided argument if (string.IsNullOrEmpty(name)) throw new ArgumentNullException("name", "No valid name was provided for this similarity measure"); // Set the similarity measure's name and description _name = name; _description = description; // Set the assigned semantic types for this similarity measure _semanticTypes = semanticTypes; }
private string HlslSemantic(SemanticType semanticType, ref HlslSemanticTracker tracker) { switch (semanticType) { case SemanticType.None: return(string.Empty); case SemanticType.Position: { int val = tracker.Position++; return(" : POSITION" + val.ToString()); } case SemanticType.Normal: { int val = tracker.Normal++; return(" : NORMAL" + val.ToString()); } case SemanticType.TextureCoordinate: { int val = tracker.TexCoord++; return(" : TEXCOORD" + val.ToString()); } case SemanticType.Color: { int val = tracker.Color++; return(" : COLOR" + val.ToString()); } case SemanticType.Tangent: { int val = tracker.Tangent++; return(" : TANGENT" + val.ToString()); } case SemanticType.SystemPosition: { return(" : SV_Position"); } case SemanticType.ColorTarget: { int val = tracker.ColorTarget++; return(" : SV_Target" + val.ToString()); } default: throw new ShaderGenerationException("Invalid semantic type: " + semanticType); } }
public override int CompareTo(SemanticType other) { // any functional type is greater than any // atomic type. if (other is AtomicType) { return(1); } FunctionalType that = other as FunctionalType; // if the arities of these semantic types are // unequal, the higher arity is greater. if (this.Input.Length > that.Input.Length) { return(1); } if (this.Input.Length < that.Input.Length) { return(-1); } for (int i = 0; i < Input.Length; i++) { int inputComparison = Input[i].CompareTo(that.Input[i]); if (inputComparison < 0) { return(-1); } if (inputComparison > 0) { return(1); } } var outputComparison = Output.CompareTo(that.Output); if (outputComparison < 0) { return(-1); } if (outputComparison > 0) { return(1); } return(0); }
private byte GetMaxIndex(VertexElementDescriptor[] elements, SemanticType type) { byte max = 0; foreach (VertexElementDescriptor element in elements) { if (element.type == type) { max = Math.Max(max, element.index); } } max += 1; return(max); }
public String Copy(int fileRegisterRead, SemanticType semantic, int fileRegisterWrite, byte[] stringSalt) { Console.WriteLine("#COPY From File at Register: " + fileRegisterRead + " with " + semantic.ToString() + " Semantic and Writes to File at Register: " + fileRegisterWrite + " adding the salt: " + (new ASCIIEncoding()).GetString(stringSalt)); TFile readFile = Read(fileRegisterRead, semantic); String parte1 = Encoding.ASCII.GetString(readFile.Data); String parte2 = Encoding.ASCII.GetString(stringSalt); String data = parte1 + parte2; Write(fileRegisterWrite, (new ASCIIEncoding()).GetBytes(data)); return("#COPY Complete"); }
public string Convert(SemanticType type) { if (type == SemanticType.Unknown) { return(string.Empty); } if (type == SemanticType.Uri) { return("URI"); } return(type.ToString()); }
public static void Debug_Mips(string text, string path = "mips.s") { var root = BuildAST_Cool.BUILD(text); var cil_root = CILCompiler.Build(root); var sem = SemanticType.BuildAllType(root.class_list); //var solve = CIL_Execute.Execute(cil_root, sem); var prog = new MipsCompiler(cil_root, sem); string s = (prog.Visit(cil_root)); //Console.WriteLine(s); var w = new StreamWriter(path); w.Write(s); w.Close(); }
/// <summary> /// Creates a new instance of the SimilarityMeasureBase class /// </summary> /// <param name="name">Specifies the name</param> /// <param name="semanticTypes">Specifies the <see cref="SemanticType"/></param> /// <param name="description">Specifies the description</param> protected SimilarityMeasureBase(string name, SemanticType semanticTypes, string description) { // Validate the provided argument if (string.IsNullOrEmpty(name)) { throw new ArgumentNullException("name", "No valid name was provided for this similarity measure"); } // Set the similarity measure's name and description _name = name; _description = description; // Set the assigned semantic types for this similarity measure _semanticTypes = semanticTypes; }
/// <summary> /// Initializes a new instance of the Berico.LinkAnalysis.Model.Attribute /// class with the provided name, preferred similarity measure, the /// semantic type and the visibilty setting. /// </summary> /// <param name="_name">The name of the attribute</param> /// <param name="_preferredSimilarityMeasure">The preferred similarity measure that should be /// used by this attribute</param> /// <param name="_semanticType">The semantic type for this attribute</param> /// <param name="_visible">Whether or not the attribute should /// be visible (in the UI) to the user</param> /// <exception cref="System.ArgumentNullException">Thrown in the event that Name or Value are null</exception> public Attribute(string _name, Type _preferredSimilarityMeasure, SemanticType _semanticType, bool _visible) { // Validate parameters if (String.IsNullOrEmpty(_name)) { throw new ArgumentNullException("Name", "A name must be provided for this attribute"); } SetPreferredSimilarityMeasure(_preferredSimilarityMeasure); // Set the internal fields for the class this.name = _name; this.semanticType = _semanticType; this.visible = _visible; }
public void Constructor_ThrowsForNull() { Exception caughtException = null; try { var _SUT = new SemanticType<string>(null); } catch (Exception ex) { caughtException = ex; } Assert.NotNull(caughtException); Assert.That(caughtException.Message == SemanticType<string>.DefaultValidationMessage); }
private static ArticyData.SemanticType ConvertSemanticType(SemanticType semanticType) { switch (semanticType) { case SemanticType.Input: return(ArticyData.SemanticType.Input); case SemanticType.Output: return(ArticyData.SemanticType.Output); default: Debug.LogWarning(string.Format("{0}: Unexpected semantic type {1}", DialogueDebug.Prefix, semanticType.ToString())); return(ArticyData.SemanticType.Input); } }
public SemanticAtom Visit(CompilerFunction n) { var type = n.Expression?.Accept(this); SemanticType returnType = Class.Unknown; switch (n.FunctionString) { case "System.out.println": if (type != null && type != Primitive.Int && type != Primitive.Boolean && type != Primitive.String) { Globals.Errors.Add($"[{n.Expression.Location.StartLine}, {n.Expression.Location.StartColumn}] Println expression ({type.Name}) is not assignable to {Primitive.String.Name}."); } returnType = Class.Unknown; break; case "System.in.readln": returnType = Primitive.String; break; case "System.compiler.destroy": if (!(type is Class) && type != Primitive.IntArray) { Globals.Errors.Add($"[{n.Expression.Location.StartLine}, {n.Expression.Location.StartColumn}] Destroy expression ({type.Name}) is a class or array type."); } returnType = Class.Unknown; break; case "System.compiler.exception": if (type != Primitive.String) { Globals.Errors.Add($"[{n.Expression.Location.StartLine}, {n.Expression.Location.StartColumn}] Exception expression ({type.Name}) is not assignable to {Primitive.String.Name}."); } returnType = Class.Unknown; break; case "System.compiler.atol": if (type != Primitive.String) { Globals.Errors.Add($"[{n.Expression.Location.StartLine}, {n.Expression.Location.StartColumn}] Atol expression ({type.Name}) is not assignable to {Primitive.String.Name}."); } returnType = Primitive.Int; break; } n.RealizedType = returnType; return(n.RealizedType); }
public void Constructor_ThrowsForNull() { Exception caughtException = null; try { var _SUT = new SemanticType <string>(null); } catch (Exception ex) { caughtException = ex; } Assert.NotNull(caughtException); Assert.That(caughtException.Message == SemanticType <string> .DefaultValidationMessage); }
public void SetUp() { _semanticType = SemanticType.Measure; _dataType = typeof(Boolean); _filePath = @"C:\Test.csv"; _map = new SourceMap(); _dataColumn = new DataColumnBuilder() .WithColumnName("Test") .WithDataType(typeof(Boolean)) .Build(); _table = new DataTableBuilder() .WithColumn(_dataColumn) .Build(); _source = new CsvFileSource(); _mockRepository = new Mock <ISourceRepository>(); _mockRepository.Setup(p => p.GetSource <CsvFileSource>()) .Returns(_source); _mockDataAdapter = new Mock <ICsvFileDataAdapter>(); _mockDataAdapter.Setup(p => p.GetTable(_source)) .Returns(_table); _mockDataTypeDetector = new Mock <IDataTypeDetector>(); _mockDataTypeDetector.Setup(p => p.Detect(It.IsAny <IEnumerable <object> >())) .Returns(_dataType); _mockSemanticTypeDetector = new Mock <ISemanticTypeDetector>(); _mockSemanticTypeDetector.Setup(p => p.Detect(_dataType, It.IsAny <List <object> >())) .Returns(_semanticType); _mockFactory = new Mock <ISourceMapFactory>(); _mockFactory.Setup(p => p.Create(_dataColumn.Ordinal, _dataColumn.ColumnName, _dataType, _semanticType)) .Returns(_map); _mockEventBus = new Mock <IEventBus>(); _handler = new UpdateCsvFileSourceCommandHandler( _mockRepository.Object, _mockDataAdapter.Object, _mockDataTypeDetector.Object, _mockSemanticTypeDetector.Object, _mockFactory.Object, _mockEventBus.Object); }
private SemanticType BinaryExpressionHelper(BinaryExpression exp, SemanticType expectedType, string op, SemanticType returnType) { var left = exp.LeftExpression.Accept(this); var right = exp.RightExpression.Accept(this); var leftLocation = exp.LeftExpression.Location; var rightLocation = exp.RightExpression.Location; if (left != expectedType) { Globals.Errors.Add($"[{leftLocation.StartLine}, {leftLocation.StartColumn}] Left expression of operator({op}) ({left.Name}) is not assignable to {expectedType.Name}."); } if (right != expectedType) { Globals.Errors.Add($"[{rightLocation.StartLine}, {rightLocation.StartColumn}] Right expression of operator({op}) ({right.Name}) is not assignable to {expectedType.Name}."); } return(returnType); }
/// <summary> /// Writes a skin source accessor for the current skin controller /// </summary> /// <param name="Name"></param> /// <param name="Semantic"></param> /// <param name="Values"></param> /// <returns>the id of the newly created skin source</returns> public string WriteSkinSource(string Name, SemanticType Semantic, object[] Values) { int Stride = GetStride(Semantic); string sourceid = GetUniqueID(Name + "-" + Semantic.ToString().ToLower()); Writer.WriteStartElement("source"); Writer.WriteAttributeString("id", sourceid); Writer.WriteStartElement(Semantic == SemanticType.JOINT ? "Name_array" : "float_array"); string FloatArrayID = GetUniqueID(Name + "-" + Semantic.ToString().ToLower() + "-array"); Writer.WriteAttributeString("id", FloatArrayID); Writer.WriteAttributeString("count", Values.Length.ToString()); Writer.WriteString(string.Join(" ", Values)); Writer.WriteEndElement(); Writer.WriteStartElement("technique_common"); { Writer.WriteStartElement("accessor"); Writer.WriteAttributeString("source", $"#{FloatArrayID}"); Writer.WriteAttributeString("count", (Values.Length / Stride).ToString()); Writer.WriteAttributeString("stride", Stride.ToString()); if (Semantic == SemanticType.JOINT) { WriteParam("JOINT", "name"); } if (Semantic == SemanticType.INV_BIND_MATRIX) { WriteParam("TRANSFORM", "float4x4"); } if (Semantic == SemanticType.WEIGHT) { WriteParam("WEIGHT", "float"); } Writer.WriteEndElement(); } Writer.WriteEndElement(); Writer.WriteEndElement(); return(sourceid); }
private VertexSemanticType GetSemantic(SemanticType semanticType) { switch (semanticType) { case SemanticType.Position: return(VertexSemanticType.Position); case SemanticType.Normal: return(VertexSemanticType.Normal); case SemanticType.TextureCoordinate: return(VertexSemanticType.TextureCoordinate); case SemanticType.Color: return(VertexSemanticType.Color); case SemanticType.Tangent: return(VertexSemanticType.Color); case SemanticType.None: default: throw new InvalidOperationException("Unexpected semantic type: " + semanticType); } }
static void Compilator(string path, string dest, string mips) { var r = new StreamReader(path); var text = r.ReadToEnd(); var root = BuildAST_Cool.BUILD(text); if (root == null) { return; } var result = SemanticChecking(root); if (result.Item1) { var cil_root = CILCompiler.Build(root); string s = cil_root.ToString(); var w = new StreamWriter(dest); //Console.WriteLine(s); w.Write(s); w.Close(); var sem = SemanticType.BuildAllType(root.class_list); //var solve = CIL_Execute.Execute(cil_root, sem); var prog = new MipsCompiler(cil_root, sem); s = (prog.Visit(cil_root)); //Console.WriteLine(s); var t = new StreamWriter(mips); //Console.WriteLine(s); t.Write(s); t.Close(); } else { Console.WriteLine("There are some errors!!!"); foreach (var item in result.Item2.Log) { Console.WriteLine(item); } } }
private bool ReadAux(string serverIP, int serverPort, string localFileName, SemanticType semantic, long minVersion) { IDataToClient dataServer = (IDataToClient)Activator.GetObject( typeof(IDataToClient), "tcp://" + serverIP + ":" + serverPort + "/PADIConnection"); AsyncReadDel RemoteDel = new AsyncReadDel(dataServer.Read); AsyncCallback RemoteCallback = new AsyncCallback(CBDoWhenReturnFromRead); try { IAsyncResult RemAr = RemoteDel.BeginInvoke(localFileName, RemoteCallback, null); } catch (Exception) { System.Console.WriteLine("#READ Could not locate server"); return(false); } return(true); }
public Column( int id, int index, string name, Type dataType, SemanticType semanticType, List <object> values, object min, object max, bool hasNulls) { _id = id; _index = index; _name = name; _dataType = dataType; _semanticType = semanticType; _values = values; _min = min; _max = max; _hasNulls = hasNulls; }
void OpenConstantMenu(SemanticType semanticType) { constantMenuOpen = true; double sliceTheta = 2f * Math.PI / Lexicon[semanticType].Count; double theta = INITIAL_ANGLE_OFFSET; foreach (Name name in Lexicon[semanticType]) { theta = theta % (2f * Math.PI); var radialMenuItem = Instantiate(radialMenuItemPrefab); radialMenuItem.GetComponent <Transform>().SetParent(gameObject.transform); radialMenuItem.GetComponent <Transform>().localPosition = new Vector2( (float)(Math.Cos(theta) * RADIUS), (float)(Math.Sin(theta) * RADIUS) ); radialMenuItem.Name = name; radialMenuItem.SetIcon(name); radialMenuItems.Add(radialMenuItem); theta += sliceTheta; } }
public static bool TryGetStructDefinition(SemanticModel model, StructDeclarationSyntax node, out StructureDefinition sd) { string fullNestedTypePrefix = Utilities.GetFullNestedTypePrefix(node, out bool nested); string structName = node.Identifier.ToFullString().Trim(); if (!string.IsNullOrEmpty(fullNestedTypePrefix)) { string joiner = nested ? "+" : "."; structName = fullNestedTypePrefix + joiner + structName; } List <FieldDefinition> fields = new List <FieldDefinition>(); foreach (MemberDeclarationSyntax member in node.Members) { if (member is FieldDeclarationSyntax fds && !fds.Modifiers.Any(x => x.IsKind(SyntaxKind.ConstKeyword))) { VariableDeclarationSyntax varDecl = fds.Declaration; foreach (VariableDeclaratorSyntax vds in varDecl.Variables) { string fieldName = vds.Identifier.Text.Trim(); string typeName = model.GetFullTypeName(varDecl.Type, out bool isArray); int arrayElementCount = 0; if (isArray) { arrayElementCount = GetArrayCountValue(vds, model); } TypeReference tr = new TypeReference(typeName, model.GetTypeInfo(varDecl.Type)); SemanticType semanticType = GetSemanticType(vds); fields.Add(new FieldDefinition(fieldName, tr, semanticType, arrayElementCount)); } } } sd = new StructureDefinition(structName.Trim(), fields.ToArray()); return(true); }
private Column CreateBitmapImageColumn( int id, int index, string name, Type dataType, SemanticType semanticType, List <object> values) { var hasNulls = values .Any(p => p == null); var column = new Column( id, index, name, dataType, semanticType, values, null, null, hasNulls); return(column); }
public void ObjectEquals_CorrectlyHandlesNulls() { var _SUT1 = new SemanticType<TestClass>(_TestClass); var _SUT1Reference = _SUT1; var _SUT2 = new SemanticType<TestClass>(_TestClass); var _SUT3 = new SemanticType<TestClass>(_OtherTestClass); Assert.False(_SUT1.Equals((object)null)); Assert.True(_SUT1.Equals((object)_SUT1Reference)); Assert.False(_SUT1.Equals((object)new TestClass())); Assert.True(_SUT1.Equals((object)_SUT2)); Assert.False(_SUT1.Equals((object)_SUT3)); }
public void Constructor_SucceedsForString() { var _SUT = new SemanticType<string>(_TestString); }
public void Constructor_SucceedsForInt() { var _SUT = new SemanticType<int>(_TestInt); }
/// <summary> /// Initializes a new instance of the Berico.LinkAnalysis.Model.Attribute /// class with the provided name, preferred similarity measure, the /// semantic type and the visibilty setting. /// </summary> /// <param name="_name">The name of the attribute</param> /// <param name="_preferredSimilarityMeasure">The preferred similarity measure that should be /// used by this attribute</param> /// <param name="_semanticType">The semantic type for this attribute</param> /// <param name="_visible">Whether or not the attribute should /// be visible (in the UI) to the user</param> /// <exception cref="System.ArgumentNullException">Thrown in the event that Name or Value are null</exception> public Attribute(string _name, Type _preferredSimilarityMeasure, SemanticType _semanticType, bool _visible) { // Validate parameters if (String.IsNullOrEmpty(_name)) throw new ArgumentNullException("Name", "A name must be provided for this attribute"); SetPreferredSimilarityMeasure(_preferredSimilarityMeasure); // Set the internal fields for the class this.name = _name; this.semanticType = _semanticType; this.visible = _visible; }
public void Constructor_SucceedsForClass() { var _SUT = new SemanticType<TestClass>(new TestClass()); }
public Button(SemanticType c) : base(c) { this.Size = new SizeF(75, 30); }
// Resizes the quad according to the dimensions of the // expression, and attaches a texture made by // drawing the expression recursively. void GenerateVisual() { int width = GetWidth(Expression); int height = GetHeight(Expression); gameObject.transform.localScale = new Vector3( gameObject.transform.localScale.x * width, gameObject.transform.localScale.y * height, gameObject.transform.localScale.z); // mipmap levels turned off. May want to turn this on later. var texture = new Texture2D(width * Scale, height * Scale); var drawStack = new Stack <DrawInfo>(); drawStack.Push(new DrawInfo(Expression, 0, 0)); bool isFirstLevel = true; while (drawStack.Count != 0) { DrawInfo currentDrawInfo = drawStack.Pop(); int currentWidth; int currentHeight; if (currentDrawInfo.Argument is Expression && !isFirstLevel) { currentWidth = SecondCallGetWidth((Expression)currentDrawInfo.Argument); currentHeight = SecondCallGetHeight((Expression)currentDrawInfo.Argument); } else { currentWidth = GetWidth(currentDrawInfo.Argument); currentHeight = GetHeight(currentDrawInfo.Argument); } int scaledHeight = height * Scale; int scaledCurrentX = currentDrawInfo.X * Scale; int scaledCurrentY = currentDrawInfo.Y * Scale; int scaledCurrentWidth = currentWidth * Scale; int scaledCurrentHeight = currentHeight * Scale; int endingY = scaledHeight - scaledCurrentY; int startingY = endingY - scaledCurrentHeight; int startingX = scaledCurrentX; int endingX = startingX + scaledCurrentWidth; if (ReadVertically) { Debug.Log("ReadVertically: Not yet working. Defaulting to horizontal reading order."); // TODO (the previous code swaps the key variables) } // fill with the color of the expression's semantic type. for (int y = startingY; y < endingY; y++) { for (int x = startingX; x < endingX; x++) { SemanticType fillType = currentDrawInfo.Argument.Type; if (RenderingOptions.FillMode == FillMode.Complete) { // already set } if (RenderingOptions.FillMode == FillMode.Output && fillType is FunctionalType && currentDrawInfo.Argument is Expression && isFirstLevel) { fillType = ((FunctionalType)fillType).Output; } if (RenderingOptions.FillMode == FillMode.Head && currentDrawInfo.Argument is Expression) { fillType = ((Expression)currentDrawInfo.Argument).Head.Type; } Color typeColor = ColorsByType[fillType] - new Color(0, 0, 0, FillTransparency); texture.SetPixel(x, y, typeColor); } } // northern border and southern border for (int y = startingY; y < startingY + BorderSize; y++) { for (int x = startingX; x < endingX; x++) { Color typeColor = ColorsByType[currentDrawInfo.Argument.Type] - new Color(0, 0, 0, BorderTransparency); // northern border texture.SetPixel(x, y + scaledCurrentHeight - BorderSize, typeColor); // southern border texture.SetPixel(x, y, typeColor); } } // eastern and western border for (int y = startingY; y < endingY; y++) { for (int x = startingX; x < startingX + BorderSize; x++) { Color typeColor = ColorsByType[currentDrawInfo.Argument.Type] - new Color(0, 0, 0, BorderTransparency); // west border texture.SetPixel(x, y, typeColor); // east border texture.SetPixel(x + scaledCurrentWidth - BorderSize, y, typeColor); } } // We're at an empty argument slot. Nothing left to do here. // @Note: we could draw the inaccessible argument slot, but that // involves more changes than I want to make. if (currentDrawInfo.Argument is Empty) { continue; } Expression currentExpression = (Expression)currentDrawInfo.Argument; var head = ((Expression)currentDrawInfo.Argument).Head; var nameString = head is Name ? ((Name)head).ID : ""; Texture2D headTexture = Resources.Load <Texture2D>("Textures/Symbols/" + nameString); // if we're an expression, we want to draw the head symbol // @Note this has to be in a specific RGBA format to work. if (headTexture != null) { int symbolSize = Scale - BorderSize * 2; // @Note Unity is being picky about these. // Seems like we just have give a texture of the // right size and format for now. // headTexture.Resize(Scale - BorderSize * 2, Scale - BorderSize * 2); // headTexture.Apply(); int xOffset = 0; if (HeadSymbolPosition == Position.Left) { xOffset = 0; } if (HeadSymbolPosition == Position.Center) { xOffset = (currentWidth / 2) * Scale; if (currentWidth % 2 == 0) { xOffset -= Scale / 2; } } if (HeadSymbolPosition == Position.Right) { xOffset = (currentWidth - 1) * Scale; } for (int y = 0; y < symbolSize; y++) { for (int x = 0; x < symbolSize; x++) { Color headPixelColor = headTexture.GetPixel(x, y) - new Color(0, 0, 0, BorderTransparency); if (headPixelColor.a > 0) { texture.SetPixel( startingX + xOffset + x + BorderSize, -Scale + startingY + scaledCurrentHeight + y + BorderSize, headPixelColor); } } } } if (currentDrawInfo.Argument is Empty) { continue; } // Now, we push the arguments on to the draw stack. var nextX = currentDrawInfo.X; if (DrawFirstArgumentDiagonally && HeadSymbolPosition != Position.Right) { nextX++; } if (DrawInaccessibleArgumentSlot) { Debug.Log("DrawInaccessibleArgumentSlot: not implemented yet. Default to not drawing it."); } // We only skip empties if all arguments are empty. bool canSkipEmpties = true; for (int i = 0; i < currentExpression.NumArgs; i++) { if (currentExpression.GetArg(i) is Expression) { canSkipEmpties = false; break; } } for (int i = 0; i < currentExpression.NumArgs; i++) { var arg = currentExpression.GetArg(i); // we skip moving forward, because we won't draw this empty slot. if (arg is Empty && !isFirstLevel) { if (!canSkipEmpties) { nextX++; } continue; } drawStack.Push(new DrawInfo(arg, nextX, currentDrawInfo.Y + 1)); if (arg is Expression) { nextX += SecondCallGetWidth((Expression)arg); } else { nextX += GetWidth(arg); } } isFirstLevel = false; } texture.Apply(); GetComponent <Renderer>().material.mainTexture = texture; }
public void EqualityComparison_DifferentValue_WorksForString() { var _SUT1 = new SemanticType<string>(_TestString); var _SUT2 = new SemanticType<string>(_OtherTestString); Assert.False(_SUT1 == _SUT2); }
public ToggleButton(SemanticType c) : base(c) { this.Size = new SizeF(75, 30); }
protected override double Convert(SemanticType <double> value, CultureInfo culture) { return(value.Value); }
public Pin(string id, int index, SemanticType semantic, string expression) { this.id = id; this.index = index; this.semantic = semantic; this.expression = expression; }
public void EqualityComparison_DifferentValue_WorksForInt() { var _SUT1 = new SemanticType<int>(_TestInt); var _SUT2 = new SemanticType<int>(_OtherTestInt); Assert.False(_SUT1 == _SUT2); }
public void EqualityComparison_SameValue_WorksForClass() { var _SUT1 = new SemanticType<TestClass>(_TestClass); var _SUT2 = new SemanticType<TestClass>(_TestClass); Assert.That(_SUT1 == _SUT2); Assert.False(_SUT1 != _SUT2); }
public void Equals_False_ForNull() { var _SUT1 = new SemanticType<TestClass>(_TestClass); // IEquatable<SemanticType<T>>.Equals Assert.False(_SUT1.Equals((SemanticType<TestClass>)null)); }
public Word(string value, SemanticType semType) { Value = value; SemType = semType; }
public PictureBox(SemanticType c) : base(c) { this.Size = new SizeF(50, 50); this.TabStop = false; }
public TrackBar(SemanticType c) : base(c) { this.Size = new SizeF(120, 12); }
public void BasicTypes() { var basic = SemanticType.BuildSystemType(); Assert.AreEqual(basic.Count, 6); }
public static CIL_AST_Root Build(AST_Root root) { // SectionTypes var inst = new CILCompiler(); inst.semantictypes = SemanticType.BuildAllType(root.class_list); // SectionData inst.label_data_gen = new GenerateContinuosLabel("str"); inst.Visit(root.class_list); List <CIL_DataElement> listdata = new List <CIL_DataElement>(inst.data.Select(x => new CIL_DataElement(x.Value, x.Key))); foreach (var typ in inst.semantictypes) { var t = typ.Value; bool isbasic = typ.Key != "SELF_TYPE"; foreach (var item in inst.listtypes) { isbasic &= item.Id != typ.Key; } if (!isbasic) { continue; } List <CIL_ClassAttr> lattr = new List <CIL_ClassAttr>(); foreach (var item in t.GetAllAttr()) { lattr.Add(new CIL_ClassAttr(item.Id)); } List <CIL_ClassMethod> lmeth = new List <CIL_ClassMethod>(); if (t.Father != null) { foreach (var item in t.Father.GetAllMethods()) { if (t._find_method(item.Name) == -1) { lmeth.Add(new CIL_ClassMethod(item.Name, item.Label())); } } } foreach (var item in t.Methods) { lmeth.Add(new CIL_ClassMethod(item.Name, item.Label())); } inst.listtypes.Add(new CIL_ClassDef(typ.Key, new CIL_ListNode <CIL_ClassAttr>(lattr), new CIL_ListNode <CIL_ClassMethod>(lmeth))); } // agregar los str types al data foreach (var item in inst.listtypes) { listdata.Add(new CIL_DataElement("type_" + item.Id, item.Id)); } listdata.Add(new CIL_DataElement("error_null", "Null Reference Exception")); listdata.Add(new CIL_DataElement("error_div0", "Divition By Zero Exception")); listdata.Add(new CIL_DataElement("error_indexout", "Index Out Range Exception")); inst.methods.Add(SystemCallGenerator.GeneratePrint()); inst.methods.Add(SystemCallGenerator.GeneratePrintInt()); inst.methods.Add(SystemCallGenerator.Descend()); inst.methods.Add(SystemCallGenerator.Abort()); inst.methods.Add(SystemCallGenerator.TypeName()); inst.methods.Add(SystemCallGenerator.StrLenght()); inst.methods.Add(SystemCallGenerator.StrConcat()); inst.methods.Add(SystemCallGenerator.Copy()); inst.methods.Add(SystemCallGenerator.StrSubstr()); inst.methods.Add(SystemCallGenerator.GenerateReadInt()); inst.methods.Add(SystemCallGenerator.Entry()); return(new CIL_AST_Root(new CIL_SectionData(listdata), new CIL_SectionTypes(inst.listtypes), new CIL_SectionFunction(inst.methods))); }
/// <summary> /// Creates a new instance of the RegexStringSimilarityMeasure class /// </summary> /// <param name="name">The name to be assigned to this similarity measure</param> /// <param name="regex">A regular expression to be used for comparing only /// a specific portion of the strings</param> public RegexStringSimilarityMeasure(string _name, string _regex, SemanticType _type, string _description ) : base(_name, _type, _description) { this.expression = _regex; }
/// <summary> /// Initializes a new instance of the Berico.LinkAnalysis.Model.Attribute /// class with the provided name, preferred similarity measure and the /// semantic type. This Attribute instance will default to being visible. /// </summary> /// <param name="_name">The name of the attribute</param> /// <param name="_preferredSimilarityMeasure">The preferred similarity measure that should be /// used by this attribute</param> /// <param name="_semanticType">The semantic type for this attribute</param> public Attribute(string _name, Type _preferredSimilarityMeasure, SemanticType _semanticType) : this(_name, _preferredSimilarityMeasure, _semanticType, true) { }
public Semantic(SemanticType type) { Type = type; Index = -1; }
/// <summary> /// Initializes a new instance of the Berico.LinkAnalysis.Model.Attribute /// class with the provided name and semantic type. ThisAttribute /// instance will default to being visible. /// </summary> /// <param name="_name">The name of the attribute</param> /// <param name="_semanticType">The semantic type for this attribute</param> public Attribute(string _name, SemanticType _semanticType) : this(_name, null, _semanticType, true) { }
public Semantic(SemanticType type, int index) { Type = type; Index = index; }
public void ReceiveExpression(Expression utterer, Expression utterance) { // Debug.Log(this.name + " is seeing '" + utterance + "'"); if (this.model == null) { // Debug.Log("No associated model."); this.controller.placeExpression.Play(); StartCoroutine(ShowSpeechBubble("questionMark")); return; } if (utterance.type.Equals(SemanticType.CONFORMITY_VALUE)) { // if (name.Equals(new Phrase(Expression.THE, new Phrase(Expression.POSSESS, new Phrase(Expression.THE, Expression.LOG), 1)))) { // if (!model.Proves(new Phrase(Expression.KING, utterer))) { // StartCoroutine(ShowSpeechBubble(Expression.REFUSE)); // return; // } // } // TODO figure out conditions of refusal, etc. if (utterance.GetHead().Equals(Expression.CONTRACT)) { if (!this.model.Proves(new Phrase(Expression.NOT, new Phrase(Expression.TRUSTWORTHY, utterer)))) { // TODO: check if utilities work out, and if you can uphold your end of the deal. // For now, just accept by default // uphold your end of the bargain model.Add(new Phrase(Expression.BETTER, utterance.GetArg(1), Expression.NEUTRAL)); // model.AddUtility(utterance.GetArg(1), 10f); // hold the other person to account model.UpdateBelief(new Phrase(Expression.BOUND, utterer, utterance.GetArg(0))); // // hold yourself to account?? // model.UpdateBelief(new Phrase(Expression.BOUND, utterer, utterance.GetArg(1))); this.controller.combineSuccess.Play(); StartCoroutine(ShowSpeechBubble(new Phrase(Expression.ACCEPT))); return; } this.controller.lowClick.Play(); StartCoroutine(ShowSpeechBubble(Expression.REFUSE)); return; } if (utterance.GetHead().Equals(Expression.WOULD)) { if (this.model.Proves(new Phrase(Expression.NOT, new Phrase(Expression.TRUSTWORTHY, utterer)))) { this.controller.lowClick.Play(); StartCoroutine(ShowSpeechBubble(new Phrase(Expression.REFUSE))); return; } this.controller.combineSuccess.Play(); StartCoroutine(ShowSpeechBubble(Expression.ACCEPT)); model.Add(new Phrase(Expression.BETTER, utterance.GetArg(0), Expression.NEUTRAL)); model.decisionLock = false; // model.AddUtility(utterance.GetArg(0), 10f); return; } } if (utterance.type.Equals(SemanticType.ASSERTION)) { Expression content = utterance.GetArg(0); // if (this.model.UpdateBelief(new Phrase(Expression.BELIEVE, utterer, content))) { if (this.model.UpdateBelief(content)) { this.controller.combineSuccess.Play(); StartCoroutine(ShowSpeechBubble(new Phrase(Expression.ASSERT, Expression.AFFIRM))); } else { this.controller.failure.Play(); StartCoroutine(ShowSpeechBubble(new Phrase(Expression.ASSERT, Expression.DENY))); } return; } if (utterance.type.Equals(SemanticType.TRUTH_VALUE)) { if (this.model.Proves(utterance)) { this.controller.combineSuccess.Play(); StartCoroutine(ShowSpeechBubble(new Phrase(Expression.ASSERT, Expression.AFFIRM))); } else if (this.model.Proves(new Phrase(Expression.NOT, utterance))) { this.controller.failure.Play(); StartCoroutine(ShowSpeechBubble(new Phrase(Expression.ASSERT, Expression.DENY))); } else { this.controller.lowClick.Play(); StartCoroutine(ShowSpeechBubble(new Phrase(Expression.ASSERT, new Phrase(Expression.OR, Expression.AFFIRM, Expression.DENY)))); } return; } if (utterance.type.Equals(SemanticType.INDIVIDUAL)) { // I imagine this will be an invitation to attend to the individual named // but I'll leave this as a kind of puzzlement for now. this.controller.placeExpression.Play(); StartCoroutine(ShowSpeechBubble("query")); return; } SemanticType outputType = utterance.type.GetOutputType(); if (outputType != null && outputType.Equals(SemanticType.TRUTH_VALUE)) { IPattern[] args = new IPattern[utterance.GetNumArgs()]; Dictionary <SemanticType, int> places = new Dictionary <SemanticType, int>(); int counter = 0; for (int i = 0; i < utterance.GetNumArgs(); i++) { if (utterance.GetArg(i) == null) { SemanticType argType = utterance.type.GetInputType(counter); int place = 0; if (places.ContainsKey(argType)) { place = places[argType]; } places[argType] = place + 1; args[i] = new MetaVariable(argType, place); counter++; } else { args[i] = utterance.GetArg(i); } } // let's see if this doesn't break things. // might have to cycle through the utterance's open args. IPattern question = new ExpressionPattern(utterance.GetHead(), args); List <Dictionary <MetaVariable, Expression> > found = model.Find(false, new List <Expression>(), question); if (found != null) { List <IPattern> bound = question.Bind(found); Expression[] answers = new Expression[bound.Count]; counter = 0; foreach (IPattern p in bound) { Expression answer = new Phrase(Expression.ASSERT, p.ToExpression()); answers[counter] = answer; counter++; } StartCoroutine(ShowSpeechBubbles(answers)); return; } } // this leaves functions with e as output. Not sure what this would amount to. this.controller.placeExpression.Play(); StartCoroutine(ShowSpeechBubble("query")); }
public MetaVariable(SemanticType type, int localID) { this.type = type; this.localID = localID; }
public void ToString_Works_ForAllWrappedTypes() { var _SUT1 = new SemanticType<TestClass>(_TestClass); var _SUT2 = new SemanticType<string>(_TestString); var _SUT3 = new SemanticType<int>(_TestInt); Assert.That(_SUT1.ToString() == _TestClass.ToString()); Assert.That(_SUT2.ToString() == _TestString); Assert.That(_SUT3.ToString() == _TestInt.ToString()); }
private static ArticyData.SemanticType ConvertSemanticType(SemanticType semanticType) { switch (semanticType) { case SemanticType.Input: return ArticyData.SemanticType.Input; case SemanticType.Output: return ArticyData.SemanticType.Output; default: Debug.LogWarning(string.Format("{0}: Unexpected semantic type {1}", DialogueDebug.Prefix, semanticType.ToString())); return ArticyData.SemanticType.Input; } }
public VertexSemanticAttribute(SemanticType type) { Type = type; }
public ColumnBuilder WithSemanticType(SemanticType semanticType) { _semanticType = semanticType; return(this); }
public Pin() : base() { id = string.Empty; index = 0; semantic = SemanticType.Input; expression = string.Empty; }
public void EqualityComparison_DifferentValue_WorksForClass() { var _SUT1 = new SemanticType<TestClass>(_TestClass); var _SUT2 = new SemanticType<TestClass>(_OtherTestClass); Assert.False(_SUT1 == _SUT2); }