Beispiel #1
0
        //for fun proto
        public FunInfo(FuncTerm parameters, AST <FuncTerm> returnType)
        {
            this.isFunProto      = true;
            this.returnType      = returnType;
            this.parameterNames  = new List <string>();
            this.localNameToInfo = new Dictionary <string, LocalVariableInfo>();
            this.localNames      = new List <string>();

            int paramIndex = 0;

            while (parameters != null)
            {
                var ft = (FuncTerm)PTranslation.GetArgByIndex(parameters, 0);
                using (var enumerator = ft.Args.GetEnumerator())
                {
                    enumerator.MoveNext();
                    var varName = ((Cnst)enumerator.Current).GetStringValue();
                    enumerator.MoveNext();
                    var varType = (FuncTerm)enumerator.Current;
                    localNameToInfo[varName] = new LocalVariableInfo(varType, paramIndex);
                    parameterNames.Add(varName);
                }
                parameters = PTranslation.GetArgByIndex(parameters, 1) as FuncTerm;
                paramIndex++;
            }
        }
Beispiel #2
0
        // if isAnonymous is true, parameters is actually envVars
        public FunInfo(bool isAnonymous, FuncTerm parameters, AST <FuncTerm> returnType, FuncTerm locals, Node body)
        {
            this.isAnonymous = isAnonymous;
            this.returnType  = returnType;
            this.body        = body;

            this.parameterNames      = new List <string>();
            this.isRefParameter      = new List <bool>();
            this.localNameToInfo     = new Dictionary <string, LocalVariableInfo>();
            this.localNames          = new List <string>();
            this.numFairChoices      = 0;
            this.typeInfo            = new Dictionary <AST <Node>, FuncTerm>();
            this.maxNumLocals        = 0;
            this.invokeSchedulerFuns = new HashSet <Node>();
            this.invokePluginFuns    = new HashSet <Node>();
            this.printArgs           = new HashSet <string>();

            int paramIndex = 0;

            while (parameters != null)
            {
                var ft = (FuncTerm)PTranslation.GetArgByIndex(parameters, 0);
                using (var enumerator = ft.Args.GetEnumerator())
                {
                    enumerator.MoveNext();
                    var isRef = ((Id)enumerator.Current).Name == "REF";
                    enumerator.MoveNext();
                    var varName = ((Cnst)enumerator.Current).GetStringValue();
                    enumerator.MoveNext();
                    var varType = (FuncTerm)enumerator.Current;
                    localNameToInfo[varName] = new LocalVariableInfo(varType, paramIndex);
                    parameterNames.Add(varName);
                    isRefParameter.Add(isRef);
                }
                parameters = PTranslation.GetArgByIndex(parameters, 1) as FuncTerm;
                paramIndex++;
            }

            int localIndex = paramIndex;

            while (locals != null)
            {
                var ft = (FuncTerm)PToZing.GetArgByIndex(locals, 0);
                using (var enumerator = ft.Args.GetEnumerator())
                {
                    // skip over the qualifier
                    enumerator.MoveNext();
                    enumerator.MoveNext();
                    var varName = ((Cnst)enumerator.Current).GetStringValue();
                    enumerator.MoveNext();
                    var varType = (FuncTerm)enumerator.Current;
                    localNameToInfo[varName] = new LocalVariableInfo(varType, localIndex);
                    localNames.Add(varName);
                }
                locals = PToZing.GetArgByIndex(locals, 1) as FuncTerm;
                localIndex++;
            }
        }