Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. TypeBuilder Problems in My Compiler.

TypeBuilder Problems in My Compiler.

Scheduled Pinned Locked Moved C#
questioncsharpdata-structureshelptutorial
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    Defiant00
    wrote on last edited by
    #1

    I am writing a compiler using C# and the System.Reflection.Emit classes. The problem I am having is that I go through and create my classes for my language using TypeBuilder but I can't use those classes until I call CreateType. This wouldn't be a problem except that I potentially have to define instances of the class within the class (and therefore before I call CreateType). An example of this would be a linked list node that contains an instance of itself as the next node. So the real question is if there is some way to get the System.Type of a TypeBuilder before calling CreateType. Or alternately, is there some way to add functions and variables to an already created type that I still have the TypeBuilder for but have called CreateType? I need this because many things need a System.Type and I need to allow users to use the classes they create while programming. Thanks

    L B 2 Replies Last reply
    0
    • D Defiant00

      I am writing a compiler using C# and the System.Reflection.Emit classes. The problem I am having is that I go through and create my classes for my language using TypeBuilder but I can't use those classes until I call CreateType. This wouldn't be a problem except that I potentially have to define instances of the class within the class (and therefore before I call CreateType). An example of this would be a linked list node that contains an instance of itself as the next node. So the real question is if there is some way to get the System.Type of a TypeBuilder before calling CreateType. Or alternately, is there some way to add functions and variables to an already created type that I still have the TypeBuilder for but have called CreateType? I need this because many things need a System.Type and I need to allow users to use the classes they create while programming. Thanks

      L Offline
      L Offline
      leppie
      wrote on last edited by
      #2

      I feel your pain. I abandoned IL , and went with codedom. :) , but I believe inheritance will solve your problem here. :)

      leppie::AllocCPArticle(Generic DFA State Machine for .NET);

      1 Reply Last reply
      0
      • D Defiant00

        I am writing a compiler using C# and the System.Reflection.Emit classes. The problem I am having is that I go through and create my classes for my language using TypeBuilder but I can't use those classes until I call CreateType. This wouldn't be a problem except that I potentially have to define instances of the class within the class (and therefore before I call CreateType). An example of this would be a linked list node that contains an instance of itself as the next node. So the real question is if there is some way to get the System.Type of a TypeBuilder before calling CreateType. Or alternately, is there some way to add functions and variables to an already created type that I still have the TypeBuilder for but have called CreateType? I need this because many things need a System.Type and I need to allow users to use the classes they create while programming. Thanks

        B Offline
        B Offline
        Burt Harris
        wrote on last edited by
        #3

        Hmm, TypeBuilder itself is derrived from Type, perhaps that's what you need. I also see the following remark in the documentation for TypeBuilder: To retrieve a Type object for an incomplete type, use ModuleBuilder.GetType with a string representing the type name, such as "MyType" or "MyType[]". Burt Harris

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups