public void ExitHandleExtern(Expr.Prototype data) { var value = this._visitor.Visit(data); if (value == null) { return; } this._visitor.FunctionProtos[data.Name] = data; }
/// toplevelexpr ::= expression private Expr.Function ParseTopLevelExpr() { //Console.WriteLine($"ParseTopLevelExpr: {this._scanner.CurrentToken}"); var e = this.ParseExpression(); if (e == null) { return(null); } // Make an anonymous proto. var proto = new Expr.Prototype("__anon_expr", new string[0], false, 0); return(new Expr.Function(proto, e)); }
private IrFunction GetOrDeclareFunction(Expr.Prototype prototype) { var function = this.Module.GetFunction(prototype.Name); if (function != null) { return(function); } var llvmSignature = this._ctx.GetFunctionType(this._ctx.DoubleType, prototype.Arguments.Select(_ => this._ctx.DoubleType)); var retVal = this.Module.AddFunction(prototype.Name, llvmSignature); retVal.Linkage = Linkage.External; int index = 0; foreach (var argId in prototype.Arguments) { retVal.Parameters[index].Name = argId; ++index; } return(retVal); }
public Value Visit(Expr.Prototype stmt) { return(this.GetOrDeclareFunction(stmt)); }
public void EnterHandleExtern(Expr.Prototype data) { }
public void ExitHandleExtern(Expr.Prototype data) { //Console.WriteLine($"ExitHandleExtern {data.Name}"); this._visitor.NextIsExtern = true; this._visitor.Visit(data); }