public void VisitBorrowUnaryOp(BorrowUnaryOpNode node) { IAddressableNode addressableRhs = (IAddressableNode)node.RHS; AddressOfVisitor addressOfVisitor = new AddressOfVisitor(_functionStackLayout, _semanticModule, _structLayoutManager); addressableRhs.AcceptAddressableVisitor(addressOfVisitor); int startAddr = _builder.AddInstruction(OpCode.ADDRESSOF, addressOfVisitor.AbsoluteStackAddress); _builder.AddDebugSymbol(startAddr, node); }
public LValue?Resolve(IAddressableNode node) { _path.Clear(); node.AcceptAddressableVisitor(this); if (_path.Count == 0) { return(null); } return(new LValue(_path)); }
public void VisitAccess(AccessNode node) { if (!node.IsAddressable()) { return; } IAddressableNode addressableLhs = (IAddressableNode)node.Lhs; addressableLhs.AcceptAddressableVisitor(this); _path.Add(node.Rhs); }
private void ValidateUsage(IAddressableNode addressableNode) { LValue?lValue = _lValueResolver.Resolve(addressableNode); if (lValue == null) { return; } if (lValue.Covers(_targetLValue) && !_isTargetCurrentlyAssigned) { _errors.AddError("Cannot use before assignment", addressableNode); } }
public void VisitAccess(AccessNode node) { IAddressableNode addressableLhs = (IAddressableNode)node.Lhs; addressableLhs.AcceptAddressableVisitor(this); StructType structType = (StructType)_module.ExpressionResultTypes[node.Lhs]; StructLayout layout = _structLayoutManager.GetLayout(structType); if (!layout.MemberOffsets.TryGetValue(node.Rhs, out int offset)) { throw new InvalidOperationException(); } AbsoluteStackAddress += offset; }
public void VisitAccess(AccessNode node) { IAddressableNode addressableNode = (IAddressableNode)node.Lhs; addressableNode.AcceptAddressableVisitor(this); StructType structType = (StructType)_genContext.SemanticModule.ExpressionResultTypes[node.Lhs]; StructLayout layout = _genContext.StructLayoutManager.GetLayout(structType); if (!layout.MemberOffsets.TryGetValue(node.Rhs, out int index)) { throw new InvalidOperationException(); } AssignmentWritePointer = _builder.BuildStructGEP(AssignmentWritePointer, (uint)index); }
public AssignmentNode(IAddressableNode lhs, IExpressionNode rhs) { Lhs = lhs; Rhs = rhs; }