Пример #1
0
        private static IAnalysisSet NewArray(FunctionValue func, Node node, AnalysisUnit unit, IAnalysisSet @this, IAnalysisSet[] args) {
            IAnalysisSet value;
            if (!unit._env.GlobalEnvironment.TryGetNodeValue(NodeEnvironmentKind.ArrayCall, node, out value)) {
                var arrValue = new ArrayValue(
                    new[] { new TypedDef() },
                    unit.ProjectEntry,
                    node
                );
                value = arrValue.SelfSet;
                unit._env.GlobalEnvironment.AddNodeValue(NodeEnvironmentKind.ArrayCall, node, arrValue.SelfSet);
            }

            return value;
        }
Пример #2
0
        private static IAnalysisSet ObjectKeys(FunctionValue func, Node node, AnalysisUnit unit, IAnalysisSet @this, IAnalysisSet[] args) {
            ArrayValue arrValue;
            IAnalysisSet value;
            if (!unit._env.GlobalEnvironment.TryGetNodeValue(NodeEnvironmentKind.ObjectKeysArray, node, out value)) {
                arrValue = new ArrayValue(
                    new[] { new TypedDef() },
                    unit.ProjectEntry,
                    node
                );
                unit._env.GlobalEnvironment.AddNodeValue(NodeEnvironmentKind.ObjectKeysArray, node, arrValue.SelfSet);
            } else {
                arrValue = (ArrayValue)value.First().Value;
            }

            IAnalysisSet res = AnalysisSet.Empty;
            if (args.Length >= 1) {
                if (args[0].Count < unit.Analyzer.Limits.MaxObjectKeysTypes) {
                    arrValue.IndexTypes[0].AddTypes(
                        unit,
                        args[0].GetEnumerationValues(node, unit)
                    );
                }
            }
            return arrValue.SelfSet;
        }