protected override ExprAST VisitVariableExprAST(VariableExprAST node) { // Look this variable up in the function. if (this.namedValues.TryGetValue(node.Name, out var value)) { this.valueStack.Push(value); } else { throw new Exception($"Unknown variable name {node.Name}"); } return(node); }
public ExprAST VariableExprVisit(VariableExprAST node) { LLVMValueRef initValue; this.Visit(node.Value); initValue = valueStack.Pop(); LLVMValueRef alloca = default(LLVMValueRef); switch (LLVM.GetTypeKind(LLVM.TypeOf(initValue))) { case LLVMTypeKind.LLVMIntegerTypeKind: alloca = CreateEntryBlockAlloca(mainFunction, LLVMTypeRef.Int64Type(), node.Name); break; case LLVMTypeKind.LLVMDoubleTypeKind: alloca = CreateEntryBlockAlloca(mainFunction, LLVMTypeRef.DoubleType(), node.Name); break; } LLVM.BuildStore(builder, initValue, alloca); return(node); }
protected internal virtual ExprAST VisitVariableExprAST(VariableExprAST node) { return node; }
protected internal virtual ExprAST VisitVariableExprAST(VariableExprAST node) { return(node); }
protected internal override void VisitAST(VariableExprAST node) { var (_, addr) = GetId(node.Name); GenCode.Add(Ins.Lod(node.RetType, 0, addr)); }