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"); }
public void BuildOutParameters(SequenceInvocation invocation, SequenceVariable[] ReturnVars, out String outParameterDeclarations, out String outArguments, out String outAssignments) { outParameterDeclarations = ""; outArguments = ""; outAssignments = ""; for (int i = 0; i < actionsTypeInformation.sequencesToOutputTypes[invocation.PackagePrefixedName].Count; ++i) { String varName; if (ReturnVars.Length != 0) { varName = GetUniqueId() + ReturnVars[i].PureName; } else { varName = GetUniqueId(); } String typeName = actionsTypeInformation.sequencesToOutputTypes[invocation.PackagePrefixedName][i]; outParameterDeclarations += TypesHelper.XgrsTypeToCSharpType(typeName, model) + " tmpvar_" + varName + " = " + TypesHelper.DefaultValueString(typeName, model) + ";"; outArguments += ", ref tmpvar_" + varName; if (ReturnVars.Length != 0) { outAssignments += SetVar(ReturnVars[i], "tmpvar_" + varName); } } }
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"); }
private void CheckSubgraph(Invocation invocation) { SequenceVariable subgraph; if (invocation is RuleInvocation) { RuleInvocation ruleInvocation = (RuleInvocation)invocation; subgraph = ruleInvocation.Subgraph; } else { SequenceInvocation sequenceInvocation = (SequenceInvocation)invocation; subgraph = sequenceInvocation.Subgraph; } if (subgraph != null && !TypesHelper.IsSameOrSubtype("graph", subgraph.Type, Model)) { throw new SequenceParserException(invocation.Name, subgraph.Type, SequenceParserError.SubgraphTypeError); } }