Example #1
0
 private void CheckEdgeType(SequenceCheckingEnvironment env, SequenceExpression IncidentEdgeType, String whichArgument)
 {
     if(IncidentEdgeType != null && IncidentEdgeType.Type(env) != "")
     {
         string typeString = null;
         if(IncidentEdgeType.Type(env) == "string")
         {
             if(IncidentEdgeType is SequenceExpressionConstant)
                 typeString = (string)((SequenceExpressionConstant)IncidentEdgeType).Constant;
         }
         else
         {
             typeString = IncidentEdgeType.Type(env);
         }
         EdgeType edgeType = TypesHelper.GetEdgeType(typeString, env.Model);
         if(edgeType == null && typeString != null)
         {
             throw new SequenceParserException(Symbol + whichArgument, "edge type or string denoting edge type", typeString);
         }
     }
 }
Example #2
0
        /// <summary>
        /// Helper for checking function method calls.
        /// Checks whether called entity exists, and type checks the input.
        /// Throws an exception when an error is found.
        /// </summary>
        /// <param name="seq">The sequence expression to check, must be a function call</param>
        /// <param name="targetExpr">The target of the procedure function call</param>
        public void CheckFunctionMethodCall(SequenceExpression targetExpr, SequenceExpression seq)
        {
            if(targetExpr.Type(this) == "")
            {
                // only runtime checks possible (we could check whether the called procedure signature exists in at least one of the model types, if not it's a type error, can't work at runtime, but that kind of negative check is not worth the effort)
                return;
            }

            GrGenType ownerType = TypesHelper.GetNodeOrEdgeType(targetExpr.Type(this), Model);
            if(ownerType == null)
            {
                // error, must be node or edge type
                throw new SequenceParserException(targetExpr.Type(this), SequenceParserError.UserMethodsOnlyAvailableForGraphElements);
            }

            CheckFunctionCallBase(seq, ownerType);
        }
Example #3
0
 private void CheckNodeType(SequenceCheckingEnvironment env, SequenceExpression AdjacentNodeType, String whichArgument)
 {
     if(AdjacentNodeType != null && AdjacentNodeType.Type(env) != "")
     {
         string typeString = null;
         if(AdjacentNodeType.Type(env) == "string")
         {
             if(AdjacentNodeType is SequenceExpressionConstant)
                 typeString = (string)((SequenceExpressionConstant)AdjacentNodeType).Constant;
         }
         else
         {
             typeString = AdjacentNodeType.Type(env);
         }
         NodeType nodeType = TypesHelper.GetNodeType(typeString, env.Model);
         if(nodeType == null && typeString != null)
         {
             throw new SequenceParserException(Symbol + whichArgument, "node type or string denoting node type", typeString);
         }
     }
 }
 private string ExtractEdgeType(SourceBuilder source, SequenceExpression typeExpr)
 {
     string incidentEdgeType = "graph.Model.EdgeModel.RootType";
     if(typeExpr != null)
     {
         if(typeExpr.Type(env) != "")
         {
             if(typeExpr.Type(env) == "string")
                 incidentEdgeType = "graph.Model.EdgeModel.GetType((string)" + GetSequenceExpression(typeExpr, source) + ")";
             else
                 incidentEdgeType = "(GRGEN_LIBGR.EdgeType)" + GetSequenceExpression(typeExpr, source);
         }
         else
         {
             incidentEdgeType = GetSequenceExpression(typeExpr, source) + " is string ? "
                 + "graph.Model.EdgeModel.GetType((string)" + GetSequenceExpression(typeExpr, source) + ")"
                 + " : " + "(GRGEN_LIBGR.EdgeType)" + GetSequenceExpression(typeExpr, source);
         }
     }
     return "(" + incidentEdgeType + ")";
 }