コード例 #1
0
 protected override int NumOutputParameters(Invocation invocation, GrGenType ownerType)
 {
     if (invocation is RuleInvocation)
     {
         RuleInvocation ruleInvocation = (RuleInvocation)invocation;
         return(actionsTypeInformation.rulesToOutputTypes[ruleInvocation.PackagePrefixedName].Count);
     }
     else if (invocation is SequenceInvocation)
     {
         SequenceInvocation seqInvocation = (SequenceInvocation)invocation;
         return(actionsTypeInformation.sequencesToOutputTypes[seqInvocation.PackagePrefixedName].Count);
     }
     else if (invocation is ProcedureInvocation)
     {
         ProcedureInvocation procInvocation = (ProcedureInvocation)invocation;
         if (ownerType != null)
         {
             IProcedureDefinition procDef = ownerType.GetProcedureMethod(procInvocation.Name);
             return(procDef.Outputs.Length);
         }
         else
         {
             return(actionsTypeInformation.proceduresToOutputTypes[procInvocation.PackagePrefixedName].Count);
         }
     }
     throw new Exception("Internal error");
 }
コード例 #2
0
 protected override string OutputParameterType(int i, Invocation invocation, GrGenType ownerType)
 {
     if (invocation is RuleInvocation)
     {
         RuleInvocation ruleInvocation = (RuleInvocation)invocation;
         return(actionsTypeInformation.rulesToOutputTypes[ruleInvocation.PackagePrefixedName][i]);
     }
     else if (invocation is SequenceInvocation)
     {
         SequenceInvocation seqInvocation = (SequenceInvocation)invocation;
         return(actionsTypeInformation.sequencesToOutputTypes[seqInvocation.PackagePrefixedName][i]);
     }
     else if (invocation is ProcedureInvocation)
     {
         ProcedureInvocation procInvocation = (ProcedureInvocation)invocation;
         if (ownerType != null)
         {
             IProcedureDefinition procDef = ownerType.GetProcedureMethod(procInvocation.Name);
             return(TypesHelper.DotNetTypeToXgrsType(procDef.Outputs[i]));
         }
         else
         {
             return(actionsTypeInformation.proceduresToOutputTypes[procInvocation.PackagePrefixedName][i]);
         }
     }
     throw new Exception("Internal error");
 }
コード例 #3
0
 protected override string InputParameterType(int i, Invocation invocation, GrGenType ownerType)
 {
     if (invocation is RuleInvocation)
     {
         RuleInvocation ruleInvocation = (RuleInvocation)invocation;
         IAction        action         = SequenceBase.GetAction(ruleInvocation);
         return(TypesHelper.DotNetTypeToXgrsType(action.RulePattern.Inputs[i]));
     }
     else if (invocation is SequenceInvocation)
     {
         SequenceSequenceCallInterpreted seqInvocation = (SequenceSequenceCallInterpreted)invocation;
         if (seqInvocation.SequenceDef is SequenceDefinitionInterpreted)
         {
             SequenceDefinitionInterpreted seqDef = (SequenceDefinitionInterpreted)seqInvocation.SequenceDef;
             return(seqDef.InputVariables[i].Type);
         }
         else
         {
             SequenceDefinitionCompiled seqDef = (SequenceDefinitionCompiled)seqInvocation.SequenceDef;
             return(TypesHelper.DotNetTypeToXgrsType(seqDef.SeqInfo.ParameterTypes[i]));
         }
     }
     else if (invocation is ProcedureInvocation)
     {
         ProcedureInvocation procInvocation = (ProcedureInvocation)invocation;
         if (ownerType != null)
         {
             IProcedureDefinition procDef = ownerType.GetProcedureMethod(procInvocation.Name);
             return(TypesHelper.DotNetTypeToXgrsType(procDef.Inputs[i]));
         }
         else
         {
             SequenceComputationProcedureCallInterpreted procInvocationInterpreted = (SequenceComputationProcedureCallInterpreted)procInvocation;
             return(TypesHelper.DotNetTypeToXgrsType(procInvocationInterpreted.ProcedureDef.Inputs[i]));
         }
     }
     else if (invocation is FunctionInvocation)
     {
         FunctionInvocation funcInvocation = (FunctionInvocation)invocation;
         if (ownerType != null)
         {
             IFunctionDefinition funcDef = ownerType.GetFunctionMethod(funcInvocation.Name);
             return(TypesHelper.DotNetTypeToXgrsType(funcDef.Inputs[i]));
         }
         else
         {
             SequenceExpressionFunctionCallInterpreted funcInvocationInterpreted = (SequenceExpressionFunctionCallInterpreted)funcInvocation;
             return(TypesHelper.DotNetTypeToXgrsType(funcInvocationInterpreted.FunctionDef.Inputs[i]));
         }
     }
     throw new Exception("Internal error");
 }
コード例 #4
0
 protected override int NumInputParameters(Invocation invocation, InheritanceType ownerType)
 {
     if (invocation is RuleInvocation)
     {
         RuleInvocation ruleInvocation = (RuleInvocation)invocation;
         IAction        action         = SequenceBase.GetAction(ruleInvocation);
         return(action.RulePattern.Inputs.Length);
     }
     else if (invocation is SequenceInvocation)
     {
         SequenceSequenceCallInterpreted seqInvocation = (SequenceSequenceCallInterpreted)invocation;
         if (seqInvocation.SequenceDef is SequenceDefinitionInterpreted)
         {
             SequenceDefinitionInterpreted seqDef = (SequenceDefinitionInterpreted)seqInvocation.SequenceDef;
             return(seqDef.InputVariables.Length);
         }
         else
         {
             SequenceDefinitionCompiled seqDef = (SequenceDefinitionCompiled)seqInvocation.SequenceDef;
             return(seqDef.SeqInfo.ParameterTypes.Length);
         }
     }
     else if (invocation is ProcedureInvocation)
     {
         ProcedureInvocation procInvocation = (ProcedureInvocation)invocation;
         if (ownerType != null)
         {
             IProcedureDefinition procDef = ownerType.GetProcedureMethod(procInvocation.Name);
             return(procDef.Inputs.Length);
         }
         else
         {
             SequenceComputationProcedureCallInterpreted procInvocationInterpreted = (SequenceComputationProcedureCallInterpreted)procInvocation;
             return(procInvocationInterpreted.ProcedureDef.Inputs.Length);
         }
     }
     else if (invocation is FunctionInvocation)
     {
         FunctionInvocation funcInvocation = (FunctionInvocation)invocation;
         if (ownerType != null)
         {
             IFunctionDefinition funcDef = ownerType.GetFunctionMethod(funcInvocation.Name);
             return(funcDef.Inputs.Length);
         }
         else
         {
             SequenceExpressionFunctionCallInterpreted funcInvocationInterpreted = (SequenceExpressionFunctionCallInterpreted)funcInvocation;
             return(funcInvocationInterpreted.FunctionDef.Inputs.Length);
         }
     }
     throw new Exception("Internal error");
 }
コード例 #5
0
 /// <summary>
 /// Instantiates a new ProcedureInvocationParameterBindings object
 /// </summary>
 /// <param name="procedureDef">The defined procedure to be used</param>
 /// <param name="argExprs">An array of expressions used to compute the arguments</param>
 /// <param name="arguments">An array of arguments.</param>
 /// <param name="returnVars">An array of variables used for the return values</param>
 public ProcedureInvocationParameterBindings(IProcedureDefinition procedureDef,
                                             SequenceExpression[] argExprs, object[] arguments, SequenceVariable[] returnVars)
     : base(argExprs, arguments, returnVars)
 {
     ProcedureDef = procedureDef;
     if (procedureDef != null)
     {
         Name                = procedureDef.Name;
         PrePackage          = procedureDef.Package;
         Package             = PrePackage;
         PackagePrefixedName = Package != null ? Package + "::" + Name : Name;
     }
 }
コード例 #6
0
        public override SequenceComputationProcedureCall CreateSequenceComputationProcedureCallUserProcedure(String procedureName, String packagePrefix,
                                                                                                             List <SequenceExpression> argExprs, List <SequenceVariable> returnVars)
        {
            String packagePrefixedProcedureName = !PackageIsNullOrGlobal(packagePrefix) ? packagePrefix + "::" + procedureName : procedureName;
            IProcedureDefinition procedureDef   = actions.GetProcedureDefinition(packagePrefixedProcedureName);

            if (procedureDef == null)
            {
                throw new SequenceParserException(packagePrefixedProcedureName, DefinitionType.Procedure, SequenceParserError.UnknownProcedure);
            }

            return(new SequenceComputationProcedureCallInterpreted(procedureDef, argExprs, returnVars));
        }
コード例 #7
0
        public String BuildParameters(Invocation invocation, SequenceExpression[] ArgumentExpressions, IProcedureDefinition procedureMethod, SourceBuilder source)
        {
            String parameters = "";

            for (int i = 0; i < ArgumentExpressions.Length; i++)
            {
                String typeName = TypesHelper.DotNetTypeToXgrsType(procedureMethod.Inputs[i]);
                String cast     = "(" + TypesHelper.XgrsTypeToCSharpType(typeName, model) + ")";
                parameters += ", " + cast + exprGen.GetSequenceExpression(ArgumentExpressions[i], source);
            }
            return(parameters);
        }
コード例 #8
0
 /// <summary>
 /// Instantiates a new ProcedureInvocationParameterBindings object
 /// </summary>
 /// <param name="procedureDef">The defined procedure to be used</param>
 /// <param name="argExprs">An array of expressions used to compute the arguments</param>
 /// <param name="arguments">An array of arguments.</param>
 /// <param name="returnVars">An array of variables used for the return values</param>
 public ProcedureInvocationParameterBindings(IProcedureDefinition procedureDef,
     SequenceExpression[] argExprs, object[] arguments, SequenceVariable[] returnVars)
     : base(argExprs, arguments, returnVars)
 {
     ProcedureDef = procedureDef;
     if(procedureDef != null)
     {
         Name = procedureDef.Name;
         PrePackage = procedureDef.Package;
         Package = PrePackage;
         PackagePrefixedName = Package != null ? Package + "::" + Name : Name;
     }
 }
コード例 #9
0
 private String BuildParameters(InvocationParameterBindings paramBindings, IProcedureDefinition procedureMethod)
 {
     String parameters = "";
     for(int i = 0; i < paramBindings.ArgumentExpressions.Length; i++)
     {
         if(paramBindings.ArgumentExpressions[i] != null)
         {
             String typeName = TypesHelper.DotNetTypeToXgrsType(procedureMethod.Inputs[i]);
             String cast = "(" + TypesHelper.XgrsTypeToCSharpType(typeName, model) + ")";
             parameters += ", " + cast + GetSequenceExpression(paramBindings.ArgumentExpressions[i], null);
         }
         else
         {
             // the sequence parser always emits all argument expressions, for interpreted and compiled
             throw new Exception("Internal error: missing argument expressions");
         }
     }
     return parameters;
 }