public DataType VisitFieldAccess(AttributeAccess a) { // the form of ::A in ruby if (a.Expression == null) { return(a.FieldName.Accept(this)); } DataType targetType = a.Expression.Accept(this); if (targetType is UnionType) { ISet <DataType> types = ((UnionType)targetType).types; DataType retType = DataType.Unknown; foreach (DataType tt in types) { retType = UnionType.Union(retType, getAttrType(a, tt)); } return(retType); } else { return(getAttrType(a, targetType)); } }
public void addRef(AttributeAccess attr, DataType targetType, ISet <Binding> bs) { foreach (Binding b in bs) { putRef(attr, b); if (attr.Parent is Application && b.Type is FunType && targetType is InstanceType) { // method call ((FunType)b.Type).SelfType = targetType; } } }
public static string[] GetMemberNames(AttributeAccess attributeAccess) { string[] methodNames = GetMemberNames(attributeAccess.Qualifier); List <string> names = new List <string>(); names.AddRange(methodNames); string lastMemberName = attributeAccess.Name.Substring(0, attributeAccess.Name.Length - 1); names.Add(lastMemberName); return(names.ToArray()); }
private static void setAttrType(Analyzer analyzer, AttributeAccess attr, DataType targetType, DataType attrType) { if (targetType.isUnknownType()) { analyzer.putProblem(attr, "Can't set attribute for UnknownType"); return; } ISet <Binding> bs = targetType.Table.LookupAttribute(attr.FieldName.Name); if (bs != null) { analyzer.addRef(attr, targetType, bs); } targetType.Table.Insert(analyzer, attr.FieldName.Name, attr, attrType, BindingKind.ATTRIBUTE); }
private static void setAttr(Analyzer analyzer, AttributeAccess attr, DataType attrType, DataType targetType) { if (targetType is UnionType) { ISet <DataType> types = ((UnionType)targetType).types; foreach (DataType tp in types) { setAttrType(analyzer, attr, tp, attrType); } } else { setAttrType(analyzer, attr, targetType, attrType); } }
public DataType GetAttrType(AttributeAccess a, DataType targetType) { ISet <Binding> bs = targetType.Table.LookupAttribute(a.FieldName.Name); if (bs == null) { analyzer.putProblem(a.FieldName, "attribute not found in type: " + targetType); DataType t = DataType.Unknown; t.Table.Path = targetType.Table.ExtendPath(analyzer, a.FieldName.Name); return(t); } else { analyzer.addRef(a, targetType, bs); return(State.MakeUnion(bs)); } }
private static void FoldLastOperands(ref List <Expr> operands, Token op) { Expr leftOperand = operands[operands.Count - 2]; Expr rightOperand = operands[operands.Count - 1]; Expr operation; if (op.Type == TokenInfo.TokenType.DOT) { operation = new AttributeAccess(leftOperand, rightOperand); } else { operation = new InfixOp(leftOperand, rightOperand, op); } operands.RemoveAt(operands.Count - 1); operands.RemoveAt(operands.Count - 1); operands.Add(operation); }
void WalkSimpleAssignment(SimpleAssignmentExpression node) { AttributeAccess attributeAccess = node.Left as AttributeAccess; InstanceVariable instance = node.Left as InstanceVariable; LocalVariable localVariable = node.Left as LocalVariable; if (attributeAccess != null) { RubyControlFieldExpression field = RubyControlFieldExpression.Create(attributeAccess); object propertyValue = deserializer.Deserialize(node.Right); if (propertyValue != null) { field.SetPropertyValue(componentCreator, propertyValue); } else if (IsResource(node.Right)) { field.SetPropertyValue(componentCreator, GetResource(node.Right as MethodCall)); } else { ThrowCouldNotFindTypeException(node.Right); } } else if (instance != null) { string instanceName = RubyControlFieldExpression.GetVariableName(instance.Name); object propertyValue = deserializer.Deserialize(instanceName, node.Right); AddComponent(instanceName, propertyValue); } else if (localVariable != null) { object propertyValue = deserializer.Deserialize(localVariable.Name, node.Right); if (propertyValue == null) { ThrowCouldNotFindTypeException(node.Right); } } }
public CodeExpression VisitFieldAccess(AttributeAccess acc) { var exp = acc.Expression.Accept(this); return(m.Access(exp, acc.FieldName.Name)); }
public void VisitFieldAccess(AttributeAccess acc) { throw new NotImplementedException(); }
public void addRef(AttributeAccess attr, DataType targetType, ISet<Binding> bs) { foreach (Binding b in bs) { putRef(attr, b); if (attr.Parent != null && attr.Parent is Application && b.type is FunType && targetType is InstanceType) { // method call ((FunType) b.type).SelfType = targetType; } } }
/// <summary> /// Creates a RubyControlField from an attribute access expression: /// /// @textBox1.Name = /// self.textBox1 = /// self.textBox1.Name = /// </summary> public static RubyControlFieldExpression Create(AttributeAccess expression) { return(Create(GetMemberNames(expression))); }
private static void setAttrType(Analyzer analyzer, AttributeAccess attr, DataType targetType, DataType attrType) { if (targetType.isUnknownType()) { analyzer.putProblem(attr, "Can't set attribute for UnknownType"); return; } ISet<Binding> bs = targetType.Table.LookupAttribute(attr.FieldName.Name); if (bs != null) { analyzer.addRef(attr, targetType, bs); } targetType.Table.Insert(analyzer, attr.FieldName.Name, attr, attrType, BindingKind.ATTRIBUTE); }
private static void setAttr(Analyzer analyzer, AttributeAccess attr, DataType attrType, DataType targetType) { if (targetType is UnionType) { ISet<DataType> types = ((UnionType) targetType).types; foreach (DataType tp in types) { setAttrType(analyzer, attr, tp, attrType); } } else { setAttrType(analyzer, attr, targetType, attrType); } }