Beispiel #1
0
        public GeneratorInfo(FunctionInfo functionInfo)
            : base(functionInfo.ProjectState._generatorType)
        {
            _functionInfo = functionInfo;
            var nextMeth = VariableDict["next"];
            var sendMeth = VariableDict["send"];

            _nextMethod = new GeneratorNextBoundBuiltinMethodInfo(this, (BuiltinMethodInfo)nextMeth.First());
            _sendMethod = new GeneratorSendBoundBuiltinMethodInfo(this, (BuiltinMethodInfo)sendMeth.First());

            _sends = new VariableDef();
        }
Beispiel #2
0
        public override bool Walk(FunctionDefinition node)
        {
            if (node.Body == null || node.Name == null) {
                return false;
            }

            var queue = _entry.ProjectState.Queue;
            var scopes = new InterpreterScope[_scopes.Count + 1];
            _scopes.CopyTo(scopes);

            _analysisStack.Push(_curUnit);
            var unit = _curUnit = new AnalysisUnit(node, scopes, _curUnit);
            var function = new FunctionInfo(unit, _entry);
            var funcScope = new FunctionScope(function);

            _entry.MyScope.GetOrMakeNodeVariable(node, x => function.SelfSet);
            _scopes.Push(funcScope);
            scopes[scopes.Length - 1] = funcScope;

            if (!node.IsLambda) {
                // lambdas don't have their names published
                var scope = _scopes[_scopes.Count - 2];
                scope.SetVariable(node, unit, node.Name, function.SelfSet);
            }

            var newParams = new VariableDef[node.Parameters.Count];
            int index = 0;
            foreach (var param in node.Parameters) {
                newParams[index++] = funcScope.DefineVariable(param, _curUnit);
            }
            function.SetParameters(newParams);

            PushPositionScope(node, funcScope);

            return true;
        }
Beispiel #3
0
 public FunctionScope(FunctionInfo functionInfo)
     : base(functionInfo)
 {
 }
Beispiel #4
0
 public MethodInfo(FunctionInfo function, Namespace instance)
     : base(function._analysisUnit)
 {
     _function = function;
     _instanceInfo = instance;
 }