Ejemplo n.º 1
0
        internal virtual SetOpVar CreateSetOpVar(TypeUsage type)
        {
            SetOpVar setOpVar = new SetOpVar(this.NewVarId(), type);

            this.m_vars.Add((Var)setOpVar);
            return(setOpVar);
        }
Ejemplo n.º 2
0
 internal virtual void BuildUnionAllLadder(
     IList <Node> inputNodes,
     IList <Var> inputVars,
     out Node resultNode,
     out IList <Var> resultVars)
 {
     if (inputNodes.Count == 0)
     {
         resultNode = (Node)null;
         resultVars = (IList <Var>)null;
     }
     else
     {
         int num = inputVars.Count / inputNodes.Count;
         if (inputNodes.Count == 1)
         {
             resultNode = inputNodes[0];
             resultVars = inputVars;
         }
         else
         {
             List <Var> varList1 = new List <Var>();
             Node       node     = inputNodes[0];
             for (int index = 0; index < num; ++index)
             {
                 varList1.Add(inputVars[index]);
             }
             for (int index1 = 1; index1 < inputNodes.Count; ++index1)
             {
                 VarMap     leftMap  = new VarMap();
                 VarMap     rightMap = new VarMap();
                 List <Var> varList2 = new List <Var>();
                 for (int index2 = 0; index2 < num; ++index2)
                 {
                     SetOpVar setOpVar = this.CreateSetOpVar(varList1[index2].Type);
                     varList2.Add((Var)setOpVar);
                     leftMap.Add((Var)setOpVar, varList1[index2]);
                     rightMap.Add((Var)setOpVar, inputVars[index1 * num + index2]);
                 }
                 node     = this.CreateNode((Op)this.CreateUnionAllOp(leftMap, rightMap), node, inputNodes[index1]);
                 varList1 = varList2;
             }
             resultNode = node;
             resultVars = (IList <Var>)varList1;
         }
     }
 }
        /// <summary>
        ///     Flattens a SetOpVar (used in SetOps). Simply produces a list of
        ///     properties corresponding to each desired property
        /// </summary>
        /// <param name="v"> </param>
        /// <returns> </returns>
        private VarInfo FlattenSetOpVar(SetOpVar v)
        {
            if (TypeUtils.IsCollectionType(v.Type))
            {
                var newType = GetNewType(v.Type);
                Var newVar = m_command.CreateSetOpVar(newType);
                return m_varInfoMap.CreateCollectionVarInfo(v, newVar);
            }
            else if (md.TypeSemantics.IsEnumerationType(v.Type)
                     || md.TypeSemantics.IsStrongSpatialType(v.Type))
            {
                var newType = GetNewType(v.Type);
                Var newVar = m_command.CreateSetOpVar(newType);
                return m_varInfoMap.CreatePrimitiveTypeVarInfo(v, newVar);
            }

            // Get the "new" type for the Var
            var typeInfo = m_typeInfo.GetTypeInfo(v.Type);
            // Get a list of properties that we think are necessary 
            var desiredProperties = m_varPropertyMap[v];
            var newVars = new List<Var>();
            var newProps = new List<md.EdmProperty>();
            var hasNullSentinelVar = false;
            foreach (var p in typeInfo.PropertyRefList)
            {
                if (!desiredProperties.Contains(p))
                {
                    continue;
                }
                var newProperty = typeInfo.GetNewProperty(p);
                newProps.Add(newProperty);
                var newVar = m_command.CreateSetOpVar(md.Helper.GetModelTypeUsage(newProperty));
                newVars.Add(newVar);

                // Check if it is a null sentinel var
                if (!hasNullSentinelVar
                    && IsNullSentinelPropertyRef(p))
                {
                    hasNullSentinelVar = true;
                }
            }
            var varInfo = m_varInfoMap.CreateStructuredVarInfo(v, typeInfo.FlattenedType, newVars, newProps, hasNullSentinelVar);
            return varInfo;
        }
Ejemplo n.º 4
0
 // <summary>
 // Creates a SetOp Var of
 // </summary>
 // <param name="type"> Datatype of the Var </param>
 // <returns> A new SetOp Var with the specified result type </returns>
 internal virtual SetOpVar CreateSetOpVar(TypeUsage type)
 {
     var v = new SetOpVar(NewVarId(), type);
     m_vars.Add(v);
     return v;
 }