Ejemplo n.º 1
0
 public FunctionDescriptorParams()
 {
     IsVisibleInLibrary = true;
     Parameters         = new List <TypedParameter>();
     ReturnKeys         = new List <string>();
     ReturnType         = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar);
 }
        public static ProtoCore.AST.AssociativeAST.IdentifierNode BuildAssocIdentifier(Core core, string name, ProtoCore.PrimitiveType type = ProtoCore.PrimitiveType.kTypeVar)
        {
            var ident = new ProtoCore.AST.AssociativeAST.IdentifierNode();

            ident.Name     = ident.Value = name;
            ident.datatype = TypeSystem.BuildPrimitiveTypeObject(type, 0);
            return(ident);
        }
Ejemplo n.º 3
0
        public static ProtoCore.AST.AssociativeAST.IdentifierNode BuildAssocIdentifier(ProtoLanguage.CompileStateTracker compileState, string name, ProtoCore.PrimitiveType type = ProtoCore.PrimitiveType.kTypeVar)
        {
            var ident = new ProtoCore.AST.AssociativeAST.IdentifierNode();

            ident.Name     = ident.Value = name;
            ident.datatype = TypeSystem.BuildPrimitiveTypeObject(type, false);
            return(ident);
        }
Ejemplo n.º 4
0
        private FunctionDescriptor GetConstructorMethod()
        {
            var funcDesc = new FunctionDescriptor(new FunctionDescriptorParams
            {
                Assembly     = "MyAssembly.dll",
                ClassName    = "MyNamespace.MyClass",
                FunctionName = "MyClass",
                ReturnType   = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.Var),
                FunctionType = FunctionType.Constructor
            });

            return(funcDesc);
        }
Ejemplo n.º 5
0
        private static FunctionDescriptor GetTranslateMethod()
        {
            var parms = new List <TypedParameter>()
            {
                new TypedParameter("xTranslation", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeDouble, 0)),
                new TypedParameter("yTranslation", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeDouble, 0)),
                new TypedParameter("zTranslation", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeDouble, 0))
            };

            var funcDesc = new FunctionDescriptor(
                "ProtoGeometry.dll",
                "Autodesk.DesignScript.Geometry.Geometry",
                "Translate",
                parms,
                TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar),
                FunctionType.InstanceMethod);

            parms.ForEach(x => x.Function = funcDesc);

            return(funcDesc);
        }
Ejemplo n.º 6
0
        private static FunctionDescriptor GetTranslateMethod()
        {
            var parms = new List<TypedParameter>()
            {
                new TypedParameter("xTranslation", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeDouble, 0)),
                new TypedParameter("yTranslation", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeDouble, 0)),
                new TypedParameter("zTranslation", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeDouble, 0))
            };

            var funcDesc = new FunctionDescriptor(new FunctionDescriptorParams
            {
                Assembly = "ProtoGeometry.dll",
                ClassName = "Autodesk.DesignScript.Geometry.Geometry",
                FunctionName = "Translate",
                Parameters = parms,
                ReturnType = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar),
                FunctionType = FunctionType.InstanceMethod
            });

            parms.ForEach(x => x.UpdateFunctionDescriptor(funcDesc, null));

            return funcDesc;
        }
Ejemplo n.º 7
0
        private FunctionDescriptor GetMyMethod(string methodName = "MyMethod")
        {
            var parms = new List <TypedParameter>()
            {
                new TypedParameter("a", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.Double, 0)),
                new TypedParameter("b", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.Double, 0)),
                new TypedParameter("c", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.Double, 0))
            };

            var funcDesc = new FunctionDescriptor(new FunctionDescriptorParams
            {
                Assembly     = "MyAssembly.dll",
                ClassName    = "MyNamespace.MyClass",
                FunctionName = methodName,
                Parameters   = parms,
                ReturnType   = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.Var),
                FunctionType = FunctionType.InstanceMethod
            });

            parms.ForEach(x => x.UpdateFunctionDescriptor(funcDesc));

            return(funcDesc);
        }
Ejemplo n.º 8
0
 private static IEnumerable <TypedParameter> GetUnaryFuncArgs()
 {
     return(new List <TypedParameter> {
         new TypedParameter("x", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar)),
     });
 }
Ejemplo n.º 9
0
        /// <summary>
        ///     Compiles a collection of Dynamo nodes into a function definition for a custom node.
        /// </summary>
        /// <param name="functionId"></param>
        /// <param name="returnKeys"></param>
        /// <param name="functionName"></param>
        /// <param name="funcBody"></param>
        /// <param name="outputNodes"></param>
        /// <param name="parameters"></param>
        /// <param name="verboseLogging"></param>
        public void CompileCustomNodeDefinition(
            Guid functionId, IEnumerable <string> returnKeys, string functionName,
            IEnumerable <NodeModel> funcBody, IEnumerable <AssociativeNode> outputNodes,
            IEnumerable <TypedParameter> parameters, bool verboseLogging)
        {
            OnAstNodeBuilding(functionId);

            var functionBody = new CodeBlockNode();
            var asts         = CompileToAstNodes(funcBody, CompilationContext.None, verboseLogging);

            functionBody.Body.AddRange(asts.SelectMany(t => t.Item2));

            var outputs = outputNodes.ToList();

            if (outputs.Count > 1)
            {
                /* rtn_array = {};
                 * rtn_array[key0] = out0;
                 * rtn_array[key1] = out1;
                 * ...
                 * return = rtn_array;
                 */

                // return array, holds all outputs
                string rtnName = "__temp_rtn_" + functionId.ToString().Replace("-", String.Empty);
                functionBody.Body.Add(
                    AstFactory.BuildAssignment(
                        AstFactory.BuildIdentifier(rtnName),
                        AstFactory.BuildExprList(new List <string>())));

                // indexers for each output
                IEnumerable <AssociativeNode> indexers = returnKeys != null
                    ? returnKeys.Select(AstFactory.BuildStringNode) as IEnumerable <AssociativeNode>
                    : Enumerable.Range(0, outputs.Count).Select(AstFactory.BuildIntNode);

                functionBody.Body.AddRange(
                    outputs.Zip(
                        indexers,
                        (outputId, indexer) => // for each outputId and return key
                        // pack the output into the return array
                        AstFactory.BuildAssignment(AstFactory.BuildIdentifier(rtnName, indexer), outputId)));

                // finally, return the return array
                functionBody.Body.Add(AstFactory.BuildReturnStatement(AstFactory.BuildIdentifier(rtnName)));
            }
            else
            {
                // For single output, directly return that identifier or null.
                AssociativeNode returnValue = outputs.Count == 1 ? outputs[0] : new NullNode();
                functionBody.Body.Add(AstFactory.BuildReturnStatement(returnValue));
            }

            Type allTypes = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar);

            //Create a new function definition
            var functionDef = new FunctionDefinitionNode
            {
                Name      = functionName.Replace("-", string.Empty),
                Signature =
                    new ArgumentSignatureNode
                {
                    Arguments =
                        parameters.Select(param => AstFactory.BuildParamNode(param.Name, param.Type)).ToList()
                },
                FunctionBody = functionBody,
                ReturnType   = allTypes
            };

            OnAstNodeBuilt(functionId, new[] { functionDef });
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Simply copy an array.
        /// </summary>
        /// <param name="array"></param>
        /// <param name="core"></param>
        /// <returns></returns>
        public static StackValue CopyArray(StackValue array, Core core)
        {
            Type anyType = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, Constants.kArbitraryRank);

            return(CopyArray(array, anyType, core));
        }
Ejemplo n.º 11
0
        private static IEnumerable <TypedParameter> GetBinaryFuncArgs()
        {
            yield return(new TypedParameter("x", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar)));

            yield return(new TypedParameter("y", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar)));
        }
Ejemplo n.º 12
0
        private static IEnumerable <TypedParameter> GetBinaryFuncArgs()
        {
            yield return(new TypedParameter(null, "x", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, Constants.kArbitraryRank)));

            yield return(new TypedParameter(null, "y", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, Constants.kArbitraryRank)));
        }
Ejemplo n.º 13
0
        /// <summary>
        /// Return possible type of the output at specified output port.
        /// </summary>
        /// <param name="index"></param>
        /// <returns></returns>
        public override ProtoCore.Type GetTypeHintForOutput(int index)
        {
            ProtoCore.Type type      = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar);
            var            statement = GetStatementForOutput(index);

            if (statement == null)
            {
                return(type);
            }

            BinaryExpressionNode expr = statement.AstNode as BinaryExpressionNode;

            if (expr == null || expr.Optr != Operator.assign)
            {
                return(type);
            }

            var core = libraryServices.LibraryManagementCore;

            if (expr.RightNode is IdentifierListNode)
            {
                var identListNode = expr.RightNode as IdentifierListNode;
                var funcNode      = identListNode.RightNode as FunctionCallNode;
                if (funcNode == null)
                {
                    return(type);
                }

                string fullyQualitifiedName = CoreUtils.GetIdentifierExceptMethodName(identListNode);
                if (string.IsNullOrEmpty(fullyQualitifiedName))
                {
                    return(type);
                }

                var classIndex = core.ClassTable.IndexOf(fullyQualitifiedName);
                if (classIndex == ProtoCore.DSASM.Constants.kInvalidIndex)
                {
                    return(type);
                }

                var targetClass = core.ClassTable.ClassNodes[classIndex];
                var func        = targetClass.GetFirstMemberFunctionBy(funcNode.Function.Name);
                type = func.ReturnType;
                return(type);
            }
            else if (expr.RightNode is FunctionCallNode)
            {
                var functionCallNode = expr.RightNode as FunctionCallNode;
                ProtoCore.FunctionGroup funcGroup;
                var funcTable = core.FunctionTable.GlobalFuncTable[0];
                if (funcTable.TryGetValue(functionCallNode.Function.Name, out funcGroup))
                {
                    var func = funcGroup.FunctionEndPoints.FirstOrDefault();
                    if (func != null)
                    {
                        return(func.procedureNode.ReturnType);
                    }
                }
            }
            else if (expr.RightNode is IntNode)
            {
                return(TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeInt));
            }
            else if (expr.RightNode is StringNode)
            {
                return(TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeString));
            }
            else if (expr.RightNode is DoubleNode)
            {
                return(TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeDouble));
            }
            else if (expr.RightNode is StringNode)
            {
                return(TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeString));
            }

            return(type);
        }
Ejemplo n.º 14
0
        /// <summary>
        /// <param name="core"></param>
        /// <returns></returns>
        /// </summary>
        public StackValue CopyArray(RuntimeCore runtimeCore)
        {
            Type anyType = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.Var, Constants.kArbitraryRank);

            return(CopyArray(anyType, runtimeCore));
        }
Ejemplo n.º 15
0
        /// <summary>
        /// array[index1][index2][...][indexN] = value, and
        /// indices = {index1, index2, ..., indexN}
        /// </summary>
        /// <param name="indices"></param>
        /// <param name="value"></param>
        /// <param name="t"></param>
        /// <param name="core"></param>
        /// <returns></returns>
        public StackValue SetValueForIndices(List <StackValue> indices, StackValue value, RuntimeCore runtimeCore)
        {
            StackValue[][] zippedIndices = ArrayUtils.GetZippedIndices(indices, runtimeCore);
            if (zippedIndices == null || zippedIndices.Length == 0)
            {
                return(StackValue.Null);
            }

            var t = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.Var);

            if (zippedIndices.Length == 1)
            {
                StackValue coercedData = TypeSystem.Coerce(value, t, runtimeCore);
                return(SetValueForIndices(zippedIndices[0], coercedData, runtimeCore));
            }

            if (value.IsArray)
            {
                // Replication happens on both side.
                DSArray dataElements = heap.ToHeapObject <DSArray>(value);
                int     length       = Math.Min(zippedIndices.Length, dataElements.Count);

                StackValue[] oldValues = new StackValue[length];
                for (int i = 0; i < length; ++i)
                {
                    StackValue coercedData = TypeSystem.Coerce(dataElements.GetValueAt(i), t, runtimeCore);
                    oldValues[i] = SetValueForIndices(zippedIndices[i], coercedData, runtimeCore);
                }

                // The returned old values shouldn't have any key-value pairs
                try
                {
                    return(heap.AllocateArray(oldValues));
                }
                catch (RunOutOfMemoryException)
                {
                    runtimeCore.RuntimeStatus.LogWarning(WarningID.RunOutOfMemory, Resources.RunOutOfMemory);
                    return(StackValue.Null);
                }
            }
            else
            {
                // Replication is only on the LHS, so collect all old values
                // and return them in an array.
                StackValue coercedData = TypeSystem.Coerce(value, t, runtimeCore);

                StackValue[] oldValues = new StackValue[zippedIndices.Length];
                for (int i = 0; i < zippedIndices.Length; ++i)
                {
                    oldValues[i] = SetValueForIndices(zippedIndices[i], coercedData, runtimeCore);
                }

                // The returned old values shouldn't have any key-value pairs
                try
                {
                    return(heap.AllocateArray(oldValues));
                }
                catch (RunOutOfMemoryException)
                {
                    runtimeCore.RuntimeStatus.LogWarning(WarningID.RunOutOfMemory, Resources.RunOutOfMemory);
                    return(StackValue.Null);
                }
            }
        }
Ejemplo n.º 16
0
        public BuiltInMethods(Core core)
        {
            Validity.Assert(null == Methods);
            Methods = new List <BuiltInMethod>()
            {
                new BuiltInMethod
                {
                    ReturnType = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeInt, 0),
                    Parameters = new List <KeyValuePair <string, ProtoCore.Type> >
                    {
                        new KeyValuePair <string, ProtoCore.Type>("array", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, Constants.kArbitraryRank))
                    },
                    ID = BuiltInMethods.MethodID.kCount
                },

                new BuiltInMethod
                {
                    ReturnType = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeBool, 0),
                    Parameters = new List <KeyValuePair <string, ProtoCore.Type> >
                    {
                        new KeyValuePair <string, ProtoCore.Type>("array", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, Constants.kArbitraryRank))
                    },
                    ID = BuiltInMethods.MethodID.kSomeNulls,
                    MethodAttributes = new MethodAttributes(true),
                },

                new BuiltInMethod
                {
                    ReturnType = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeInt, 0),
                    Parameters = new List <KeyValuePair <string, ProtoCore.Type> >
                    {
                        new KeyValuePair <string, ProtoCore.Type>("array", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, Constants.kArbitraryRank))
                    },
                    ID = BuiltInMethods.MethodID.kRank
                },

                new BuiltInMethod
                {
                    ReturnType = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, 1),
                    Parameters = new List <KeyValuePair <string, ProtoCore.Type> >
                    {
                        new KeyValuePair <string, ProtoCore.Type>("array", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, Constants.kArbitraryRank))
                    },
                    ID = BuiltInMethods.MethodID.kFlatten
                },

                new BuiltInMethod
                {
                    ReturnType = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, Constants.kArbitraryRank),
                    Parameters = new List <KeyValuePair <string, ProtoCore.Type> >
                    {
                        new KeyValuePair <string, ProtoCore.Type>("array1", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, Constants.kArbitraryRank)),
                        new KeyValuePair <string, ProtoCore.Type>("array2", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, Constants.kArbitraryRank))
                    },
                    ID = BuiltInMethods.MethodID.kConcat,
                    //MAGN-3382 MethodAttributes = new MethodAttributes(true),
                },

                new BuiltInMethod
                {
                    ReturnType = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, 1),
                    Parameters = new List <KeyValuePair <string, ProtoCore.Type> >
                    {
                        new KeyValuePair <string, ProtoCore.Type>("array1", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, 1)),
                        new KeyValuePair <string, ProtoCore.Type>("array2", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, 1))
                    },
                    ID = BuiltInMethods.MethodID.kIntersection
                },

                new BuiltInMethod
                {
                    ReturnType = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, 1),
                    Parameters = new List <KeyValuePair <string, ProtoCore.Type> >
                    {
                        new KeyValuePair <string, ProtoCore.Type>("array1", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, 1)),
                        new KeyValuePair <string, ProtoCore.Type>("array2", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, 1))
                    },
                    ID = BuiltInMethods.MethodID.kUnion
                },

                new BuiltInMethod
                {
                    ReturnType = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, 1),
                    Parameters = new List <KeyValuePair <string, ProtoCore.Type> >
                    {
                        new KeyValuePair <string, ProtoCore.Type>("array1", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, 1)),
                        new KeyValuePair <string, ProtoCore.Type>("array2", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, 1))
                    },
                    ID = BuiltInMethods.MethodID.kDifference
                },

                new BuiltInMethod
                {
                    ReturnType = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeInt, 0),
                    Parameters = new List <KeyValuePair <string, ProtoCore.Type> >
                    {
                        new KeyValuePair <string, ProtoCore.Type>("array", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, Constants.kArbitraryRank))
                    },
                    ID = BuiltInMethods.MethodID.kCountTrue
                },

                new BuiltInMethod
                {
                    ReturnType = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeInt, 0),
                    Parameters = new List <KeyValuePair <string, ProtoCore.Type> >
                    {
                        new KeyValuePair <string, ProtoCore.Type>("array", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, Constants.kArbitraryRank))
                    },
                    ID = BuiltInMethods.MethodID.kCountFalse
                },

                new BuiltInMethod
                {
                    ReturnType = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeBool, 0),
                    Parameters = new List <KeyValuePair <string, ProtoCore.Type> >
                    {
                        new KeyValuePair <string, ProtoCore.Type>("array", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, Constants.kArbitraryRank))
                    },
                    ID = BuiltInMethods.MethodID.kAllFalse,
                    //MAGN-3382 MethodAttributes = new MethodAttributes(true),
                },

                new BuiltInMethod
                {
                    ReturnType = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeBool, 0),
                    Parameters = new List <KeyValuePair <string, ProtoCore.Type> >
                    {
                        new KeyValuePair <string, ProtoCore.Type>("array", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, Constants.kArbitraryRank))
                    },
                    ID = BuiltInMethods.MethodID.kAllTrue,
                    //MAGN-3382 MethodAttributes = new MethodAttributes(true),
                },

                new BuiltInMethod
                {
                    ReturnType = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeBool, 0),
                    Parameters = new List <KeyValuePair <string, ProtoCore.Type> >
                    {
                        new KeyValuePair <string, ProtoCore.Type>("array", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, Constants.kArbitraryRank))
                    },
                    ID = BuiltInMethods.MethodID.kIsHomogeneous,
                    //MAGN-3382 MethodAttributes = new MethodAttributes(true),
                },

                new BuiltInMethod
                {
                    ReturnType = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeInt, 0),
                    Parameters = new List <KeyValuePair <string, ProtoCore.Type> >
                    {
                        new KeyValuePair <string, ProtoCore.Type>("array", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeInt, Constants.kArbitraryRank))
                    },
                    ID = BuiltInMethods.MethodID.kSum,
                    MethodAttributes = new MethodAttributes(true),
                },

                new BuiltInMethod
                {
                    ReturnType = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeDouble, 0),
                    Parameters = new List <KeyValuePair <string, ProtoCore.Type> >
                    {
                        new KeyValuePair <string, ProtoCore.Type>("array", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeDouble, Constants.kArbitraryRank))
                    },
                    ID = BuiltInMethods.MethodID.kSum,
                    MethodAttributes = new MethodAttributes(true),
                },

                new BuiltInMethod
                {
                    ReturnType = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeDouble, 0),
                    Parameters = new List <KeyValuePair <string, ProtoCore.Type> >
                    {
                        new KeyValuePair <string, ProtoCore.Type>("array", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeInt, Constants.kArbitraryRank))
                    },
                    ID = BuiltInMethods.MethodID.kAverage,
                    MethodAttributes = new MethodAttributes(true),
                },

                new BuiltInMethod
                {
                    ReturnType = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeDouble, 0),
                    Parameters = new List <KeyValuePair <string, ProtoCore.Type> >
                    {
                        new KeyValuePair <string, ProtoCore.Type>("array", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeDouble, Constants.kArbitraryRank))
                    },
                    ID = BuiltInMethods.MethodID.kAverage,
                    MethodAttributes = new MethodAttributes(true),
                },

                new BuiltInMethod
                {
                    ReturnType = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeBool, 0),
                    Parameters = new List <KeyValuePair <string, ProtoCore.Type> >
                    {
                        new KeyValuePair <string, ProtoCore.Type>("array", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, Constants.kArbitraryRank))
                    },
                    ID = BuiltInMethods.MethodID.kSomeTrue,
                    MethodAttributes = new MethodAttributes(true),
                },

                new BuiltInMethod()
                {
                    ReturnType = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVoid, 0),
                    Parameters = new List <KeyValuePair <string, ProtoCore.Type> >
                    {
                        new KeyValuePair <string, ProtoCore.Type>("milliseconds", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeInt, 0)),
                    },
                    ID = BuiltInMethods.MethodID.kSleep,
                    MethodAttributes = new MethodAttributes(true),
                },

                new BuiltInMethod
                {
                    ReturnType = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeBool, 0),
                    Parameters = new List <KeyValuePair <string, ProtoCore.Type> >
                    {
                        new KeyValuePair <string, ProtoCore.Type>("array", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, Constants.kArbitraryRank))
                    },
                    ID = BuiltInMethods.MethodID.kSomeFalse,
                    MethodAttributes = new MethodAttributes(true),
                },

                new BuiltInMethod
                {
                    ReturnType = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, Constants.kArbitraryRank),
                    Parameters = new List <KeyValuePair <string, ProtoCore.Type> >
                    {
                        new KeyValuePair <string, ProtoCore.Type>("array", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, Constants.kArbitraryRank)),
                        new KeyValuePair <string, ProtoCore.Type>("index", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeInt, 0))
                    },
                    ID = BuiltInMethods.MethodID.kRemove,
                    MethodAttributes = new MethodAttributes(true),
                },

                new BuiltInMethod
                {
                    ReturnType = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, Constants.kArbitraryRank),
                    Parameters = new List <KeyValuePair <string, ProtoCore.Type> >
                    {
                        new KeyValuePair <string, ProtoCore.Type>("array", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, Constants.kArbitraryRank))
                    },
                    ID = BuiltInMethods.MethodID.kRemoveDuplicates,
                    MethodAttributes = new MethodAttributes(true),
                },

                new BuiltInMethod
                {
                    ReturnType = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, Constants.kArbitraryRank),
                    Parameters = new List <KeyValuePair <string, ProtoCore.Type> >
                    {
                        new KeyValuePair <string, ProtoCore.Type>("array", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, Constants.kArbitraryRank))
                    },
                    ID = BuiltInMethods.MethodID.kRemoveNulls,
                    MethodAttributes = new MethodAttributes(true),
                },

                new BuiltInMethod
                {
                    ReturnType = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, Constants.kArbitraryRank),
                    Parameters = new List <KeyValuePair <string, ProtoCore.Type> >
                    {
                        new KeyValuePair <string, ProtoCore.Type>("array", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, Constants.kArbitraryRank)),
                        new KeyValuePair <string, ProtoCore.Type>("type", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeString, 0))
                    },
                    ID = BuiltInMethods.MethodID.kRemoveIfNot,
                    //MAGN-3382  MethodAttributes = new MethodAttributes(true),
                },

                new BuiltInMethod
                {
                    ReturnType = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, Constants.kArbitraryRank),
                    Parameters = new List <KeyValuePair <string, ProtoCore.Type> >
                    {
                        new KeyValuePair <string, ProtoCore.Type>("array", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, Constants.kArbitraryRank))
                    },
                    ID = BuiltInMethods.MethodID.kReverse,
                    MethodAttributes = new MethodAttributes(true),
                },

                new BuiltInMethod
                {
                    ReturnType = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeBool, 0),
                    Parameters = new List <KeyValuePair <string, ProtoCore.Type> >
                    {
                        new KeyValuePair <string, ProtoCore.Type>("ObjectA", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, 0)),
                        new KeyValuePair <string, ProtoCore.Type>("ObjectB", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, 0)),
                    },
                    ID = BuiltInMethods.MethodID.kEquals
                },

                new BuiltInMethod
                {
                    ReturnType = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeBool, 0),
                    Parameters = new List <KeyValuePair <string, ProtoCore.Type> >
                    {
                        new KeyValuePair <string, ProtoCore.Type>("ObjectA", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, Constants.kArbitraryRank)),
                        new KeyValuePair <string, ProtoCore.Type>("ObjectB", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, Constants.kArbitraryRank)),
                    },
                    ID = BuiltInMethods.MethodID.kEquals
                },

                new BuiltInMethod
                {
                    ReturnType = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeBool, 0),
                    Parameters = new List <KeyValuePair <string, ProtoCore.Type> >
                    {
                        new KeyValuePair <string, ProtoCore.Type>("array", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, Constants.kArbitraryRank)),
                        new KeyValuePair <string, ProtoCore.Type>("member", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, Constants.kArbitraryRank))
                    },
                    ID = BuiltInMethods.MethodID.kContains
                },

                new BuiltInMethod
                {
                    ReturnType = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeBool, 0),
                    Parameters = new List <KeyValuePair <string, ProtoCore.Type> >
                    {
                        new KeyValuePair <string, ProtoCore.Type>("array", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, Constants.kArbitraryRank)),
                        new KeyValuePair <string, ProtoCore.Type>("member", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, 0))
                    },
                    ID = BuiltInMethods.MethodID.kContains
                },

                new BuiltInMethod
                {
                    ReturnType = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeInt, 0),
                    Parameters = new List <KeyValuePair <string, ProtoCore.Type> >
                    {
                        new KeyValuePair <string, ProtoCore.Type>("array", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, Constants.kArbitraryRank)),
                        new KeyValuePair <string, ProtoCore.Type>("member", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, 0))
                    },
                    ID = BuiltInMethods.MethodID.kIndexOf,
                    MethodAttributes = new MethodAttributes(true),
                },

                new BuiltInMethod
                {
                    ReturnType = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeInt, 0),
                    Parameters = new List <KeyValuePair <string, ProtoCore.Type> >
                    {
                        new KeyValuePair <string, ProtoCore.Type>("array", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, Constants.kArbitraryRank)),
                        new KeyValuePair <string, ProtoCore.Type>("member", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, Constants.kArbitraryRank))
                    },
                    ID = BuiltInMethods.MethodID.kIndexOf
                },

                new BuiltInMethod
                {
                    ReturnType = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, Constants.kArbitraryRank),
                    Parameters = new List <KeyValuePair <string, ProtoCore.Type> >
                    {
                        new KeyValuePair <string, ProtoCore.Type>("array", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, Constants.kArbitraryRank)),
                        new KeyValuePair <string, ProtoCore.Type>("element", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, 0)),
                        new KeyValuePair <string, ProtoCore.Type>("index", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeInt, 0))
                    },
                    ID = BuiltInMethods.MethodID.kInsert
                },

                new BuiltInMethod
                {
                    ReturnType = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, Constants.kArbitraryRank),
                    Parameters = new List <KeyValuePair <string, ProtoCore.Type> >
                    {
                        new KeyValuePair <string, ProtoCore.Type>("array", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, Constants.kArbitraryRank)),
                        new KeyValuePair <string, ProtoCore.Type>("element", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, Constants.kArbitraryRank)),
                        new KeyValuePair <string, ProtoCore.Type>("index", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeInt, 0))
                    },
                    ID = BuiltInMethods.MethodID.kInsert
                },

                //Sort, SortWithMode, SortIndexByValue & SortIndexByValueWithMode
                new BuiltInMethod
                {
                    ReturnType = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeInt, 1),
                    Parameters = new List <KeyValuePair <string, ProtoCore.Type> >
                    {
                        new KeyValuePair <string, ProtoCore.Type>("array", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeInt, 1)),
                    },
                    ID = BuiltInMethods.MethodID.kSort,
                    MethodAttributes = new MethodAttributes(true),
                },

                new BuiltInMethod
                {
                    ReturnType = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeInt, 1),
                    Parameters = new List <KeyValuePair <string, ProtoCore.Type> >
                    {
                        new KeyValuePair <string, ProtoCore.Type>("array", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeInt, 1)),
                        new KeyValuePair <string, ProtoCore.Type>("ascending", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeBool, 0)),
                    },
                    ID = BuiltInMethods.MethodID.kSortWithMode,
                    MethodAttributes = new MethodAttributes(true),
                },

                new BuiltInMethod
                {
                    ReturnType = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeDouble, 1),
                    Parameters = new List <KeyValuePair <string, ProtoCore.Type> >
                    {
                        new KeyValuePair <string, ProtoCore.Type>("array", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeDouble, 1)),
                    },
                    ID = BuiltInMethods.MethodID.kSort,
                    MethodAttributes = new MethodAttributes(true),
                },

                new BuiltInMethod
                {
                    ReturnType = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeDouble, 1),
                    Parameters = new List <KeyValuePair <string, ProtoCore.Type> >
                    {
                        new KeyValuePair <string, ProtoCore.Type>("array", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeDouble, 1)),
                        new KeyValuePair <string, ProtoCore.Type>("ascending", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeBool, 0)),
                    },
                    ID = BuiltInMethods.MethodID.kSortWithMode,
                    MethodAttributes = new MethodAttributes(true),
                },

                new BuiltInMethod
                {
                    ReturnType = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, 1),
                    Parameters = new List <KeyValuePair <string, ProtoCore.Type> >
                    {
                        new KeyValuePair <string, ProtoCore.Type>("comparerFunction", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeFunctionPointer, 0)),
                        new KeyValuePair <string, ProtoCore.Type>("array", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, 1)),
                    },
                    ID = BuiltInMethods.MethodID.kSortPointer,
                    MethodAttributes = new MethodAttributes(true),
                },

                new BuiltInMethod
                {
                    ReturnType = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeInt, 1),
                    Parameters = new List <KeyValuePair <string, ProtoCore.Type> >
                    {
                        new KeyValuePair <string, ProtoCore.Type>("array", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeDouble, 1)),
                    },
                    ID = BuiltInMethods.MethodID.kSortIndexByValue,
                    //MAGN-3382 MethodAttributes = new MethodAttributes(true),
                },

                new BuiltInMethod
                {
                    ReturnType = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeInt, 1),
                    Parameters = new List <KeyValuePair <string, ProtoCore.Type> >
                    {
                        new KeyValuePair <string, ProtoCore.Type>("array", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeDouble, 1)),
                        new KeyValuePair <string, ProtoCore.Type>("ascending", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeBool, 0)),
                    },
                    ID = BuiltInMethods.MethodID.kSortIndexByValueWithMode,
                    //MAGN-3382 MethodAttributes = new MethodAttributes(true),
                },

                new BuiltInMethod
                {
                    ReturnType = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, 1),
                    Parameters = new List <KeyValuePair <string, ProtoCore.Type> >
                    {
                        new KeyValuePair <string, ProtoCore.Type>("array", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, 1)),
                        new KeyValuePair <string, ProtoCore.Type>("indice", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, 1)),
                    },
                    ID = BuiltInMethods.MethodID.kReorder
                },

                new BuiltInMethod
                {
                    ReturnType = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeBool, 0),
                    Parameters = new List <KeyValuePair <string, ProtoCore.Type> >
                    {
                        new KeyValuePair <string, ProtoCore.Type>("array", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, Constants.kArbitraryRank)),
                    },
                    ID = BuiltInMethods.MethodID.kIsUniformDepth,
                    //MAGN-3382 MethodAttributes = new MethodAttributes(true),
                },

                new BuiltInMethod
                {
                    ReturnType = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeBool, 0),
                    Parameters = new List <KeyValuePair <string, ProtoCore.Type> >
                    {
                        new KeyValuePair <string, ProtoCore.Type>("array", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, Constants.kArbitraryRank)),
                    },
                    ID = BuiltInMethods.MethodID.kIsRectangular,
                    //MAGN-3382 MethodAttributes = new MethodAttributes(true),
                },

                new BuiltInMethod
                {
                    ReturnType = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, Constants.kArbitraryRank),
                    Parameters = new List <KeyValuePair <string, ProtoCore.Type> >
                    {
                        new KeyValuePair <string, ProtoCore.Type>("array", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, Constants.kArbitraryRank)),
                    },
                    ID = BuiltInMethods.MethodID.kNormalizeDepth,
                    //MAGN-3382 MethodAttributes = new MethodAttributes(true),
                },

                new BuiltInMethod
                {
                    ReturnType = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, Constants.kArbitraryRank),
                    Parameters = new List <KeyValuePair <string, ProtoCore.Type> >
                    {
                        new KeyValuePair <string, ProtoCore.Type>("array", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, Constants.kArbitraryRank)),
                        new KeyValuePair <string, ProtoCore.Type>("rank", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, 0)),
                    },
                    ID = BuiltInMethods.MethodID.kNormalizeDepthWithRank,
                    //MAGN-3382 MethodAttributes = new MethodAttributes(true),
                },

                new BuiltInMethod
                {
                    ReturnType = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeDouble, 0),
                    Parameters = new List <KeyValuePair <string, ProtoCore.Type> >
                    {
                        new KeyValuePair <string, ProtoCore.Type>("rangeMin", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeDouble, 0)),
                        new KeyValuePair <string, ProtoCore.Type>("rangeMax", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeDouble, 0)),
                        new KeyValuePair <string, ProtoCore.Type>("inputValue", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeDouble, 0)),
                    },
                    ID = BuiltInMethods.MethodID.kMap
                },

                new BuiltInMethod
                {
                    ReturnType = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeDouble, 0),
                    Parameters = new List <KeyValuePair <string, ProtoCore.Type> >
                    {
                        new KeyValuePair <string, ProtoCore.Type>("rangeMin", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeDouble, 0)),
                        new KeyValuePair <string, ProtoCore.Type>("rangeMax", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeDouble, 0)),
                        new KeyValuePair <string, ProtoCore.Type>("inputValue", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeDouble, 0)),
                        new KeyValuePair <string, ProtoCore.Type>("targetRangeMin", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeDouble, 0)),
                        new KeyValuePair <string, ProtoCore.Type>("targetRangeMax", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeDouble, 0)),
                    },
                    ID = BuiltInMethods.MethodID.kMapTo
                },

                new BuiltInMethod
                {
                    ReturnType = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, Constants.kArbitraryRank),
                    Parameters = new List <KeyValuePair <string, ProtoCore.Type> >
                    {
                        new KeyValuePair <string, ProtoCore.Type>("Array", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, Constants.kArbitraryRank)),
                    },
                    ID = BuiltInMethods.MethodID.kTranspose,
                    MethodAttributes = new MethodAttributes(true)
                },

                new BuiltInMethod
                {
                    ReturnType = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeArray, Constants.kArbitraryRank),
                    Parameters = new List <KeyValuePair <string, ProtoCore.Type> >
                    {
                        new KeyValuePair <string, ProtoCore.Type>("start", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, 0)),
                        new KeyValuePair <string, ProtoCore.Type>("end", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, 0)),
                        new KeyValuePair <string, ProtoCore.Type>("step", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, 0)),
                        new KeyValuePair <string, ProtoCore.Type>("op", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeInt, 0)),
                        new KeyValuePair <string, ProtoCore.Type>("nostep", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeBool, 0)),
                        new KeyValuePair <string, ProtoCore.Type>("hasAmountOp", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeBool, 0))
                    },
                    ID = BuiltInMethods.MethodID.kRangeExpression
                },

                new BuiltInMethod()
                {
                    ReturnType = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeDouble, Constants.kArbitraryRank),
                    Parameters = new List <KeyValuePair <string, ProtoCore.Type> >
                    {
                        new KeyValuePair <string, ProtoCore.Type>("filePath", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeString, 0)),
                    },
                    ID = BuiltInMethods.MethodID.kLoadCSV
                },

                new BuiltInMethod()
                {
                    ReturnType = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeDouble, Constants.kArbitraryRank),
                    Parameters = new List <KeyValuePair <string, ProtoCore.Type> >
                    {
                        new KeyValuePair <string, ProtoCore.Type>("filePath", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeString, 0)),
                        new KeyValuePair <string, ProtoCore.Type>("transpose", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeBool, 0)),
                    },
                    ID = BuiltInMethods.MethodID.kLoadCSVWithMode
                },

                new BuiltInMethod()
                {
                    ReturnType = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVoid, 0),
                    Parameters = new List <KeyValuePair <string, ProtoCore.Type> >
                    {
                        new KeyValuePair <string, ProtoCore.Type>("msg", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, 0)),
                    },
                    ID = BuiltInMethods.MethodID.kPrint,
                    MethodAttributes = new MethodAttributes(true),
                },

                new BuiltInMethod()
                {
                    ReturnType = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVoid, 0),
                    Parameters = new List <KeyValuePair <string, ProtoCore.Type> >
                    {
                        new KeyValuePair <string, ProtoCore.Type>("msg", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, Constants.kArbitraryRank)),
                    },
                    ID = BuiltInMethods.MethodID.kPrintIndexable,
                    MethodAttributes = new MethodAttributes(true),
                },

                new BuiltInMethod()
                {
                    ReturnType       = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeInt, 0),
                    Parameters       = new List <KeyValuePair <string, ProtoCore.Type> > {
                    },
                    ID               = BuiltInMethods.MethodID.kGetElapsedTime,
                    MethodAttributes = new MethodAttributes(true),
                },

                new BuiltInMethod
                {
                    ReturnType = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, Constants.kArbitraryRank),
                    Parameters = new List <KeyValuePair <string, ProtoCore.Type> >
                    {
                        new KeyValuePair <string, ProtoCore.Type>("lhsPtr", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, Constants.kArbitraryRank)),
                    },
                    ID = BuiltInMethods.MethodID.kDot
                },

                new BuiltInMethod
                {
                    ReturnType = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, Constants.kArbitraryRank),
                    Parameters = new List <KeyValuePair <string, ProtoCore.Type> >
                    {
                        new KeyValuePair <string, ProtoCore.Type>("condition", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeBool, 0)),
                        new KeyValuePair <string, ProtoCore.Type>("dyn1", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, Constants.kArbitraryRank)),
                        new KeyValuePair <string, ProtoCore.Type>("dyn2", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, Constants.kArbitraryRank))
                    },
                    ID = BuiltInMethods.MethodID.kInlineConditional
                },

                new BuiltInMethod
                {
                    ReturnType = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeBool, 0),
                    Parameters = new List <KeyValuePair <string, ProtoCore.Type> >
                    {
                        new KeyValuePair <string, ProtoCore.Type>("object", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, 0)),
                    },
                    ID = BuiltInMethods.MethodID.kGetType
                },

                new BuiltInMethod
                {
                    ReturnType = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeBool, 0),
                    Parameters = new List <KeyValuePair <string, ProtoCore.Type> >
                    {
                        new KeyValuePair <string, ProtoCore.Type>("object", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, Constants.kArbitraryRank)),
                    },
                    ID = BuiltInMethods.MethodID.kGetType
                },

                new BuiltInMethod
                {
                    ReturnType = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeString, 0),
                    Parameters = new List <KeyValuePair <string, ProtoCore.Type> >
                    {
                        new KeyValuePair <string, ProtoCore.Type>("object", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, Constants.kArbitraryRank)),
                    },
                    ID = BuiltInMethods.MethodID.kToString
                },

                new BuiltInMethod
                {
                    ReturnType       = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVoid, 0),
                    Parameters       = new List <KeyValuePair <string, Type> >(),
                    ID               = BuiltInMethods.MethodID.kBreak,
                    MethodAttributes = new MethodAttributes(true),
                },

                new BuiltInMethod
                {
                    ReturnType = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, Constants.kArbitraryRank),
                    Parameters = new List <KeyValuePair <string, ProtoCore.Type> >
                    {
                        new KeyValuePair <string, ProtoCore.Type>("appname", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeString, 0)),
                        new KeyValuePair <string, ProtoCore.Type>("connectionParameters", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, Constants.kArbitraryRank))
                    },
                    ID = BuiltInMethods.MethodID.kImportData,
                    MethodAttributes = new MethodAttributes(true),
                },

                new BuiltInMethod
                {
                    ReturnType = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, Constants.kArbitraryRank),
                    Parameters = new List <KeyValuePair <string, Type> >
                    {
                        new KeyValuePair <string, Type>("array", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, Constants.kArbitraryRank))
                    },
                    ID = MethodID.kGetKeys,
                    //MAGN_3382 MethodAttributes = new MethodAttributes(true),
                },

                new BuiltInMethod
                {
                    ReturnType = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, Constants.kArbitraryRank),
                    Parameters = new List <KeyValuePair <string, Type> >
                    {
                        new KeyValuePair <string, Type>("array", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, Constants.kArbitraryRank))
                    },
                    ID = MethodID.kGetValues,
                    //MAGN_3382 MethodAttributes = new MethodAttributes(true),
                },

                new BuiltInMethod
                {
                    ReturnType = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeBool, 0),
                    Parameters = new List <KeyValuePair <string, Type> >
                    {
                        new KeyValuePair <string, Type>("array", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, Constants.kArbitraryRank)),
                        new KeyValuePair <string, Type>("key", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, 0))
                    },
                    ID = MethodID.kRemoveKey,
                    //MethodAttributes = new MethodAttributes(true), MAGN-3382
                },

                new BuiltInMethod
                {
                    ReturnType = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeBool, 0),
                    Parameters = new List <KeyValuePair <string, Type> >
                    {
                        new KeyValuePair <string, Type>("array", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, Constants.kArbitraryRank)),
                        new KeyValuePair <string, Type>("key", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, 0))
                    },
                    ID = MethodID.kContainsKey,
                    //MAGN-3382 MethodAttributes = new MethodAttributes(true),
                },

                new BuiltInMethod
                {
                    ReturnType = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, Constants.kArbitraryRank),
                    Parameters = new List <KeyValuePair <string, Type> >
                    {
                        new KeyValuePair <string, Type>("functionPointer", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeFunctionPointer, 0)),
                        new KeyValuePair <string, Type>("params", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, Constants.kArbitraryRank)),
                        new KeyValuePair <string, Type>("unpackParams", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeBool, 0))
                    },
                    ID = MethodID.kEvaluate,
                    MethodAttributes = new MethodAttributes(true),
                },

                new BuiltInMethod
                {
                    ReturnType = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, Constants.kArbitraryRank),
                    Parameters = new List <KeyValuePair <string, Type> >
                    {
                        new KeyValuePair <string, Type>("array", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar)),
                        new KeyValuePair <string, Type>("key", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar))
                    },
                    ID = MethodID.kTryGetValueFromNestedDictionaries,
                    MethodAttributes = new MethodAttributes(true),
                }
            };
        }
Ejemplo n.º 17
0
 private static IEnumerable <TypedParameter> GetUnaryFuncArgs()
 {
     return(new List <TypedParameter> {
         new TypedParameter(null, "x", TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar, Constants.kArbitraryRank)),
     });
 }
Ejemplo n.º 18
0
 public IdentifierNode(string identName = null)
 {
     ArrayDimensions = null;
     datatype        = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kInvalidType, 0);
     Value           = Name = identName;
 }
Ejemplo n.º 19
0
 public IdentifierNode()
 {
     ArrayDimensions = null;
     datatype        = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kInvalidType, 0);
 }
Ejemplo n.º 20
0
 public FunctionDescriptor(string name, IEnumerable <TypedParameter> parameters, FunctionType type)
     : this(null, null, name, parameters, TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.kTypeVar), type)
 {
 }
Ejemplo n.º 21
0
        public override IEnumerable <AssociativeNode> BuildOutputAst(List <AssociativeNode> inputAstNodes)
        {
            Func <string, string[], object[], object> backingMethod = DSCore.Formula.Evaluate;

            // Format input names to be used as function parameters
            var inputs = InPorts.Select(x => x.PortName.Replace(' ', '_')).ToList();


            /*  def formula_partial(<params>) {
             *    return = DSCore.Formula.Evaluate(<FormulaString>, <InPortData Names>, <params>);
             *  }
             */

            var functionDef = new FunctionDefinitionNode
            {
                Name      = "__formula_" + AstIdentifierGuid,
                Signature =
                    new ArgumentSignatureNode
                {
                    Arguments = inputs.Select(AstFactory.BuildParamNode).ToList()
                },
                ReturnType   = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.Var),
                FunctionBody =
                    new CodeBlockNode
                {
                    Body =
                        new List <AssociativeNode>
                    {
                        AstFactory.BuildReturnStatement(
                            AstFactory.BuildFunctionCall(
                                backingMethod,
                                new List <AssociativeNode>
                        {
                            AstFactory.BuildStringNode(FormulaString),
                            AstFactory.BuildExprList(
                                InPorts.Select(
                                    x =>
                                    AstFactory.BuildStringNode(x.PortName) as
                                    AssociativeNode).ToList()),
                            AstFactory.BuildExprList(
                                inputs.Select(AstFactory.BuildIdentifier)
                                .Cast <AssociativeNode>()
                                .ToList())
                        }))
                    }
                }
            };

            if (IsPartiallyApplied)
            {
                return(new AssociativeNode[]
                {
                    functionDef,
                    AstFactory.BuildAssignment(
                        GetAstIdentifierForOutputIndex(0),
                        AstFactory.BuildFunctionObject(
                            functionDef.Name,
                            InPorts.Count,
                            Enumerable.Range(0, InPorts.Count).Where(index => InPorts[index].IsConnected),
                            inputAstNodes))
                });
            }
            else
            {
                UseLevelAndReplicationGuide(inputAstNodes);

                return(new AssociativeNode[]
                {
                    functionDef,
                    AstFactory.BuildAssignment(
                        GetAstIdentifierForOutputIndex(0),
                        AstFactory.BuildFunctionCall(
                            functionDef.Name,
                            inputAstNodes))
                });
            }
        }
Ejemplo n.º 22
0
        /// <summary>
        ///     Compiles a collection of Dynamo nodes into a function definition for a custom node.
        /// </summary>
        /// <param name="functionId"></param>
        /// <param name="returnKeys"></param>
        /// <param name="functionName"></param>
        /// <param name="funcBody"></param>
        /// <param name="outputNodes"></param>
        /// <param name="parameters"></param>
        /// <param name="verboseLogging"></param>
        internal void CompileCustomNodeDefinition(
            Guid functionId, IEnumerable <string> returnKeys, string functionName,
            IEnumerable <NodeModel> funcBody, IEnumerable <AssociativeNode> outputNodes,
            IEnumerable <TypedParameter> parameters, bool verboseLogging)
        {
            OnAstNodeBuilding(functionId);

            var functionBody = new CodeBlockNode();
            var asts         = CompileToAstNodes(funcBody, CompilationContext.None, verboseLogging);

            functionBody.Body.AddRange(asts.SelectMany(t => t.Item2));

            var outputs = outputNodes.ToList();

            if (outputs.Count > 1)
            {
                /* rtn_dict = Dictionary.ByKeysValues({key0, ..., keyn}, {out0, ..., outn});
                 * return = rtn_dict;
                 */

                // return dictionary, holds all outputs
                string rtnName = "__temp_rtn_" + functionId.ToString().Replace("-", String.Empty);

                //// indexers for each output
                var indexers = returnKeys != null
                    ? returnKeys.Select(AstFactory.BuildStringNode) as IEnumerable <AssociativeNode>
                    : Enumerable.Range(0, outputs.Count).Select(AstFactory.BuildIntNode);

                // Create AST for Dictionary initialization
                var kvps = outputs.Zip(indexers, (outputId, indexer) =>
                                       new KeyValuePair <AssociativeNode, AssociativeNode>(indexer, outputId));
                var dict = new DictionaryExpressionBuilder();
                foreach (var kvp in kvps)
                {
                    dict.AddKey(kvp.Key);
                    dict.AddValue(kvp.Value);
                }
                functionBody.Body.Add(AstFactory.BuildAssignment(AstFactory.BuildIdentifier(rtnName), dict.ToFunctionCall()));

                // finally, return the return array
                functionBody.Body.Add(AstFactory.BuildReturnStatement(AstFactory.BuildIdentifier(rtnName)));
            }
            else
            {
                // For single output, directly return that identifier or null.
                AssociativeNode returnValue = outputs.Count == 1 && outputs[0] != null ? outputs[0] : new NullNode();
                functionBody.Body.Add(AstFactory.BuildReturnStatement(returnValue));
            }

            Type allTypes = TypeSystem.BuildPrimitiveTypeObject(PrimitiveType.Var);

            //Create a new function definition
            var functionDef = new FunctionDefinitionNode
            {
                Name      = functionName.Replace("-", string.Empty),
                Signature =
                    new ArgumentSignatureNode
                {
                    Arguments =
                        parameters.Select(param => AstFactory.BuildParamNode(param.Name, param.Type)).ToList()
                },
                FunctionBody = functionBody,
                ReturnType   = allTypes
            };

            OnAstNodeBuilt(functionId, new[] { functionDef });
        }