Example #1
0
 protected EventVariable(ChelaModule module)
     : base(module)
 {
     this.flags = MemberFlags.Default;
     this.parentScope = null;
     this.associatedField = null;
 }
Example #2
0
 internal Method(ChelaModule module)
     : base(module)
 {
     this.vslot = -1;
     this.ctorLeaf = false;
     this.ctorParent = null;
     this.explicitContract = null;
 }
Example #3
0
        public override ScopeMember InstanceMember(ScopeMember factory, GenericInstance instance)
        {
            // Instance the instance.
            ChelaModule     module      = factory.GetModule();
            GenericInstance newInstance = genericInstance.InstanceFrom(instance, module);

            // Instance the structure.
            return(template.InstanceMember(factory, newInstance));
        }
Example #4
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> ();
 }
Example #5
0
 public FieldVariable(ChelaModule module)
     : base(module)
 {
     this.flags = MemberFlags.Default;
     this.slot = -1;
     this.initializer = null;
     this.parentScope = null;
     this.position = null;
 }
Example #6
0
 public FieldVariable(ChelaModule module)
     : base(module)
 {
     this.flags       = MemberFlags.Default;
     this.slot        = -1;
     this.initializer = null;
     this.parentScope = null;
     this.position    = null;
 }
Example #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;
 }
Example #8
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);
        }
Example #9
0
        internal override void PrepareSerialization()
        {
            base.PrepareSerialization();

            // Register the template and the factory.
            ChelaModule module = GetModule();

            module.RegisterMember(template);
            module.RegisterMember(factory);
        }
Example #10
0
        public void Write(ModuleWriter writer, ChelaModule module)
        {
            // Write the type count.
            writer.Write((byte)parameters.Length);

            // Write the types.
            for (int i = 0; i < parameters.Length; ++i)
            {
                writer.Write((uint)module.RegisterType(parameters[i]));
            }
        }
Example #11
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;
 }
Example #12
0
        public GenericInstance InstanceFrom(GenericInstance instance, ChelaModule module)
        {
            IChelaType[] instancedTypes = new IChelaType[placeHolders.Length];
            for (int i = 0; i < placeHolders.Length; ++i)
            {
                instancedTypes[i] = placeHolders[i].InstanceGeneric(instance, module);
            }

            GenericInstance res = new GenericInstance(this, instancedTypes);

            return(res);
        }
Example #13
0
        public void Write(ModuleWriter writer, ChelaModule module)
        {
            // Write the placeholder count.
            writer.Write((byte)placeHolders.Length);

            // Write the placeholders.
            for (int i = 0; i < placeHolders.Length; ++i)
            {
                PlaceHolderType placeHolder = placeHolders[i];
                writer.Write((uint)module.RegisterType(placeHolder));
            }
        }
Example #14
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);
            }
        }
Example #15
0
        internal static void PreloadMember(ChelaModule module, ModuleReader reader, MemberHeader header)
        {
            // Create the temporal namespace and register it.
            Namespace space = new Namespace(module);

            module.RegisterMember(space);

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

            // Skip the namespace elements.
            reader.Skip(header.memberSize);
        }
Example #16
0
        internal static new void PreloadMember(ChelaModule module, ModuleReader reader, MemberHeader header)
        {
            // Create the temporal interface and register it.
            Interface iface = new Interface(module);
            module.RegisterMember(iface);

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

            // Skip the class elements.
            reader.Skip(header.memberSize);
        }
Example #17
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);
        }
Example #18
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);
        }
Example #19
0
        internal static void PreloadMember(ChelaModule module, ModuleReader reader, MemberHeader header)
        {
            // Create the temporal event and register it.
            EventVariable ev = new EventVariable(module);

            module.RegisterMember(ev);

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

            // Skip the structure elements.
            reader.Skip(header.memberSize);
        }
Example #20
0
        internal new static void PreloadMember(ChelaModule module, ModuleReader reader, MemberHeader header)
        {
            // Create the temporal interface and register it.
            Interface iface = new Interface(module);

            module.RegisterMember(iface);

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

            // Skip the class elements.
            reader.Skip(header.memberSize);
        }
Example #21
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);
        }
Example #22
0
        internal new static 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);
        }
Example #23
0
        internal static void PreloadMember(ChelaModule module, ModuleReader reader, MemberHeader header)
        {
            // Create the temporal field and register it.
            FieldVariable field = new FieldVariable(module);

            module.RegisterMember(field);

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

            // Skip the structure elements.
            reader.Skip(header.memberSize);
        }
Example #24
0
        internal override void Read(ModuleReader reader, MemberHeader header)
        {
            // Get the module.
            ChelaModule module = GetModule();

            // Read the type.
            type = module.GetType(reader.ReadUInt());

            // Read the add modifier.
            addModifier = (Function)module.GetMember(reader.ReadUInt());

            // Read the remove modifier.
            removeModifier = (Function)module.GetMember(reader.ReadUInt());
        }
Example #25
0
        internal override void PrepareSerialization()
        {
            //base.PrepareSerialization ();
            PrepareSerializationNoBase();

            // Register the template.
            ChelaModule module = GetModule();

            module.RegisterMember(template);
            module.RegisterMember(factory);

            // Register the types used.
            genericInstance.PrepareSerialization(module);
        }
Example #26
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;
        }
Example #27
0
 public PlaceHolderType(ChelaModule module, string name, bool valueType, List <Structure> bases)
     : base(module)
 {
     this.placeHolderId = module.CreatePlaceHolderId();
     this.name          = name;
     this.valueType     = valueType;
     if (bases == null)
     {
         this.bases = new Structure[0];
     }
     else
     {
         this.bases = bases.ToArray();
     }
 }
Example #28
0
        public override AstNode Visit(ModuleNode node)
        {
            // Store the old module.
            ChelaModule oldModule = this.currentModule;

            currentModule = node.GetModule();

            // Visit the children.
            PushScope(currentModule.GetGlobalNamespace());
            VisitList(node.GetChildren());
            PopScope();

            // Restore the module.
            currentModule = oldModule;
            return(node);
        }
Example #29
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;
 }
Example #30
0
        public override IChelaType InstanceGeneric(GenericInstance args, ChelaModule instModule)
        {
            // Instance the return type.
            IChelaType returnType = this.returnType.InstanceGeneric(args, instModule);

            // Instance all of the parameters.
            List <IChelaType> parameters = new List <IChelaType>();

            for (int i = 0; i < arguments.Length; ++i)
            {
                IChelaType arg = arguments[i];
                parameters.Add(arg.InstanceGeneric(args, instModule));
            }

            // Return a function type with the instanced types.
            return(Create(returnType, parameters, variableArguments));
        }
Example #31
0
        public override void Write(ModuleWriter writer)
        {
            // Write the header.
            MemberHeader header = new MemberHeader();

            header.memberType  = (byte)MemberHeaderType.Property;
            header.memberName  = GetModule().RegisterString(GetName());
            header.memberFlags = (uint)GetFlags();
            header.memberSize  = (uint)(13 + 4 * GetIndexCount());
            header.Write(writer);

            // Write the type.
            ChelaModule module = GetModule();

            writer.Write((uint)module.RegisterType(GetVariableType()));

            // Write the indices.
            byte numIndices = (byte)GetIndexCount();

            writer.Write(numIndices);
            for (int i = 0; i < numIndices; ++i)
            {
                writer.Write(module.RegisterType((IChelaType)indices[i]));
            }

            // Write the get accessor.
            if (getAccessor != null)
            {
                writer.Write((uint)getAccessor.GetSerialId());
            }
            else
            {
                writer.Write((uint)0);
            }

            // Write the set accessor.
            if (setAccessor != null)
            {
                writer.Write((uint)setAccessor.GetSerialId());
            }
            else
            {
                writer.Write((uint)0);
            }
        }
Example #32
0
        internal override void PrepareSerialization()
        {
            // Prepare myself.
            base.PrepareSerialization();

            // Register the property type.
            ChelaModule module = GetModule();

            module.RegisterType(GetVariableType());

            // Register the indices type.
            int numindices = GetIndexCount();

            for (int i = 0; i < numindices; ++i)
            {
                module.RegisterType((IChelaType)indices[i]);
            }
        }
Example #33
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());
            }
        }
Example #34
0
        public GenericInstance InstanceFrom(GenericInstance instance, ChelaModule instModule)
        {
            // Avoid instancing.
            if (instance == null)
            {
                return(this);
            }

            // Instance the arguments.
            IChelaType[] arguments = new IChelaType[parameters.Length];
            for (int i = 0; i < parameters.Length; ++i)
            {
                arguments[i] = parameters[i].InstanceGeneric(instance, instModule);
            }

            // Create the new instance.
            return(new GenericInstance(prototype, arguments));
        }
Example #35
0
 protected Interface(ChelaModule module)
     : base(module)
 {
 }
Example #36
0
 public FunctionInstance(Function template, GenericInstance genericInstance, ChelaModule instanceModule)
     : base(instanceModule)
 {
     Initialize(template, genericInstance);
 }
Example #37
0
 protected ChelaType(ChelaModule module)
     : base(module)
 {
 }
Example #38
0
 public virtual IChelaType InstanceGeneric(GenericInstance args, ChelaModule instModule)
 {
     return this;
 }
Example #39
0
 public void Write(ModuleWriter writer, ChelaModule module)
 {
     writer.Write(module.RegisterString(name));
 }
Example #40
0
 public Variable(IChelaType type, ChelaModule module)
     : base(module)
 {
     this.type = type;
     this.name = string.Empty;
 }
Example #41
0
 protected Variable(ChelaModule module)
     : base(module)
 {
     this.type = null;
     this.name = string.Empty;
 }
Example #42
0
        internal static void PreloadMember(ChelaModule module, ModuleReader reader, MemberHeader header)
        {
            // Create the temporal field and register it.
            FieldVariable field = new FieldVariable(module);
            module.RegisterMember(field);

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

            // Skip the structure elements.
            reader.Skip(header.memberSize);
        }
Example #43
0
        internal static void PreloadMember(ChelaModule module, ModuleReader reader, MemberHeader header)
        {
            // Create the temporal event and register it.
            EventVariable ev = new EventVariable(module);
            module.RegisterMember(ev);

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

            // Skip the structure elements.
            reader.Skip(header.memberSize);
        }