protected internal override void CheckSemantics(AstHelper astHelper)
        {
            FunctionName.CheckSemantics(astHelper);

            // initialize the scopes for each one of the arguments
            var scopes = new AstHelper[Args.Count()];

            for (int i = 0; i < scopes.Length; scopes[i++] = astHelper.CreateChild(expecting: true))
            {
            }

            foreach (var item in Args.Zip(scopes, (arg, scope) => new { arg, scope }))
            {
                item.arg.CheckSemantics(item.scope);
            }

            Type[] argTypes = (from arg in Args select arg.Type).ToArray();

            if (astHelper.Errors.Check(new FunctionNotDefinedError(FunctionName.Name, argTypes, astHelper.Functions,
                                                                   Start)))
            {
                return;
            }

            _pointer = astHelper.Functions[FunctionName.Name, argTypes];

            // SPEC: The following are legal: function f(p:rec) = f(nil)
            // for that reason the expected type for each one of the arguments is the
            // type of the function argument (in the definition)
            foreach (var item in _pointer.ArgTypes.Zip(scopes, (type, scope) => new { type, scope }))
            {
                item.scope.Expecting.Type = item.type;
            }
        }
Example #2
0
    IEnumerator UpdateDuration()
    {
        while (true)
        {
            duration += Time.deltaTime;

            if (transitioning)
            {
                if (duration >= transitionDuration)
                {
                    duration     -= transitionDuration;
                    transitioning = false;
                }
            }
            else if (duration >= functionDuration)
            {
                duration          -= functionDuration;
                transitioning      = true;
                transitionFunction = function;
                if (transition)
                {
                    PickNextFunction();
                }
            }

            yield return(null);
        }
    }
Example #3
0
 public NetworkConfiguration(FunctionName activationFunction, int inputSize, int outputSize, params int[] hiddenLayerSizes)
 {
     ActivationFunction = activationFunction;
     InputSize          = inputSize;
     OutputSize         = outputSize;
     HiddenLayerSizes   = hiddenLayerSizes;
 }
        public long returnPinIDofUDFB(string _str)
        {
            //string str = "";
            string[] varname = _str.Split(new Char[] { '.' });
            int      count   = varname.Length;

            if (!IsFunction && !IsStandard)
            {
                foreach (tblPou tblpou in tblSolution.m_tblSolution().Dummytblcontroller.m_tblPouCollection)
                {
                    if (tblpou.pouName.ToUpper() == FunctionName.ToUpper())
                    {
                        foreach (tblVariable tblvariable in tblpou.m_tblVariableCollection)
                        {
                            if (varname[0].ToUpper() == tblvariable.VarName.ToUpper())
                            {
                                return(tblvariable.VarNameID);

                                break;
                            }
                        }
                        break;
                    }
                }
            }
            return(-1);
        }
 void LateUpdate()
 {
     if (LogUpdates)
     {
         CurrentFunction = FunctionName.LateUpdate;
     }
 }
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }
            //if (ReferenceEquals(this, obj))
            //{
            //    return false;
            //}
            if (this.GetType() != obj.GetType())
            {
                return(false);
            }
            if (this.GetHashCode() != obj.GetHashCode())
            {
                return(false);
            }

            RequestContent ctpReq = obj as RequestContent;

            if (ctpReq == null)
            {
                return(false);
            }
            if (Params == null || FunctionName == null)
            {
                return(false);
            }
            return(FunctionName.Equals(ctpReq.FunctionName) && Params.Count == 0);
        }
 void FixedUpdate()
 {
     if (LogUpdates)
     {
         CurrentFunction = FunctionName.FixedUpdate;
     }
 }
Example #8
0
        public static Operator Parse(string oper, int num)
        {
            int          indexOfBracket = oper.LastIndexOf('(');
            FunctionName functionName   = GetFunctionName(oper.Substring(0, indexOfBracket));

            if (functionName == FunctionName.NotSpecified)
            {
                throw new FormatException("Несуществующая функция");
            }
            string assigned;

            List <string> argsList = new List <string>();
            FunctionCall  operation;
            int           indexOfBracketClose = oper.LastIndexOf(')');

            if (indexOfBracketClose == -1)
            {
                throw new FormatException("Отсутствует закрывающаяся скобка");
            }
            if (oper.Contains(','))
            {
                int indexOfComma = oper.LastIndexOf(',');

                assigned = oper.Substring(indexOfBracket + 1, indexOfComma - indexOfBracket - 1);
                if (IsUnacceptableIdentifier(assigned))
                {
                    throw new FormatException("Ошибка в задании цели присваивания (неверный идентификатор)");
                }

                int indexOfQuotesR = oper.LastIndexOf('\"');
                if (indexOfQuotesR == -1)
                {
                    throw new FormatException("Ошибка в задании пути файла (отсутствует правые кавычки)");
                }
                int indexOfQuotesL = oper.LastIndexOf('\"', indexOfQuotesR - 1);
                if (indexOfQuotesL == -1)
                {
                    throw new FormatException("Ошибка в задании пути файла (отсутствует левые кавычки)");
                }

                string arg = oper.Substring(indexOfQuotesL + 1, indexOfQuotesR - indexOfQuotesL - 1);
                if (arg == null)
                {
                    throw new FormatException("Пустая строка пути файла");
                }
                argsList.Add(arg);
            }
            else
            {
                assigned = oper.Substring(indexOfBracket + 1, indexOfBracketClose - indexOfBracket - 1);
                if (IsUnacceptableIdentifier(assigned))
                {
                    throw new FormatException("Ошибка в задании цели присваивания (неверный идентификатор)");
                }
            }

            operation = new FunctionCall(assigned, argsList, functionName, num);
            argsList.Clear();
            return(operation);
        }
        protected override void AppendTo(SqlStringBuilder builder)
        {
            var orReplace = ReplaceIfExists ? "OR REPLACE" : "";

            builder.AppendFormat("CREATE {0}FUNCTION ", orReplace);
            FunctionName.AppendTo(builder);

            builder.Append("(");
            if (Parameters != null && Parameters.Length > 0)
            {
                for (int i = 0; i < Parameters.Length; i++)
                {
                    Parameters[i].AppendTo(builder);

                    if (i < Parameters.Length - 1)
                    {
                        builder.Append(", ");
                    }
                }
            }

            builder.Append(")");

            builder.Append(" RETURN ");
            ReturnType.AppendTo(builder);
            builder.AppendLine(" IS");

            builder.Indent();

            Body.AppendTo(builder);

            builder.DeIndent();
        }
Example #10
0
        public Aggregate(Expression target, FunctionName funcName, params string[] args)
            : base(target, funcName, args)
        {
            selectionPath = args != null && args.Length > 0 ? args[0] : null;
            var targetType = target.Type;
            var methodName = funcName.ToString();

            callInfo = supportedMethods.FirstOrDefault(m =>
                                                       m.TargetType == targetType && m.MethodName.Equals(methodName, StringComparison.OrdinalIgnoreCase));
            if (callInfo == null)
            {
                if (targetType.IsGenericType)
                {
                    var argType = targetType.GetGenericArguments()[0];
                    callInfo = new MethodInspect(methodName, targetType, argType, typeof(Enumerable));
                }
                else if (targetType.IsArray)
                {
                    var argType = targetType.GetElementType();
                    callInfo = new MethodInspect(methodName, targetType, argType, typeof(Enumerable));
                }
            }

            if (callInfo == null)
            {
                throw new NotSupportedException("Operator in condition is not supported for field type");
            }
        }
Example #11
0
        public static string GetName(FunctionName name)
        {
            switch (name)
            {
            case FunctionName.Sphere:
                return("SPHERE");

            case FunctionName.Torus:
                return("TORUS");

            case FunctionName.Pyramid:
                return("PYRAMID");

            case FunctionName.Octahedron:
                return("OCTAHEDRON");

            case FunctionName.Box:
                return("BOX");

            case FunctionName.Noise:
                return("NOISE");

            default:
                return("");
            }
        }
Example #12
0
        public Where(Expression target, FunctionName funcName, params string[] args) : base(target, funcName, args)
        {
            if (args == null || args.Length != 3)
            {
                throw new ArgumentException($"exactly 3 args required for function '{funcName}'");
            }

            fieldName  = args[0];
            op         = (Operator)Enum.Parse(typeof(Operator), args[1], true);
            fieldValue = args[2];
            fieldValue = fieldValue.Trim(new[] { '\'', '"' }).Trim();
            if (IsValueStaticFunction(fieldValue, out var valueFunc))
            {
                valueExpression = valueFunc;
            }

            if (Target.Type.IsGenericType)
            {
                argType = Target.Type.GetGenericArguments()[0];
            }
            else if (Target.Type.IsArray)
            {
                argType = Target.Type.GetElementType();
            }
            else
            {
                throw new InvalidOperationException($"target expression type '{Target.Type.Name}' is invalid, it should be either an array or enumerable");
            }
        }
        protected internal override void CheckSemantics(AstHelper astHelper)
        {
            FunctionName.CheckSemantics(astHelper);

            foreach (Expression expression in Parameters)
            {
                expression.CheckSemantics(astHelper);
            }
            Type[] parameterTypes = Parameters.Select(param => param.Type).ToArray();

            if (!astHelper.Errors.Check(new FunctionNotDefinedError(FunctionName.Name, parameterTypes,
                                                                    astHelper.Functions, Start)))
            {
                FunctionReference functionReference = astHelper.Functions[FunctionName.Name, parameterTypes];

                _type    = functionReference.ReturnType;
                _pointer = functionReference.Function;
            }
            else
            {
                // if there is any error
                _type    = typeof(Null);
                _pointer = MAst.Empty();
            }
        }
Example #14
0
        public override void WriteTo(IndentedTextWriter writer)
        {
            var initialIndent = writer.Indent;

            writer.Write("CREATE FUNCTION ");
            FunctionName.WriteTo(writer);

            // parameters
            writer.Write(" (");
            WriteParameters(writer);
            writer.WriteLine(')');

            writer.Indent++;
            try
            {
                // returns
                writer.Write("RETURNS ");
                Returns.WriteTo(writer);
                writer.WriteLine();

                // definition
                writer.Write("AS ");
                Definition.WriteTo(writer);
            }
            finally
            {
                writer.Indent--;
            }
            writer.WriteLine();
        }
Example #15
0
        public Ago(Expression target, FunctionName funcName, params string[] args) : base(target, funcName, args)
        {
            if (args == null || args.Length != 1)
            {
                throw new ArgumentException($"Exactly one argument is required for function '{funcName}'");
            }
            var funcArg = args[0];
            var match   = argRegex.Match(funcArg);

            if (!match.Success)
            {
                throw new InvalidOperationException($"invalid arg '{funcArg}' for function {funcName}");
            }

            var number = int.Parse(match.Groups[1].Value);

            switch (match.Groups[2].Value)
            {
            case "m":
                span = TimeSpan.FromMinutes(0 - number);
                break;

            case "h":
                span = TimeSpan.FromHours(0 - number);
                break;

            case "d":
                span = TimeSpan.FromDays(0 - number);
                break;

            default:
                throw new InvalidOperationException($"invalid arg '{funcArg}' for function {funcName}");
            }
        }
Example #16
0
        public OrderBy(Expression target, FunctionName funcName, params string[] args) : base(target, funcName, args)
        {
            if (args != null && args.Length > 1)
            {
                throw new ArgumentException($"exactly zero or one argument expected for function '{funcName}'");
            }

            if (args?.Length == 1)
            {
                orderByField = args[0];
            }

            if (funcName == FunctionName.OrderBy)
            {
                methodName = "OrderBy";
            }
            else if (funcName == FunctionName.OrderByDesc)
            {
                methodName = "OrderByDescending";
            }
            else
            {
                throw new NotSupportedException($"invalid {funcName} for order by");
            }
        }
Example #17
0
 protected override void VisitFunctionName(FunctionName tree)
 {
     _TrySetResult(tree);
     if (_result != null)
     {
         return;
     }
 }
 /// <inheritdoc />
 public override int GetHashCode()
 {
     unchecked {
         int hashCode = FunctionName.ToLowerInvariant().GetHashCode();
         hashCode = (hashCode * 397) ^ Iterations.GetHashCode();
         return(hashCode);
     }
 }
Example #19
0
 public FunctionCall(string assigned, List <string> argsList, FunctionName operationType, int lineNumber)
     : this()
 {
     Assigned        = assigned;
     ArgsList        = new List <string>(argsList);
     FunctionName    = operationType;
     base.LineNumber = lineNumber;
 }
Example #20
0
        public TransformFunction(StoreOptions options, string name, string body)
        {
            _options = options;
            Name     = name;
            Body     = body;

            Function = new FunctionName(_options.DatabaseSchemaName, $"{Prefix}{Name.ToLower().Replace(".", "_")}");
        }
Example #21
0
        private void GetTableData()
        {
            TableMapping = Mapper.GetTableMapping <T>();
            FunctionNameAttribute tableNameAtt = typeof(T).GetTypeInfo().GetCustomAttribute <FunctionNameAttribute>();

            FunctionName = tableNameAtt != null ? tableNameAtt.FunctionName : typeof(T).Name + "s";
            alias        = FunctionName.First().ToString().ToLower();
        }
Example #22
0
    public static FunctionData GetFunction(FunctionName name)
    {
        if ((int)name > functions.Count - 1)
        {
            name = FunctionName.Wave2D;
        }

        return(new FunctionData(functions[(int)name], name));
    }
Example #23
0
 public Call(
     Expression0 left,
     FunctionName function,
     IEnumerable <Expression> parameters = null)
 {
     Left       = left;
     Function   = function;
     Parameters = parameters.EmptyIfNull();
 }
Example #24
0
        private static bool FunctionHasPermisions(FunctionName functionName, AccountViewModel account)
        {
            if (!new FunctionPermissionManager().HasPermissionsByFacebookId(functionName, account.FacebookId))
            {
                return(false);
            }

            return(true);
        }
Example #25
0
 public StaticCall(
     ClassName @class,
     FunctionName function,
     IEnumerable <Expression> parameters)
 {
     Class      = @class;
     Function   = function;
     Parameters = parameters;
 }
    void Update()
    {
        if (LogUpdates)
        {
            Debug.Log(Time.frameCount + " Frame");

            CurrentFunction = FunctionName.Update;
        }
    }
Example #27
0
        public SprocCall Sproc(FunctionName function, ICallback callback = null)
        {
            if (function == null)
            {
                throw new ArgumentNullException(nameof(function));
            }

            return(Current().Sproc(function, callback));
        }
Example #28
0
        public NetworkDefinition(FunctionName activationFunction, int inputSize, int outputSize, params int[] hiddenLayerSizes)
        {
            InputSize = inputSize;

            foreach (var layerSize in hiddenLayerSizes.Concat(new [] { outputSize }))
            {
                Layers.Add(new NetworkLayerDefinition(activationFunction, layerSize));
            }
        }
Example #29
0
 public TweenData(MonoBehaviour mono, AnimationName animation, FunctionName function, float duration, GameObject gameObject, params object[] customData)
 {
     Mono      = mono;
     Animation = Animations[(int)animation](
         Functions[(int)function], duration, gameObject, customData);
     Duration   = duration;
     GameObject = gameObject;
     CustomData = customData;
 }
Example #30
0
        /// <summary>
        /// Returns a hash code for this instance.
        /// </summary>
        /// <returns>
        /// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.
        /// </returns>
        public override int GetHashCode()
        {
            var hash = 4909;

            hash = hash * 1877 + FunctionName.GetHashCode();
            hash = hash * 1877 + CountOfParameters.GetHashCode();

            return(hash);
        }
Example #31
0
	bool CheckArrayLength (FunctionName functionName, int segments, int index) {
		if (segments < 1) {
			Debug.LogError ("VectorLine." + functionNames[(int)functionName] + " needs at least 1 segment");
			return false;
		}

		if (m_isPoints) {
			if (index + segments > m_pointsCount) {
				if (index == 0) {
					Debug.LogError ("VectorLine." + functionNames[(int)functionName] + ": The number of segments cannot exceed the number of points in the array for \"" + name + "\"");
					return false;
				}
				Debug.LogError ("VectorLine: Calling " + functionNames[(int)functionName] + " with an index of " + index + " would exceed the length of the Vector array for \"" + name + "\"");
				return false;				
			}
			return true;
		}

		if (m_continuous) {
			if (index + (segments+1) > m_pointsCount) {
				if (index == 0) {
					Debug.LogError ("VectorLine." + functionNames[(int)functionName] + ": The length of the array for continuous lines needs to be at least the number of segments plus one for \"" + name + "\"");
					return false;
				}
				Debug.LogError ("VectorLine: Calling " + functionNames[(int)functionName] + " with an index of " + index + " would exceed the length of the Vector array for \"" + name + "\"");
				return false;
			}
		}
		else {
			if (index + segments*2 > m_pointsCount) {
				if (index == 0) {
					Debug.LogError ("VectorLine." + functionNames[(int)functionName] + ": The length of the array for discrete lines needs to be at least twice the number of segments for \"" + name + "\"");
					return false;
				}
				Debug.LogError ("VectorLine: Calling " + functionNames[(int)functionName] + " with an index of " + index + " would exceed the length of the Vector array for \"" + name + "\"");
				return false;
			}	
		}
		return true;
	}
Example #32
0
	bool WrongArrayLength (int arrayLength, FunctionName functionName) {
		if (m_continuous) {
			if (arrayLength != m_pointsCount-1) {
				Debug.LogError (functionNames[(int)functionName] + " array for \"" + name + "\" must be length of points array minus one for a continuous line (one entry per line segment)");
				return true;
			}
		}
		else if (arrayLength != m_pointsCount/2) {
			Debug.LogError (functionNames[(int)functionName] + " array in \"" + name + "\" must be exactly half the length of points array for a discrete line (one entry per line segment)");
			return true;
		}
		return false;
	}
 public PermissionGroupAttribute(FunctionName name)
 {
     group = name;
 }
Example #34
0
 static bool WrongArrayLength(VectorLine line, int arrayLength, FunctionName functionName)
 {
     int pointsLength = GetPointsLength (line);
     if (line.continuousLine) {
         if (arrayLength != pointsLength-1) {
             LogError(functionNames[(int)functionName] + " array for " + line.vectorObject.name + " must be length of points array minus one for a continuous line (one entry per line segment)");
             return true;
         }
     }
     else if (arrayLength != pointsLength/2) {
         LogError(functionNames[(int)functionName] + " array in " + line.vectorObject.name + " must be exactly half the length of points array for a discrete line (one entry per line segment)");
         return true;
     }
     return false;
 }
Example #35
0
    private static bool CheckArrayLength(VectorLine line, FunctionName functionName, int segments, int index)
    {
        if (segments < 1) {
            LogError("Vector: " + functionNames[(int)functionName] + " needs at least 1 segment");
            return false;
        }
        int linePoints = (line.points2 == null)? line.points3.Length : line.points2.Length;

        if (line.isPoints) {
            if (index + segments > linePoints) {
                if (index == 0) {
                    LogError("Vector: " + functionNames[(int)functionName] + ": The number of segments cannot exceed the number of points in the array for " + line.vectorObject.name);
                    return false;
                }
                LogError("Vector: Calling " + functionNames[(int)functionName] + " with an index of " + index + " would exceed the length of the Vector array for " + line.vectorObject.name);
                return false;
            }
            return true;
        }

        if (line.continuousLine) {
            if (index + (segments+1) > linePoints) {
                if (index == 0) {
                    LogError("Vector: " + functionNames[(int)functionName] + ": The length of the array for continuous lines needs to be at least the number of segments plus one for " + line.vectorObject.name);
                    return false;
                }
                LogError("Vector: Calling " + functionNames[(int)functionName] + " with an index of " + index + " would exceed the length of the Vector array for " + line.vectorObject.name);
                return false;
            }
        }
        else {
            if (index + segments*2 > linePoints) {
                if (index == 0) {
                    LogError("Vector: " + functionNames[(int)functionName] + ": The length of the array for discrete lines needs to be at least twice the number of segments for " + line.vectorObject.name);
                    return false;
                }
                LogError("Vector: Calling " + functionNames[(int)functionName] + " with an index of " + index + " would exceed the length of the Vector array for " + line.vectorObject.name);
                return false;
            }
        }
        return true;
    }
Example #36
0
 private bool HasPermission(FunctionName function, Permission permission)
 {
     return GetLevel(function.ToString()) >= (int)permission;
 }
Example #37
0
 public AuthorizeFunctionAttribute(FunctionName function, Permission permission)
 {
     this.function = function;
     this.permission = permission;
 }