Example

class VariableExprAST : public ExprAST {
  std::string Name;
 
public:
  VariableExprAST(const std::string &Name) : Name(Name) {}
  Value *codegen() override;
};
 
Value *VariableExprAST::codegen() {
  // Look this variable up in the function.
  Value *V = NamedValues[Name];
  if (!V)
    LogErrorV("Unknown variable name");
  return V;
}