예제 #1
0
 public ZonnonCompilation(System.Compiler.Module targetModule,
                          System.Compiler.CompilationUnitList compilationUnits,
                          System.CodeDom.Compiler.CompilerParameters compilerParameters,
                          System.Compiler.Scope globalScope)
     : base(targetModule, compilationUnits, compilerParameters, globalScope)
 {
     init();
     EXTERNALS.clear();
     wasMainModule = false;
 }
예제 #2
0
 public override MemberList GetTypesNamespacesAndPrefixes(Scope scope, bool constructorMustBeVisible, bool listAllUnderRootNamespace) {
   MemberList result = new MemberList();
   while (scope != null && !(scope is TypeScope || scope is NamespaceScope)) scope = scope.OuterScope;
   if (scope == null) return result;
   TypeNode currentType = scope is TypeScope ? ((TypeScope)scope).Type : null;
   if (!(scope is NamespaceScope) && (currentType == null || currentType.DeclaringModule == null)) return result;
   ErrorHandler errorHandler = new ErrorHandler(new ErrorNodeList(0));
   TrivialHashtable ambiguousTypes = new TrivialHashtable();
   TrivialHashtable referencedLabels = new TrivialHashtable();
   Looker looker = new Looker(null, errorHandler, null, ambiguousTypes, referencedLabels);
   looker.currentType = currentType;
   looker.currentModule = this.currentSymbolTable;
   looker.currentAssembly = looker.currentModule as AssemblyNode;
   result = looker.GetVisibleTypesNamespacesAndPrefixes(scope, constructorMustBeVisible, listAllUnderRootNamespace);
   return result;
 }
예제 #3
0
파일: Looker.cs 프로젝트: hesam/SketchSharp
 public Looker(Scope scope, Cci.ErrorHandler errorHandler, TrivialHashtable scopeFor)
   : this(scope, errorHandler, scopeFor, null, null){
   this.alreadyReported[StandardIds.Var.UniqueIdKey] = true;
 }
예제 #4
0
파일: Error.cs 프로젝트: hesam/SketchSharp
 public static string GetMemberName(Member m, MemberNameOptions givenOptions, Scope scope) {
   if (m is KeywordCompletion)
     return m.Name.Name;
   StringBuilder sb = new StringBuilder();
   if (IsOptionActive(givenOptions, MemberNameOptions.Access)){
     sb.Append(MemberNameBuilder.GetMemberAccessString(m));
     sb.Append(' ');
   }
   if (IsOptionActive(givenOptions, MemberNameOptions.Modifiers)) {
     if (m.IsStatic)
       sb.Append("static ");
   }
   sb.Append(MemberNameBuilder.GetMemberNameRaw(m, givenOptions, scope));
   return sb.ToString();
 }
예제 #5
0
파일: Error.cs 프로젝트: hesam/SketchSharp
 internal static string GetMethodName(Method method, MemberNameOptions givenOptions, Scope scope, out bool isIndexer) {
   string methName = null;
   isIndexer = false;
   if ( method.Template != null)
     methName = MemberNameBuilder.GetAtPrefixedIfRequired(method.Template.GetUnmangledNameWithoutTypeParameters(true), givenOptions);
   else
     methName = MemberNameBuilder.GetAtPrefixedIfRequired(method.GetUnmangledNameWithoutTypeParameters(true), givenOptions);
   if (method is InstanceInitializer) {
     MemberNameOptions mask = MemberNameOptions.Keywords | MemberNameOptions.TemplateInfo | MemberNameOptions.TemplateArguments | MemberNameOptions.TemplateParameters | MemberNameOptions.Namespace | MemberNameOptions.EnclosingType;
     methName = MemberNameBuilder.GetMemberNameRaw(method.DeclaringType, givenOptions & ~mask, scope);
   } else if (method.IsSpecialName) {
     if (methName.StartsWith("get_") || methName.StartsWith("set_")) {
       if ((method.Parameters != null && method.Parameters.Count > 0)) {
         //  In this case enclosing type is not really an option. its part of name.
         methName = MemberNameBuilder.GetMemberNameRaw(method.DeclaringType, givenOptions, scope);
         if (methName == null)
           methName = "";
         isIndexer = true;
       }
       methName = methName.Substring(4);
     } else if (methName.StartsWith("add_") && method.Parameters != null && method.Parameters.Count == 1)
       methName = methName.Substring(4);
     else if (methName.StartsWith("remove_") && method.Parameters != null && method.Parameters.Count == 1)
       methName = methName.Substring(7);
     else {
       string opName = method.Name == null ? null : (string)Cci.Checker.OperatorName[method.Name.UniqueIdKey];
       if (opName != null) {
         //  In this case Enclosing type is not really an option. its part of name.
         string name = MemberNameBuilder.GetMemberNameRaw(method.DeclaringType, givenOptions, scope) + "." + opName;
         if (method.Name.UniqueIdKey == StandardIds.opExplicit.UniqueIdKey || method.Name.UniqueIdKey == StandardIds.opImplicit.UniqueIdKey)
           name = name + " " + MemberNameBuilder.GetMemberNameRaw(method.ReturnType, givenOptions, scope);
         return name;
       }
     }
   } else {
     if (method.HasCompilerGeneratedSignature) {
       if (method.Name.UniqueIdKey == StandardIds.Finalize.UniqueIdKey)
         methName = "~" + MemberNameBuilder.GetAtPrefixedIfRequired(method.DeclaringType.Name.Name, givenOptions);
     }
   }
   if (method.ImplementedTypes != null && method.ImplementedTypes.Count > 0 && method.ImplementedTypes[0] != null && IsOptionActive(givenOptions, MemberNameOptions.ImplementInterface))
     methName = MemberNameBuilder.GetMemberNameRaw(method.ImplementedTypes[0], givenOptions, scope) + "." + methName;
   if (IsOptionActive(givenOptions, MemberNameOptions.EnclosingType) && !isIndexer) {
     string decTypeName = null;
     if (!IsOptionActive(givenOptions, MemberNameOptions.SmartClassName) || !MemberNameBuilder.IsAggregateVisibleIn(method.DeclaringType, scope))
       decTypeName = MemberNameBuilder.GetMemberNameRaw(method.DeclaringType, givenOptions, scope); ;
     if (decTypeName != null)
       methName = decTypeName + "." + methName;
   }
   return methName;
 }
예제 #6
0
파일: Error.cs 프로젝트: hesam/SketchSharp
 public static string GetParameterTypeName(Parameter parameter, MemberNameOptions givenOptions, Scope scope) {
   if (parameter == null) return "";
   Reference r = parameter.Type as Reference;
   TypeNode typeNode = null;
   StringBuilder sb = new StringBuilder();
   string backUpName = null;
   if (r != null) {
     if ((parameter.Flags & ParameterFlags.Out) != 0) {
       if ( IsOptionActive(givenOptions, MemberNameOptions.PutParameterModifiers) ) sb.Append("out ");
       typeNode = r.ElementType;
     } else {
       if (IsOptionActive(givenOptions, MemberNameOptions.PutParameterModifiers)) sb.Append("ref ");
       typeNode = r.ElementType;
     }
   } else if (parameter.GetParamArrayElementType() != null) {
     if (IsOptionActive(givenOptions, MemberNameOptions.PutParameterModifiers)) sb.Append("params ");
     typeNode = parameter.Type;
   } else {
     typeNode = parameter.Type;
     if (typeNode == null && parameter.TypeExpression != null)
         backUpName = parameter.TypeExpression.SourceContext.SourceText;
   }
   sb.Append(backUpName != null ? MemberNameBuilder.GetAtPrefixedIfRequired(backUpName, givenOptions) : GetMemberNameRaw(typeNode, givenOptions, scope));
   if (IsOptionActive(givenOptions, MemberNameOptions.PutParameterName) && parameter.Name!= null) {
     sb.Append(' ');
     sb.Append(MemberNameBuilder.GetAtPrefixedIfRequired(parameter.Name.ToString(), givenOptions));
   }
   return sb.ToString();
 }
예제 #7
0
파일: Error.cs 프로젝트: hesam/SketchSharp
 internal static bool IsAggregateVisibleIn(TypeNode typeNode, Scope scope) {
   if (scope == null) return false;
   if (typeNode == null) return true;
   while (scope != null && !(scope is TypeScope)) {
     scope = scope.OuterScope;
   }
   for (TypeScope tScope = scope as TypeScope; tScope != null; tScope = tScope.OuterScope as TypeScope) {
     if (tScope.Type == null) continue;
     if (typeNode == tScope.Type || tScope.Type.IsDerivedFrom(typeNode)) {
       return true;
     }
   }
   return false;
 }
예제 #8
0
 internal Looker(Scope scope, ErrorHandler errorHandler, TrivialHashtable scopeFor, TypeSystem typeSystem, TrivialHashtable ambiguousTypes,  // LJW: added typeSystem parameter
     TrivialHashtable referencedLabels, Hashtable exceptionNames)
     : base(scope, errorHandler, scopeFor, typeSystem, ambiguousTypes, referencedLabels)
 {
     this.exceptionNames = exceptionNames;
 }
예제 #9
0
    public override Node CompileParseTree(Node node, Scope scope, Module targetModule, ErrorNodeList errorNodes){
      TrivialHashtable ambiguousTypes = new TrivialHashtable();
      TrivialHashtable referencedLabels = new TrivialHashtable();
      TrivialHashtable scopeFor = new TrivialHashtable();
      ErrorHandler errorHandler = new ErrorHandler(errorNodes);
      SpecSharpCompilation ssCompilation = new SpecSharpCompilation();

      // Setting the state
      TypeNode thisType = null;
      Method   currentMethod = null;
      BlockScope blockScope = scope as BlockScope;
      if (blockScope != null){
        Class baseScope = blockScope;
        MethodScope methodScope = null;
        while (baseScope != null){
          methodScope = baseScope.BaseClass as MethodScope;
          if (methodScope != null) break;
          baseScope = baseScope.BaseClass;
        }
        if (methodScope != null){
          thisType = methodScope.ThisType;
          if (thisType == null && methodScope.BaseClass is TypeScope){
            thisType = ((TypeScope) methodScope.BaseClass).Type;

          }
          currentMethod = methodScope.DeclaringMethod;
        }
      }

      //Attach scope to namespaces and types
      scopeFor[node.UniqueKey] = scope;
      Scoper scoper = new Scoper(scopeFor);
      scoper.currentScope = scope;
      node = scoper.Visit(node);

      //Walk IR looking up names
      Looker looker = new Looker(scope, errorHandler, scopeFor, ambiguousTypes, referencedLabels);
      // begin change by drunje (this is called from debugger only)
      looker.AllowPointersToManagedStructures = true;
      // end change by drunje
      if (blockScope != null)
      {
        looker.currentType = thisType;
        looker.currentMethod = currentMethod;
      }
      looker.currentAssembly = targetModule as AssemblyNode;
      looker.currentModule = targetModule;
      node = looker.Visit(node);
      
      //Walk IR inferring types and resolving overloads
      TypeSystem typeSystem = new TypeSystem(errorHandler);
      Resolver resolver = new Resolver(errorHandler, typeSystem);
      if (blockScope != null){
        resolver.currentType = thisType;
        resolver.currentMethod = currentMethod;
      }
      resolver.currentAssembly = targetModule as AssemblyNode;
      resolver.currentModule = targetModule;
      node = resolver.Visit(node);
      
      //TODO:  Need to set the state of the checker for compiling Expression, STOP using this method when the shift is complete
      //Walk IR checking for semantic errors and repairing it so that the next walk will work
      Checker checker = new Checker(ssCompilation, errorHandler, typeSystem, scopeFor, ambiguousTypes, referencedLabels);
      if (blockScope != null){
        checker.currentType = thisType;
        checker.currentMethod = currentMethod;
      }
      checker.currentAssembly = targetModule as AssemblyNode;
      checker.currentModule = targetModule;
      node = checker.Visit(node);

      //Walk IR reducing it to nodes that have predefined mappings to MD+IL
      Normalizer normalizer = new Normalizer(typeSystem);
      if (blockScope != null){
        normalizer.currentType = thisType;
        normalizer.currentMethod = currentMethod;
        normalizer.WrapToBlockExpression = false;
      }
      normalizer.currentModule = targetModule;
      node = normalizer.Visit(node);

      return node;
    }
예제 #10
0
 protected override MemberList GetMembers(int line, int col, QualifiedIdentifier qualId, Scope scope){
   this.suppressAttributeSuffix = scope is AttributeScope;
   return base.GetMembers(line, col, qualId, scope);
 }
예제 #11
0
 protected override MemberList GetMembers(int line, int col, Node node, Scope scope){
   KeywordCompletionList keywordList = node as KeywordCompletionList;
   if (keywordList != null)
     return new MemberList(keywordList.KeywordCompletions);
   else
     return base.GetMembers(line, col, node, scope);
 }
예제 #12
0
 protected override MemberList GetMembers(int line, int col, AttributeNode attrNode, Scope scope) {
   if (attrNode == null || scope == null) return null;
   this.suppressAttributeSuffix = true;
   return base.GetMembers(line, col, attrNode, scope);
 }
예제 #13
0
 public override void AddReleventKeywords(MemberList memberList, Node node, Scope scope, int identifierContext) {
   if (memberList == null) return;
   if (node is AttributeNode ){
     LanguageService.AddAttributeContextKeywords(memberList);
     return;
   }
   if (node is TypeAlias) {
     memberList.AddList(LanguageService.GetNamespaceStartKeywords());
     return;
   }
   Construct cons = node as Construct;
   if (cons != null){
     Member lastMember = memberList.Count > 0 ? memberList[memberList.Count - 1] : null;
     memberList.RemoveAt(memberList.Count - 1);
     if (!(cons.Constructor is QualifiedIdentifier)) {
       lastMember = LanguageService.AddTypeKeywords(memberList, lastMember as TypeNode);
     }
     if(lastMember!= null) memberList.Add(lastMember);
     return;
   }
   Identifier id = node as Identifier;
   if (id != null) {
     bool lastMemberPresent = memberList.Count > 0;
     Member lastMember = memberList.Count > 0 ? memberList[memberList.Count - 1] : null;
     memberList.RemoveAt(memberList.Count - 1);
     lastMember = LanguageService.AddTypeKeywords(memberList, lastMember as TypeNode);
     if (lastMemberPresent) memberList.Add(lastMember);
     return;
   }
   TypeExpression tExpr = node as TypeExpression;
   if (tExpr != null && !(tExpr.Expression is QualifiedIdentifier)) {
     LanguageService.AddTypeKeywords(memberList, null);
     return;
   }
   if (node is NameBinding) {
     if (identifierContext == IdentifierContexts.ParameterContext)
       LanguageService.AddParameterContextKeywords(memberList);
     else if (scope is NamespaceScope || scope is TypeScope) {
       if (identifierContext == IdentifierContexts.TypeContext)
         LanguageService.AddTypeKeywords(memberList, null);
       else if(identifierContext != IdentifierContexts.EventContext)
         this.AddTypeMemberKeywords(memberList);
     } else if (identifierContext == IdentifierContexts.TypeContext && !((scope is BlockScope) && (scope.OuterScope is TypeScope))) //  type but not member decl scope...
       LanguageService.AddTypeKeywords(memberList, null);
     else if (this.parsingStatement || scope is AttributeScope)
       this.AddStatementKeywords(memberList, scope);
     else if (identifierContext != IdentifierContexts.EventContext)
       this.AddTypeMemberKeywords(memberList);
     return;
   }
   if ((node == null || node is Namespace) && identifierContext == IdentifierContexts.AllContext){
     if(this.parsingStatement)
       this.AddStatementKeywords(memberList, scope);
     else
       this.AddTypeMemberKeywords(memberList);
   }
 }
예제 #14
0
 private void AddStatementKeywords(MemberList/*!*/ members, Scope scope) {
   foreach (KeywordCompletion keyword in LanguageService.statementKeywords)
     members.Add(keyword);
   if (this.allowSpecSharpExtensions){
     members.Add(new KeywordCompletion("additive"));
     members.Add(new KeywordCompletion("assert"));
     members.Add(new KeywordCompletion("assume"));
     members.Add(new KeywordCompletion("ensures"));
     members.Add(new KeywordCompletion("expose"));
     members.Add(new KeywordCompletion("invariant"));
     members.Add(new KeywordCompletion("requires"));
   }
   while (scope != null && !(scope is MethodScope)) {
     scope = scope.OuterScope;
   }
   MethodScope ms = scope as MethodScope;
   if (ms != null && ms.DeclaringMethod != null && !ms.DeclaringMethod.IsStatic) {
     members.Add(new KeywordCompletion("this"));
   }
 }
예제 #15
0
 public override MemberList GetNestedNamespacesAndTypes(Identifier name, Scope scope, AssemblyReferenceList assembliesToSearch){
   MemberList result = new MemberList();
   ErrorHandler errorHandler = new ErrorHandler(new ErrorNodeList(0));
   TrivialHashtable scopeFor = new TrivialHashtable();
   TrivialHashtable factoryMap = new TrivialHashtable();
   TrivialHashtable ambiguousTypes = new TrivialHashtable();
   TrivialHashtable referencedLabels = new TrivialHashtable();
   Looker looker = new Looker(null, errorHandler, null, ambiguousTypes, referencedLabels);
   looker.currentModule = this.currentSymbolTable;
   return looker.GetNestedNamespacesAndTypes(name, scope, assembliesToSearch);
 }
예제 #16
0
 public override Namespace VisitNamespace(Namespace nspace) {
   if (nspace == null) return null;
   Scope savedScope = this.scope;
   NamespaceScope ns = new NamespaceScope();
   ns.AssociatedNamespace = nspace;
   this.scope = ns;
   Namespace result = base.VisitNamespace(nspace);
   this.scope = savedScope;
   return result;
 }
예제 #17
0
 public Declarations(MemberList memberList, Cci.AuthoringHelper helper, Node node, Scope scope) 
   : base(memberList, helper, node, scope){
 }
예제 #18
0
 // LJW: added typeSystem parameter
 internal Looker(Scope scope, Microsoft.Zing.ErrorHandler errorHandler, TrivialHashtable scopeFor, TypeSystem typeSystem)
     : this(scope, errorHandler, scopeFor, typeSystem, null, null, null)
 {
 }
예제 #19
0
 public override string GetSignature(Member member, Scope scope) {
   MemberNameOptions options =
     MemberNameOptions.PutSignature
     | MemberNameOptions.PutReturnType
     | MemberNameOptions.PutParameterName
     | MemberNameOptions.PutParameterModifiers
     | MemberNameOptions.Keywords
     | MemberNameOptions.EnclosingType
     | MemberNameOptions.Namespace
     | MemberNameOptions.SmartNamespaceName
     | MemberNameOptions.TemplateArguments
     | MemberNameOptions.TemplateParameters
     | MemberNameOptions.AtPrefix
     | MemberNameOptions.PutMethodConstraints;
   return MemberNameBuilder.GetMemberName(member, options, scope);
 }
예제 #20
0
파일: Error.cs 프로젝트: hesam/SketchSharp
 internal static bool IsNamespaceImportedByScope(Identifier nspName, Scope scope) {
   if (scope == null) return false;
   if (nspName == null) return true;
   while (scope != null && !(scope is NamespaceScope)) {
     scope = scope.OuterScope;
   }
   for (NamespaceScope nsScope = scope as NamespaceScope; nsScope != null; nsScope = nsScope.OuterScope as NamespaceScope) {
     Namespace ns = nsScope.AssociatedNamespace;
     if (ns != null) {
       if (ns.Name == null) continue;
       if (ns.Name.UniqueIdKey == nspName.UniqueIdKey) return true;
       UsedNamespaceList nsList = ns.UsedNamespaces;
       if (nsList == null || nsList.Count == 0) continue;
       for (int i = 0; i < nsList.Count; ++i) {
         if (nsList[i] == null) continue;
         if (nsList[i].Namespace == null) continue;
         if (nsList[i].Namespace.UniqueIdKey == nspName.UniqueIdKey) {
           return true;
         }
       }
     }
   }
   return false;
 }
예제 #21
0
파일: Nodes.cs 프로젝트: modulexcite/SHFB-1
 public Scope(Scope outerScope)
 {
     this.OuterScope = outerScope;
 }
예제 #22
0
파일: Error.cs 프로젝트: hesam/SketchSharp
 internal static string GetDelegateConstructorSignature(Method method, MemberNameOptions givenOptions, Scope scope) {
   DelegateNode del = method.DeclaringType as DelegateNode;
   if (del == null) return "";
   StringBuilder sb = new StringBuilder();
   sb.Append(MemberNameBuilder.GetMemberNameRaw(del, givenOptions, scope));
   MemberNameOptions mask = MemberNameOptions.Keywords | MemberNameOptions.TemplateInfo | MemberNameOptions.TemplateArguments | MemberNameOptions.TemplateParameters | MemberNameOptions.Namespace | MemberNameOptions.EnclosingType;
   string methName = MemberNameBuilder.GetMemberNameRaw(method.DeclaringType, givenOptions & ~mask, scope);
   sb.Append('.');
   sb.Append(methName);
   sb.Append('(');
   sb.Append(MemberNameBuilder.GetMemberNameRaw(del.ReturnType, givenOptions, scope));
   sb.Append(MemberNameBuilder.GetSignatureString(del.Parameters, "(", ")", ", ", givenOptions&~MemberNameOptions.PutParameterName, scope, false));
   sb.Append(") target)");
   return sb.ToString();
 }
예제 #23
0
파일: Nodes.cs 프로젝트: modulexcite/SHFB-1
 public TypeScope(Scope parentScope, TypeNode/*!*/ type)
 {
     this.baseClass = parentScope;
     this.DeclaringModule = type.DeclaringModule;
     this.Type = type;
     if(type != null && type.PartiallyDefines != null)
         this.Type = type.PartiallyDefines;
     this.templateParameters = type.TemplateParameters;
     if(type != null)
         this.LexicalSourceExtent = type.SourceContext;
 }
예제 #24
0
파일: Error.cs 프로젝트: hesam/SketchSharp
 internal static string GetSignatureString(ParameterList parameters, string startPars, string endPars, string parSep, MemberNameOptions givenOpts, Scope scope, bool addNamedParameters) {
   StringBuilder sb = new StringBuilder(256);
   sb.Append(startPars);
   int n = parameters == null ? 0 : parameters.Count;
   for (int i = 0; i < n; i++) {
     Parameter p = parameters[i];
     sb.Append(GetParameterTypeName(p, givenOpts, scope));
     if (i < n - 1) sb.Append(parSep);
   }
   if (addNamedParameters) {
     string namedParamters = SpecSharpErrorNode.ResourceManager.GetString("NamedParameters", CultureInfo.CurrentCulture);
     if ( n > 0 ){
       sb.Append(parSep);
       sb.Append(namedParamters);
     }else{
       sb.Append(namedParamters);
     }
   }
   sb.Append(endPars);
   return sb.ToString();
 }
예제 #25
0
파일: Nodes.cs 프로젝트: modulexcite/SHFB-1
 public BlockScope(Scope/*!*/ parentScope, Block associatedBlock)
 {
     this.AssociatedBlock = associatedBlock;
     if(associatedBlock != null)
     {
         associatedBlock.HasLocals = true; //TODO: set only if there really are locals
         associatedBlock.Scope = this;
     }
     this.baseClass = parentScope;
     this.DeclaringModule = parentScope.DeclaringModule;
     if(associatedBlock != null)
         this.LexicalSourceExtent = associatedBlock.SourceContext;
 }
예제 #26
0
파일: Error.cs 프로젝트: hesam/SketchSharp
 internal static string GetMemberNameRaw(Member m, MemberNameOptions givenOptions, Scope scope) {
   TypeNode typeNode = m as TypeNode;
   if (typeNode != null) {
     if (typeNode.Name == Looker.NotFound) return "";
     if (IsOptionActive(givenOptions, MemberNameOptions.ExpandNullable) && typeNode.Template == SystemTypes.GenericNullable && typeNode.TemplateArguments != null
       && typeNode.TemplateArguments.Count > 0) {
       return MemberNameBuilder.GetMemberNameRaw(typeNode.TemplateArguments[0], givenOptions, scope) + "?";
     }
     if (IsOptionActive(givenOptions, MemberNameOptions.Keywords)) {
       switch (typeNode.TypeCode) {
         case TypeCode.Boolean: return "bool";
         case TypeCode.Byte: return "byte";
         case TypeCode.Char: return "char";
         case TypeCode.Decimal: return "decimal";
         case TypeCode.Double: return "double";
         case TypeCode.Int16: return "short";
         case TypeCode.Int32: return "int";
         case TypeCode.Int64: return "long";
         case TypeCode.SByte: return "sbyte";
         case TypeCode.Single: return "float";
         case TypeCode.String: return "string";
         case TypeCode.UInt16: return "ushort";
         case TypeCode.UInt32: return "uint";
         case TypeCode.UInt64: return "ulong";
       }
       if (typeNode == SystemTypes.Object) return "object";
       if (typeNode == SystemTypes.Void) return "void";
     }
     switch (typeNode.NodeType) {
       case NodeType.ArrayType: {
           ArrayType aType = (ArrayType)typeNode;
           StringBuilder sb = new StringBuilder(MemberNameBuilder.GetMemberNameRaw(aType.ElementType, givenOptions, scope));
           sb.Append('[');
           for (int i = 0, n = aType.Rank; i < n; i++) {
             if (i == 0 && n > 1) sb.Append('*');
             if (i < n - 1) {
               sb.Append(',');
               if (n > 1) sb.Append('*');
             }
           }
           sb.Append(']');
           return sb.ToString();
       }
       case NodeType.ConstrainedType:
       case NodeType.DelegateNode:
       case NodeType.EnumNode:
       case NodeType.Interface:
       case NodeType.TypeAlias:
       case NodeType.Class:{
         FunctionType fType = typeNode as FunctionType;
         if (fType != null) {
           return "delegate " + MemberNameBuilder.GetMemberNameRaw(fType.ReturnType, givenOptions, scope)
             + " " + MemberNameBuilder.GetSignatureString(fType.Parameters, "(", ")", ", ", givenOptions, scope, false);
         }
         ClosureClass cClass = typeNode as ClosureClass;
         if (cClass != null) {
           MemberList mems = cClass.Members;
           for (int i = 0, n = mems == null ? 0 : mems.Count; i < n; i++) {
             Method meth = mems[i] as Method;
             if (meth == null || meth is InstanceInitializer || (meth.Parameters != null && meth.Parameters.Count != 0)) continue;
             return MemberNameBuilder.GetMemberNameRaw(meth.ReturnType, givenOptions, scope);
           }
         }
         StringBuilder sb = new StringBuilder();
         if (IsOptionActive(givenOptions, MemberNameOptions.Namespace) && typeNode.Namespace != null) {
           string prefix = typeNode.Namespace.Name + ".";
           if (IsOptionActive(givenOptions, MemberNameOptions.SmartNamespaceName) && MemberNameBuilder.IsNamespaceImportedByScope(typeNode.Namespace, scope))
             prefix = "";
           sb.Append(MemberNameBuilder.GetAtPrefixedIfRequired(prefix, givenOptions));
         }
         if (IsOptionActive(givenOptions, MemberNameOptions.EnclosingType) && m.DeclaringType != null) {
           string prefix = "";
           if (!IsOptionActive(givenOptions, MemberNameOptions.SmartClassName) || !MemberNameBuilder.IsAggregateVisibleIn(m.DeclaringType, scope))
             prefix = MemberNameBuilder.GetMemberNameRaw(typeNode.DeclaringType, givenOptions, scope) + "."; ;
           sb.Append(MemberNameBuilder.GetAtPrefixedIfRequired(prefix, givenOptions));
         }
         string typeName = MemberNameBuilder.GetAtPrefixedIfRequired(typeNode.GetUnmangledNameWithoutTypeParameters(), givenOptions);
         if (IsOptionActive(givenOptions, MemberNameOptions.SupressAttributeSuffix) && typeName.EndsWith("Attribute")) {
           typeName = MemberNameBuilder.GetAtPrefixedIfRequired(typeName.Substring(0, typeName.Length - 9), givenOptions);
         }
         sb.Append(typeName);
         if (typeNode.TemplateParameters != null && typeNode.TemplateParameters.Count > 0) {
           if (IsOptionActive(givenOptions, MemberNameOptions.TemplateInfo))
             sb.Append("<>");
           else if(IsOptionActive(givenOptions, MemberNameOptions.TemplateParameters)){
             sb.Append('<');
             int n = typeNode.TemplateParameters.Count;
             for (int i = 0; i < n; i++) {
               sb.Append(MemberNameBuilder.GetMemberNameRaw(typeNode.TemplateParameters[i], givenOptions, scope));
               if (i < n - 1) sb.Append(',');
             }
             sb.Append('>');
           }
         } else if (typeNode.Template != null && typeNode.TemplateArguments != null && typeNode.TemplateArguments.Count > 0
           && IsOptionActive(givenOptions, MemberNameOptions.TemplateArguments)) {
           sb.Append('<');
           int n = typeNode.TemplateArguments.Count;
           for (int i = 0; i < n; i++) {
             sb.Append(MemberNameBuilder.GetMemberNameRaw(typeNode.TemplateArguments[i], givenOptions | MemberNameOptions.Keywords, scope));
             if (i < n - 1) sb.Append(',');
           }
           sb.Append('>');
         }
         return sb.ToString();
       }
       case NodeType.OptionalModifier:
         if (((OptionalModifier)typeNode).Modifier == SystemTypes.NonNullType)
           return MemberNameBuilder.GetMemberNameRaw(((OptionalModifier)typeNode).ModifiedType, givenOptions, scope) + "!";
         goto case NodeType.RequiredModifier;
       case NodeType.RequiredModifier:
         return MemberNameBuilder.GetMemberNameRaw(((TypeModifier)typeNode).ModifiedType, givenOptions, scope);
       case NodeType.Pointer:
         return MemberNameBuilder.GetMemberNameRaw(((Pointer)typeNode).ElementType, givenOptions, scope) + "*";
       case NodeType.Reference:
         return "ref " + MemberNameBuilder.GetMemberNameRaw(((Reference)typeNode).ElementType, givenOptions, scope);
       case NodeType.Refanytype:
       case NodeType.Struct:
         goto case NodeType.Class;
       case NodeType.ClassParameter:
       case NodeType.TypeParameter:
         return MemberNameBuilder.GetAtPrefixedIfRequired(typeNode.Name.ToString(), givenOptions);
       case NodeType.ClassExpression:
       case NodeType.InterfaceExpression:
       case NodeType.TypeExpression:
       case NodeType.ArrayTypeExpression:
       case NodeType.FlexArrayTypeExpression:
       case NodeType.FunctionTypeExpression:
       case NodeType.PointerTypeExpression:
       case NodeType.ReferenceTypeExpression:
       case NodeType.StreamTypeExpression:
       case NodeType.NonEmptyStreamTypeExpression:
       case NodeType.NonNullTypeExpression:
       case NodeType.NonNullableTypeExpression:
       case NodeType.BoxedTypeExpression:
       case NodeType.NullableTypeExpression:
       case NodeType.InvariantTypeExpression:
       case NodeType.TupleTypeExpression:
       case NodeType.TypeIntersectionExpression:
       case NodeType.TypeUnionExpression:
         return typeNode.SourceContext.SourceText;
     }
   }
   Method method = m as Method;
   if (method != null) {
     if (method is InstanceInitializer && method.DeclaringType is DelegateNode) return MemberNameBuilder.GetDelegateConstructorSignature(method, givenOptions, scope);
     StringBuilder sb = new StringBuilder();
     if (IsOptionActive(givenOptions, MemberNameOptions.PutReturnType) && !(method is InstanceInitializer)) {
       sb.Append(MemberNameBuilder.GetMemberNameRaw(method.ReturnType, givenOptions, scope));
       sb.Append(' ');
     }
     bool isIndexer;
     sb.Append(MemberNameBuilder.GetMethodName(method, givenOptions, scope, out isIndexer));
     if (method.TemplateParameters != null && method.TemplateParameters.Count > 0) {
       if (IsOptionActive(givenOptions, MemberNameOptions.TemplateInfo))
         sb.Append("<>");
       else if (IsOptionActive(givenOptions, MemberNameOptions.TemplateParameters)) {
         sb.Append('<');
         int n = method.TemplateParameters.Count;
         for (int i = 0; i < n; i++) {
           sb.Append(MemberNameBuilder.GetMemberNameRaw(method.TemplateParameters[i], givenOptions, scope));
           if (i < n - 1) sb.Append(',');
         }
         sb.Append('>');
       }
     } else if (method.Template != null && method.TemplateArguments != null && method.TemplateArguments.Count > 0
       && IsOptionActive(givenOptions, MemberNameOptions.TemplateArguments)) {
       sb.Append('<');
       int n = method.TemplateArguments.Count;
       for (int i = 0; i < n; i++) {
         sb.Append(MemberNameBuilder.GetMemberNameRaw(method.TemplateArguments[i], givenOptions | MemberNameOptions.Keywords, scope));
         if (i < n - 1) sb.Append(',');
       }
       sb.Append('>');
     }
     if (IsOptionActive(givenOptions, MemberNameOptions.PutSignature)) {
       InstanceInitializer ctor = method as InstanceInitializer;
       bool addNamedParameters = false;
       if (ctor != null) {
         MemberList ml = ctor.GetAttributeConstructorNamedParameters();
         addNamedParameters = ml != null && ml.Count > 0;
       }
       sb.Append(MemberNameBuilder.GetSignatureString(method.Parameters, isIndexer ? "[" : "(", isIndexer ? "]" : ")", ", ", givenOptions, scope, addNamedParameters));
     }
     if (IsOptionActive(givenOptions, MemberNameOptions.PutMethodConstraints) && method.TemplateParameters != null && method.TemplateParameters.Count > 0) {
       TypeNodeList templParameterList = method.TemplateParameters;
       int n = templParameterList.Count;
       for (int i = 0; i < n; i++) {
         TypeNode templParameter = templParameterList[i];
         ITypeParameter tpar = templParameter as ITypeParameter;
         if (!HasConstraints(templParameter, tpar) ) continue;
         sb.AppendFormat(" where {0} :", templParameter.Name.Name);
         bool isFirst = true;
         switch (tpar.TypeParameterFlags & TypeParameterFlags.SpecialConstraintMask) {
           case TypeParameterFlags.DefaultConstructorConstraint:
             sb.Append(" new()");
             isFirst = false;
             break;
           case TypeParameterFlags.ReferenceTypeConstraint:
             sb.Append(" class");
             isFirst = false;
             break;
           case TypeParameterFlags.ValueTypeConstraint:
             sb.Append(" struct");
             isFirst = false;
             break;
         }
         if (templParameter.BaseType != null && templParameter.BaseType != SystemTypes.Object) {
           if (isFirst)
             sb.Append(' ');
           else
             sb.Append(", ");
           sb.Append(MemberNameBuilder.GetMemberNameRaw(templParameterList[i].BaseType, givenOptions, scope));
           isFirst = false;
         }
         if (templParameter.Interfaces != null && templParameter.Interfaces.Count > 0) {
           InterfaceList interfaceList = templParameter.Interfaces;
           int n2 = interfaceList.Count;
           for (int j = 0; j < n2; ++j) {
             if (interfaceList[i] == null) continue;
             if (isFirst)
               sb.Append(' ');
             else
               sb.Append(", ");
             sb.Append(MemberNameBuilder.GetMemberNameRaw(interfaceList[i], givenOptions, scope));
             isFirst = false;
           }
         }
       }
     }
     return sb.ToString();
   }
   Property p = m as Property;
   if (p != null) {
     StringBuilder sb = new StringBuilder();
     if (IsOptionActive(givenOptions, MemberNameOptions.PutReturnType)) {
       sb.Append(MemberNameBuilder.GetMemberNameRaw(p.Type, givenOptions, scope));
       sb.Append(' ');
     }
     string name = null;
     bool isIndexer = false;
     if (p.DeclaringType.DefaultMembers.Contains(p)) {
       name = MemberNameBuilder.GetMemberNameRaw(p.DeclaringType, givenOptions, scope);
       isIndexer = true;
     } else
       name = MemberNameBuilder.GetAtPrefixedIfRequired(p.Name.ToString(), givenOptions);
       if (IsOptionActive(givenOptions, MemberNameOptions.EnclosingType) && !isIndexer) {
         string decTypeName = null;
         if (!IsOptionActive(givenOptions, MemberNameOptions.SmartClassName) || !MemberNameBuilder.IsAggregateVisibleIn(p.DeclaringType, scope))
           decTypeName = MemberNameBuilder.GetMemberNameRaw(p.DeclaringType, givenOptions, scope); ;
         if (decTypeName != null) {
           sb.Append(decTypeName);
           sb.Append(".");
         }
     }
     sb.Append(name);
     if (IsOptionActive(givenOptions, MemberNameOptions.PutSignature))
       sb.Append(MemberNameBuilder.GetSignatureString(p.Parameters, isIndexer ? "[" : "(", isIndexer ? "]" : ")", ", ", givenOptions, scope, false));
     return sb.ToString();
   }
   if (m==null || m.Name == null) return " ";
   return MemberNameBuilder.GetAtPrefixedIfRequired(m.Name.ToString(), givenOptions);
 }
예제 #27
0
파일: Nodes.cs 프로젝트: modulexcite/SHFB-1
 public AttributeScope(Scope parentScope, AttributeNode associatedAttribute)
 {
     this.AssociatedAttribute = associatedAttribute;
     this.baseClass = parentScope;
     if(associatedAttribute != null)
         this.LexicalSourceExtent = associatedAttribute.SourceContext;
 }
예제 #28
0
파일: Nodes.cs 프로젝트: modulexcite/SHFB-1
 public NamespaceScope(Scope outerScope, Namespace associatedNamespace, Module associatedModule)
     : base(outerScope)
 {
     //^ base;
     this.AssociatedNamespace = associatedNamespace;
     this.AssociatedModule = associatedModule;
     this.DeclaringModule = associatedModule; //TODO: make this go away
     if(associatedNamespace != null)
         this.LexicalSourceExtent = associatedNamespace.SourceContext;
 }
예제 #29
0
파일: Nodes.cs 프로젝트: modulexcite/SHFB-1
 public Compilation(Module targetModule, CompilationUnitList compilationUnits, System.CodeDom.Compiler.CompilerParameters compilerParameters, Scope globalScope)
     : base(NodeType.Compilation)
 {
     this.CompilationUnits = compilationUnits;
     this.TargetModule = targetModule;
     this.CompilerParameters = compilerParameters;
     this.GlobalScope = globalScope;
 }
예제 #30
0
파일: Looker.cs 프로젝트: hesam/SketchSharp
 public Looker(Scope scope, Cci.ErrorHandler errorHandler, TrivialHashtable scopeFor, TrivialHashtable ambiguousTypes, TrivialHashtable referencedLabels)
   : base(scope, errorHandler, scopeFor, new TypeSystem(new ErrorHandler(errorHandler.Errors)), ambiguousTypes, referencedLabels){
   this.alreadyReported[StandardIds.Var.UniqueIdKey] = true;
 }
예제 #31
0
 public override MemberList GetVisibleNames(Scope scope){
   MemberList result = new MemberList();
   if (scope == null) return result;
   Scope sc = scope;
   if (sc is MethodScope) return this.GetTypesNamespacesAndPrefixes(scope, false, false); //inside a parameter list.
   while (sc is BlockScope) sc = sc.OuterScope;
   MethodScope mscope = sc as MethodScope;
   while (sc != null && !(sc is TypeScope || sc is NamespaceScope)) sc = sc.OuterScope;
   TypeNode currentType = sc is TypeScope ? ((TypeScope)sc).Type : null;
   ErrorHandler errorHandler = new ErrorHandler(new ErrorNodeList(0));
   TrivialHashtable ambiguousTypes = new TrivialHashtable();
   TrivialHashtable referencedLabels = new TrivialHashtable();
   Looker looker = new Looker(null, errorHandler, null, ambiguousTypes, referencedLabels);
   if (mscope != null) looker.currentMethod = mscope.DeclaringMethod;
   looker.currentType = currentType;
   looker.currentModule = this.currentSymbolTable;
   looker.currentAssembly = looker.currentModule as AssemblyNode;
   return looker.GetVisibleNames(scope);
 }