コード例 #1
0
        public Var(VarInfo varInfo)
        {
            Name                 = varInfo.Name;
            DefinedAt            = varInfo.DefinedAt;
            _parseInfo           = varInfo.ParseInfo;
            AccessLevel          = varInfo.AccessLevel;
            WholeContext         = varInfo.WholeContext;
            CodeType             = varInfo.Type;
            InExtendedCollection = varInfo.InExtendedCollection;
            Ref                    = varInfo.Ref;
            ID                     = varInfo.ID;
            Static                 = varInfo.Static;
            Recursive              = varInfo.Recursive;
            BridgeInvocable        = varInfo.BridgeInvocable;
            RequiresCapture        = varInfo.RequiresCapture;
            IsMacro                = varInfo.IsMacro;
            Virtual                = varInfo.Virtual;
            Override               = varInfo.Override;
            _tokenType             = varInfo.TokenType;
            _tokenModifiers        = varInfo.TokenModifiers.ToArray();
            _handleRestrictedCalls = varInfo.HandleRestrictedCalls;
            _inferType             = varInfo.InferType;
            _initialValueContext   = varInfo.InitialValueContext;
            _initialValueResolve   = varInfo.InitialValueResolve;
            _operationalScope      = varInfo.Scope;

            _variableTypeHandler = varInfo.VariableTypeHandler;
            if (!_inferType)
            {
                AddScriptData();
            }

            if (ID != -1)
            {
                if (VariableType == VariableType.Global)
                {
                    _parseInfo.TranslateInfo.VarCollection.Reserve(ID, true, _parseInfo.Script.Diagnostics, DefinedAt.range);
                }
                else if (VariableType == VariableType.Player)
                {
                    _parseInfo.TranslateInfo.VarCollection.Reserve(ID, false, _parseInfo.Script.Diagnostics, DefinedAt.range);
                }
            }

            // Get the initial value.
            if (_initialValueResolve == InitialValueResolve.Instant)
            {
                GetInitialValue();
            }
            else
            {
                _parseInfo.TranslateInfo.StagedInitiation.On(InitiationStage.Content, GetInitialValue);
            }

            if (DefinedAt != null)
            {
                _parseInfo.Script.AddCodeLensRange(new ReferenceCodeLensRange(this, _parseInfo, varInfo.CodeLensType, DefinedAt.range));
                _parseInfo.Script.Elements.AddDeclarationCall(this, new DeclarationCall(DefinedAt.range, true));
            }
        }
コード例 #2
0
 public VarInfo(string name, Location definedAt, ParseInfo parseInfo)
 {
     Name                = name;
     DefinedAt           = definedAt;
     ParseInfo           = parseInfo;
     VariableTypeHandler = new VariableTypeHandler(this);
 }