Ejemplo n.º 1
0
 public PropertyVariable(ChelaModule module)
     : base(module)
 {
     this.flags = MemberFlags.Default;
     this.indices = null;
     this.parentScope = null;
 }
Ejemplo n.º 2
0
 protected FunctionGroup(ChelaModule module)
     : base(module)
 {
     this.name = string.Empty;
     this.parentScope = null;
     this.functions = new SimpleSet<FunctionGroupName> ();
 }
Ejemplo n.º 3
0
 public StructureInstance(Structure template, GenericInstance instance,
     ScopeMember factory, ChelaModule module)
     : base(module)
 {
     this.factory = factory;
     Initialize(template, instance);
 }
Ejemplo n.º 4
0
 protected TypeGroup(ChelaModule module)
     : base(module)
 {
     this.name = string.Empty;
     this.fullName = null;
     this.parentScope = null;
     this.types = new SimpleSet<TypeGroupName> ();
 }
Ejemplo n.º 5
0
 internal Namespace(ChelaModule module)
     : base(module)
 {
     this.parentScope = null;
     this.members = new Dictionary<string, ScopeMember> ();
     this.name = string.Empty;
     this.globalInitialization = null;
     this.staticConstructor = null;
 }
Ejemplo n.º 6
0
 public DebugEmitter(ChelaModule module)
 {
     this.module = module;
     this.functions = new List<Function> ();
     this.structures = new List<Structure> ();
     this.fields = new List<FieldVariable> ();
     this.registeredStrings = new Dictionary<string, uint> ();
     this.stringTable = new List<string> ();
 }
Ejemplo n.º 7
0
 public TypeNameMember(ChelaModule module)
     : base(module)
 {
     this.name = string.Empty;
     this.parentScope = null;
     this.typedefNode = null;
     this.actualType = null;
     this.isExpanding = false;
     this.flags = MemberFlags.Default;
 }
Ejemplo n.º 8
0
 public AstNode(TokenPosition position)
 {
     this.position = position;
     this.prev = this;
     this.next = null;
     this.attributes = null;
     this.name = null;
     this.module = null;
     this.nodeType = null;
     this.coercionType = null;
     this.nodeValue = null;
 }
Ejemplo n.º 9
0
        public ChelaCompiler(ModuleType moduleType)
        {
            // Create the module node.
            moduleNode = new ModuleNode(null, null);
            moduleNode.SetName("global");

            // Create the module.
            ChelaModule module = new ChelaModule();
            moduleNode.SetModule(module);
            module.SetName("unnamed");
            module.SetModuleType(moduleType);
        }
Ejemplo n.º 10
0
        internal static new void PreloadMember(ChelaModule module, ModuleReader reader, MemberHeader header)
        {
            // Create the temporal structure and register it.
            Class clazz = new Class(module);
            module.RegisterMember(clazz);

            // Read the name.
            clazz.name = module.GetString(header.memberName);
            clazz.flags = (MemberFlags)header.memberFlags;

            // Skip the class elements.
            reader.Skip(header.memberSize);
        }
Ejemplo n.º 11
0
        public ExceptionContext(ExceptionContext parentContext)
        {
            // Store parent-child relation.
            this.parentContext = parentContext;
            this.parentFunction = parentContext.parentFunction;
            parentContext.children.Add(this);
            module = parentFunction.GetModule();

            // Initialize more variables.
            this.children = new List<ExceptionContext> ();
            this.blocks = new List<BasicBlock> ();
            this.handlers = new List<Handler> ();
            this.cleanup = null;
        }
Ejemplo n.º 12
0
 protected Function(ChelaModule module)
     : base(module)
 {
     this.name = string.Empty;
     this.flags = MemberFlags.Default;
     this.parentScope = null;
     this.basicBlocks = new List<BasicBlock> ();
     this.lexicalScopes = new List<LexicalScope>();
     this.locals = new List<LocalVariable> ();
     this.position = null;
     this.exceptionContext = null;
     this.returnBlock = null;
     this.returningVar = null;
     this.returnValueVar = null;
     this.genericPrototype = GenericPrototype.Empty;
     this.arguments  = null;
 }
Ejemplo n.º 13
0
        public ExceptionContext(Function parentFunction)
        {
            // Store parent-child relation.
            this.parentContext = null;
            this.parentFunction = parentFunction;
            module = parentFunction.GetModule();
            if(parentFunction.exceptionContext != null)
                throw new ModuleException("A function only can have one (toplevel) exception context.");

            parentFunction.exceptionContext = this;

            // Initialize more variables.
            this.children = new List<ExceptionContext> ();
            this.blocks = new List<BasicBlock> ();
            this.handlers = new List<Handler> ();
            this.cleanup = null;
        }
Ejemplo n.º 14
0
 public FunctionInstance InstanceGeneric(GenericInstance genericInstance, ChelaModule instanceModule)
 {
     return new FunctionInstance(this, genericInstance, instanceModule);
 }
Ejemplo n.º 15
0
        internal static void PreloadMember(ChelaModule module, ModuleReader reader, MemberHeader header)
        {
            // Create the temporal type name and register it.
            TypeNameMember typeName = new TypeNameMember(module);
            module.RegisterMember(typeName);

            // Read the name and flags.
            typeName.name = module.GetString(header.memberName);
            typeName.flags = (MemberFlags)header.memberFlags;

            // Skip the structure elements.
            reader.Skip(header.memberSize);
        }
Ejemplo n.º 16
0
 public ObjectDeclarator()
 {
     currentFunction = null;
     currentModule = null;
 }
Ejemplo n.º 17
0
        public override AstNode Visit(ModuleNode node)
        {
            currentModule = node.GetModule();
            currentScope = currentModule.GetGlobalNamespace();
            currentContainer = currentScope;
            VisitList(node.GetChildren());

            return node;
        }
Ejemplo n.º 18
0
 internal void PrepareSerialization(ChelaModule module)
 {
     // Prepare the instructions.
     foreach(Instruction inst in instructions)
         inst.PrepareSerialization(module);
 }
Ejemplo n.º 19
0
        public void Write(ChelaModule module, ModuleWriter writer)
        {
            // Write the number of instructions.
            writer.Write((ushort)rawInstructionSize);
            writer.Write((ushort)instructions.Count);
            writer.Write((byte)(isUnsafe ? 1 : 0));

            // Write the instructions.
            foreach(Instruction inst in instructions)
                inst.Write(module, writer);
        }
Ejemplo n.º 20
0
        internal static void PreloadMember(ChelaModule module, ModuleReader reader, MemberHeader header)
        {
            // Check if the function is a method.
            MemberFlags instanceFlags = (MemberFlags)header.memberFlags & MemberFlags.InstanceMask;
            bool method = instanceFlags != MemberFlags.Static &&
                          instanceFlags != MemberFlags.StaticConstructor;

            // Create the temporal function and register it.
            Function function = method ? new Method(module) : new Function(module);
            module.RegisterMember(function);

            // Read the name and flags.
            function.name = module.GetString(header.memberName);
            function.flags = (MemberFlags)header.memberFlags;

            // Skip the structure elements.
            reader.Skip(header.memberSize);
        }
Ejemplo n.º 21
0
        public override IChelaType InstanceGeneric(GenericInstance instance, ChelaModule instanceModule)
        {
            // Instance the instance.
            GenericInstance newInstance = genericInstance.InstanceFrom(instance, instanceModule);

            // Instance the structure.
            return template.InstanceGeneric(newInstance, instanceModule);
        }
Ejemplo n.º 22
0
 protected Class(ChelaModule module)
     : base(module)
 {
 }
Ejemplo n.º 23
0
        internal static void PreloadMember(ChelaModule module, ModuleReader reader, MemberHeader header)
        {
            // Create the temporal event and register it.
            TypeGroup tgroup = new TypeGroup (module);
            module.RegisterMember (tgroup);

            // Read the name.
            tgroup.name = module.GetString (header.memberName);

            // Skip the structure elements.
            reader.Skip (header.memberSize);
        }
Ejemplo n.º 24
0
        internal static void PreloadMember(ChelaModule module, ModuleReader reader, MemberHeader header)
        {
            // Create the temporal event and register it.
            PropertyVariable prop = new PropertyVariable(module);
            module.RegisterMember(prop);

            // Read the name and flags.
            prop.SetName(module.GetString(header.memberName));
            prop.flags = (MemberFlags)header.memberFlags;

            // Skip the structure elements.
            reader.Skip(header.memberSize);
        }
Ejemplo n.º 25
0
        public void PrepareSerialization(ChelaModule module)
        {
            // Register the attribute class.
            module.RegisterType(attributeClass);

            // Register the attribute ctor.
            if(attributeCtor != null)
                module.RegisterMember(attributeCtor);

            // Register the properties.
            foreach(PropertyValue prop in propertyValues)
            {
                module.RegisterMember(prop.Property);
                module.RegisterType(prop.Property.GetVariableType());
            }
        }
Ejemplo n.º 26
0
 private StructureInstance(ChelaModule module)
     : base(module)
 {
 }
Ejemplo n.º 27
0
        internal static new void PreloadMember(ChelaModule module, ModuleReader reader, MemberHeader header)
        {
            // Create the temporal structure instance.
            StructureInstance instance = new StructureInstance(module);
            module.RegisterMember(instance);

            // Skip the structure elements.
            reader.Skip(header.memberSize);
        }
Ejemplo n.º 28
0
        /// <summary>
        /// Writes the attribute constant into the module file.
        /// </summary>
        /// <param name="writer">
        /// A <see cref="ModuleWriter"/>
        /// </param>
        public void Write(ModuleWriter writer, ChelaModule module)
        {
            // Write the attribute class id.
            uint attributeClassId = module.RegisterMember(attributeClass);
            writer.Write(attributeClassId);

            // Write the attribute constructor id.
            uint attributeCtorId = module.RegisterMember(attributeCtor);
            writer.Write(attributeCtorId);

            // Write the arguments.
            byte numargs = (byte)ctorArguments.Count;
            writer.Write(numargs);
            for(int i = 0; i < numargs; ++i)
            {
                ConstantValue arg = ctorArguments[i];
                arg.WriteQualified(module, writer);
            }

            // Write the properties.
            byte numprops = (byte)propertyValues.Count;
            writer.Write(numprops);
            for(int i = 0; i < numprops; ++i)
            {
                PropertyValue propVal = propertyValues[i];
                uint propId = module.RegisterMember(propVal.Property);
                writer.Write(propId);
                propVal.Value.WriteQualified(module, writer);
            }
        }
Ejemplo n.º 29
0
 public void SetModule(ChelaModule module)
 {
     this.module = module;
 }
Ejemplo n.º 30
0
 public Scope(ChelaModule module)
     : base(module)
 {
 }