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); }
public BasicBlock(Function parentFunction) { this.parentFunction = parentFunction; this.blockIndex = parentFunction.AddBlock(this); this.name = null; this.instructions = new List<Instruction> (); this.rawInstructionSize = 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; }
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; }
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> (); }
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; }
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; }
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; }
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; } } } }
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; } }
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; }
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; }
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; }
public void CreateLoadFunctionAddr(Function function) { AppendInst1(OpCode.LoadFunctionAddr, function); }
public void CreateCall(Function function, uint numargs) { AppendInst2(OpCode.Call, function, (byte)numargs); }
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); }
public void SetConstructor(Function constructor) { this.constructor = constructor; }
public void SetFunction(Function function) { this.function = function; }
public void SelectFunction(Function function) { this.selectedFunction = function; }
public void CreateNewDelegate(IChelaType type, Function invoked) { AppendInst2(OpCode.NewDelegate, type, invoked); }
public void SetOverload(Function overload) { this.overload = overload; }
protected LexicalScope CreateLexicalScope(AstNode where, Function parentFunction) { LexicalScope ret = new LexicalScope(currentContainer, parentFunction); ret.Position = where.GetPosition(); return ret; }
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); }
public void CreateBindKernel(IChelaType delegateType, Function kernel) { AppendInst2(OpCode.BindKernel, delegateType, kernel); }
public void CreateNewStruct(IChelaType type, Function constructor, uint numargs) { AppendInst3(OpCode.NewStruct, type, constructor, (byte)numargs); }
public ObjectDeclarator() { currentFunction = null; currentModule = null; }
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()); }
/// <summary> /// Adds an ambiguous function candidate /// </summary> public void AddCandidate(Function candidate) { if(candidate != null) candidates.Add(candidate); }
public void Insert(Function function) { FunctionGroupName gname = new FunctionGroupName(function.GetFunctionType(), function.IsStatic()); gname.SetFunction(function); functions.Add(gname); }