Example #1
0
 public LexicalScope(Scope parentScope, Function parentFunction)
     : base(parentScope.GetModule())
 {
     this.members = new Dictionary<string, ScopeMember> ();
     this.parentScope = parentScope;
     this.parentFunction = parentFunction;
     this.index = parentFunction.AddLexicalScope(this);
 }
Example #2
0
 public BasicBlock(Function parentFunction)
 {
     this.parentFunction = parentFunction;
     this.blockIndex = parentFunction.AddBlock(this);
     this.name = null;
     this.instructions = new List<Instruction> ();
     this.rawInstructionSize = 0;
 }
Example #3
0
 public Namespace(Namespace parent)
     : base(parent.GetModule())
 {
     this.parentScope = parent;
     this.members = new Dictionary<string, ScopeMember> ();
     this.globalInitialization = null;
     this.staticConstructor = null;
     this.name = string.Empty;
 }
Example #4
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;
 }
Example #5
0
 public FunctionDefinition(FunctionPrototype prototype, AstNode children, TokenPosition position)
     : base(children, position)
 {
     this.prototype = prototype;
     this.function = null;
     this.isGenerator = false;
     this.hasReturns = false;
     this.yields = new List<ReturnStatement> ();
 }
Example #6
0
 public CallExpression(Expression function, Expression arguments, TokenPosition position)
     : base(position)
 {
     this.function = function;
     this.arguments = arguments;
     this.hasImplicitArgument = false;
     this.vectorConstruction = false;
     this.vslot = -1;
     this.selectedFunction = null;
 }
Example #7
0
 public BinaryAssignOperation(int operation, Expression variable, Expression value, TokenPosition position)
     : base(position)
 {
     this.operation = operation;
     this.variable = variable;
     this.value = value;
     this.pointerArithmetic = false;
     this.secondCoercion = null;
     this.overload = null;
 }
 public EventAccessorDefinition(MemberFlags flags, string name, AstNode children, TokenPosition position)
     : base(children, position)
 {
     SetName(name);
     this.flags = flags;
     this.eventVariable = null;
     this.function = null;
     this.selfLocal = null;
     this.valueLocal = null;
 }
Example #9
0
        public BinaryOperation(int operation, Expression left, Expression right,
		                        TokenPosition position)
            : base(position)
        {
            this.operation = operation;
            this.left = left;
            this.right = right;
            this.pointerArithmetic = false;
            this.secondCoercion = null;
            this.operationType = null;
            this.overload = null;
            this.matrixMul = false;
        }
Example #10
0
        public void AddFunction(Function function)
        {
            // Store the function.
            functions.Add(function);

            // Register the local scopes.
            for(int i = 0; i < function.GetLexicalScopeCount(); ++i)
            {
                LexicalScope scope = function.GetLexicalScope(i);

                // Register the position filename.
                TokenPosition pos = scope.Position;
                if(pos == null)
                    pos = NullPosition;
                AddFileName(pos.GetFileName());
            }

            // Register the variables names and positions.
            foreach(LocalVariable local in function.GetLocals())
            {
                // Register the local name.
                AddString(local.GetName());

                // Register the position filename
                TokenPosition localPos = local.Position;
                if(localPos == null)
                    localPos = NullPosition;
                AddFileName(localPos.GetFileName());
            }

            // Register the filenames.
            string lastFilename = null;
            foreach(BasicBlock bb in function.GetBasicBlocks())
            {
                foreach(Instruction instruction in bb.GetInstructions())
                {
                    // Ignore instructions without position.
                    TokenPosition position = instruction.GetPosition();
                    if(position == null)
                        position = NullPosition;

                    // Set the filename.
                    string filename = position.GetFileName();
                    if(position != null && lastFilename != filename)
                    {
                        AddFileName(filename);
                        lastFilename = filename;
                    }
                }
            }
        }
Example #11
0
        public void AddMember(ScopeMember member)
        {
            if(member == null)
                return;
            this.members.Add(member.GetName(), member);

            // Store the static constructor.
            if(member.IsFunction())
            {
                Function function = (Function)member;
                if(function.IsStaticConstructor())
                    staticConstructor = function;
            }
        }
Example #12
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 #13
0
 public FunctionPrototype(MemberFlags flags, Expression returnType,
                           FunctionArgument arguments, string name,
                           GenericSignature genericSignature,
                           TokenPosition position)
     : base(null, position)
 {
     SetName (name);
     this.flags = flags;
     this.returnType = returnType;
     this.arguments = arguments;
     this.function = null;
     this.ctorInitializer = null;
     this.destructorName = null;
     this.genericSignature = genericSignature;
 }
Example #14
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;
        }
Example #15
0
 public void CreateLoadFunctionAddr(Function function)
 {
     AppendInst1(OpCode.LoadFunctionAddr, function);
 }
Example #16
0
 public void CreateCall(Function function, uint numargs)
 {
     AppendInst2(OpCode.Call, function, (byte)numargs);
 }
Example #17
0
        internal void SwapExceptionContexts(Function other)
        {
            // Make sure the other end also takes my exception context.
            ExceptionContext newContext = other.exceptionContext;
            if(exceptionContext != null)
            {
                other.exceptionContext = null;
                other.SwapExceptionContexts(this);
            }

            // Use the new exception context.
            exceptionContext = newContext;
            if(newContext != null)
                exceptionContext.UpdateParent(this);
        }
Example #18
0
 public void SetConstructor(Function constructor)
 {
     this.constructor = constructor;
 }
Example #19
0
 public void SetFunction(Function function)
 {
     this.function = function;
 }
Example #20
0
 public void SelectFunction(Function function)
 {
     this.selectedFunction = function;
 }
Example #21
0
 public void CreateNewDelegate(IChelaType type, Function invoked)
 {
     AppendInst2(OpCode.NewDelegate, type, invoked);
 }
Example #22
0
 public void SetOverload(Function overload)
 {
     this.overload = overload;
 }
Example #23
0
 protected LexicalScope CreateLexicalScope(AstNode where, Function parentFunction)
 {
     LexicalScope ret = new LexicalScope(currentContainer, parentFunction);
     ret.Position = where.GetPosition();
     return ret;
 }
Example #24
0
        internal void UpdateParent(Function newParent)
        {
            // Update the parent function.
            parentFunction = newParent;

            // Remove references to old blocks.
            blocks.Clear();
            handlers.Clear();

            // Update the parent in the children.
            foreach(ExceptionContext child in children)
                child.UpdateParent(newParent);
        }
Example #25
0
 public void CreateBindKernel(IChelaType delegateType, Function kernel)
 {
     AppendInst2(OpCode.BindKernel, delegateType, kernel);
 }
Example #26
0
 public void CreateNewStruct(IChelaType type, Function constructor, uint numargs)
 {
     AppendInst3(OpCode.NewStruct, type, constructor, (byte)numargs);
 }
Example #27
0
 public ObjectDeclarator()
 {
     currentFunction = null;
     currentModule = null;
 }
Example #28
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 number of indices.
            int numIndices = reader.ReadByte();
            if(numIndices > 0)
                indices = new IChelaType[numIndices];

            // Read the indices.
            for(int i = 0; i < numIndices; ++i)
                indices[i] = module.GetType(reader.ReadUInt());

            // Read the get accessor.
            getAccessor = (Function)module.GetMember(reader.ReadUInt());

            // Read the set accessor.
            setAccessor = (Function)module.GetMember(reader.ReadUInt());
        }
Example #29
0
 /// <summary>
 /// Adds an ambiguous function candidate
 /// </summary>
 public void AddCandidate(Function candidate)
 {
     if(candidate != null)
         candidates.Add(candidate);
 }
Example #30
0
 public void Insert(Function function)
 {
     FunctionGroupName gname = new FunctionGroupName(function.GetFunctionType(), function.IsStatic());
     gname.SetFunction(function);
     functions.Add(gname);
 }