Exemple #1
0
 internal void EnsureParameters(FunctionAnalysisUnit unit) {
     var astParams = Function.FunctionDefinition.Parameters;
     for (int i = 0; i < astParams.Count; ++i) {
         VariableDef param;
         if (!TryGetVariable(astParams[i].Name, out param)) {
             if (astParams[i].Kind == ParameterKind.List) {
                 param = _seqParameters = _seqParameters ?? new ListParameterVariableDef(unit, astParams[i]);
             } else if (astParams[i].Kind == ParameterKind.Dictionary) {
                 param = _dictParameters = _dictParameters ?? new DictParameterVariableDef(unit, astParams[i]);
             } else {
                 param = new LocatedVariableDef(unit.ProjectEntry, astParams[i]);
             }
             AddVariable(astParams[i].Name, param);
         }
     }
 }
Exemple #2
0
 public VariableDef AddLocatedVariable(string name, Node location, AnalysisUnit unit, ParameterKind paramKind = ParameterKind.Normal) {
     VariableDef value;
     if (!TryGetVariable(name, out value)) {
         VariableDef def;
         switch (paramKind) {
             case ParameterKind.List: def = new ListParameterVariableDef(unit, location); break;
             case ParameterKind.Dictionary: def = new DictParameterVariableDef(unit, location); break;
             default: def = new LocatedVariableDef(unit.DeclaringModule.ProjectEntry, location); break;
         }
         return AddVariable(name, def);
     } else if (!(value is LocatedVariableDef)) {
         VariableDef def;
         switch (paramKind) {
             case ParameterKind.List: def = new ListParameterVariableDef(unit, location, value); break;
             case ParameterKind.Dictionary: def = new DictParameterVariableDef(unit, location, value); break;
             default: def = new LocatedVariableDef(unit.DeclaringModule.ProjectEntry, location, value); break;
         }
         return AddVariable(name, def);
     } else {
         ((LocatedVariableDef)value).Node = location;
         ((LocatedVariableDef)value).DeclaringVersion = unit.ProjectEntry.AnalysisVersion;
     }
     return value;
 }