Ejemplo n.º 1
0
        private void CheckSemanticLocal(MoveInfo treeInfo, ScriptInfo scriptInfo, CheckingInfo checkingInfo)
        {
            _funcInfo = scriptInfo.FindLocalFunc(_name);

            if (_funcInfo == null)
            {
                _funcInfo = scriptInfo.FindGlobalsFunc(_name);
            }

            if (_funcInfo == null) // find in includes
            {
                _funcInfo = scriptInfo.FindIncludesFunc(_name);

                if (_funcInfo == null)
                {
                    scriptInfo.SF.Errors.Add(
                        new SemanticError("Unknown function '" + _name + "'",
                                          treeInfo.GetErrorInfo(treeInfo.Current)));
                    return;
                }

                if (_funcInfo.Access != MemberAccess.Public) // private member in include
                {
                    scriptInfo.SF.Errors.Add(
                        new SemanticError("Cannot access function '" + _funcInfo.ToString() + "'",
                                          treeInfo.GetErrorInfo(treeInfo.Current)));
                }
            }
        }
Ejemplo n.º 2
0
        private void CheckSemanticLocal(MoveInfo treeInfo, ScriptInfo scriptInfo, CheckingInfo checkingInfo)
        {
            _funcInfo = scriptInfo.FindLocalFunc(_name);

            if (_funcInfo == null) // find in includes
            {
                _funcInfo = scriptInfo.FindIncludesFunc(_name);

                if (_funcInfo == null)
                {
                    scriptInfo.SF.Errors.Add(
                        new SemanticError("Unknown function '" + _name + "'",
                                          treeInfo.GetErrorInfo(treeInfo.Current)));
                    return;
                }

                if (_funcInfo.Access == MemberAccess.Private)
                {
                    scriptInfo.SF.Errors.Add(
                        new SemanticError("Cannot access member '" + _funcInfo.ToString() + "'",
                                          treeInfo.GetErrorInfo(treeInfo.Current)));
                }
            }

            scriptInfo.References.Add(new FuncRefInfo(scriptInfo.SF, _funcInfo, this.CharIndex, this.CharLength,
                                                      checkingInfo.SC.SourceCode.Substring(this.CharIndex, this.CharLength), false));
        }
Ejemplo n.º 3
0
        public override void CheckSemantic(MoveInfo treeInfo, ScriptInfo scriptInfo, CheckingInfo checkingInfo)
        {
            if (!String.IsNullOrEmpty(this._pathOrUsing))
            {
                CheckSemanticExtern(treeInfo, scriptInfo, checkingInfo);
            }
            else
            {
                CheckSemanticLocal(treeInfo, scriptInfo, checkingInfo);
            }

            if (_funcInfo != null)
            {
                if (Arguments.Count > _funcInfo.Parameters.Count)
                {
                    if (_funcInfo.SF.IsExtern) // codapi funcs -> only warning
                    {
                        scriptInfo.SF.Errors.Add(
                            new WarningError("Function '" + _funcInfo.ToString() + "' has more arguments than parameters in the definition",
                                             treeInfo.GetErrorInfo(treeInfo.Current)));
                    }
                    else
                    {
                        scriptInfo.SF.Errors.Add(
                            new SemanticError("Function '" + _funcInfo.ToString() + "' has more arguments than parameters in the definition",
                                              treeInfo.GetErrorInfo(treeInfo.Current)));
                    }
                }

                if ((_funcInfo.OptParamStartIndex != null && Arguments.Count < _funcInfo.OptParamStartIndex) ||
                    (_funcInfo.OptParamStartIndex == null && Arguments.Count < _funcInfo.Parameters.Count))
                {
                    scriptInfo.SF.Errors.Add(
                        new WarningError("Could not find enough arguments, function '" + _funcInfo.ToString() + "'",
                                         treeInfo.GetErrorInfo(treeInfo.Current)));
                }

                FuncRefInfo funcRefInfo = new FuncRefInfo(scriptInfo.SF, _funcInfo, this.CharIndex, this.CharLength,
                                                          checkingInfo.SC.SourceCode.Substring(this.CharIndex, this.CharLength), true);
                foreach (Expression arg in this.Arguments)
                {
                    funcRefInfo.AddArgument(arg.CharIndex, arg.CharLength);
                }

                scriptInfo.References.Add(funcRefInfo);
            }
        }