public override Value VisitTopLevelExpression([NotNull] TopLevelExpressionContext context) { var function = GetOrDeclareFunction(new Prototype($"anon_expr_{AnonNameIndex++}") , isAnonymous: true ); return(DefineFunction(function, context.expression( ))); }
public override IAstNode VisitTopLevelExpression([NotNull] TopLevelExpressionContext context) { BeginFunctionDefinition( ); var sig = new Prototype(context.GetSourceSpan( ), RuntimeState.GenerateAnonymousName( ), true); var body = ( IExpression )context.expression( ).Accept(this); var retVal = new FunctionDefinition(context.GetSourceSpan( ), sig, body, true); RuntimeState.FunctionDefinitions.AddOrReplaceItem(retVal); return(retVal); }
public override Value VisitTopLevelExpression([NotNull] TopLevelExpressionContext context) { var proto = new Prototype($"anon_expr_{AnonNameIndex++}"); var function = GetOrDeclareFunction(proto , isAnonymous: true ); var(_, jitHandle) = DefineFunction(function, context.expression()); var nativeFunc = JIT.GetDelegateForFunction <AnonExpressionFunc>(proto.Identifier.Name); var retVal = Context.CreateConstant(nativeFunc( )); JIT.RemoveModule(jitHandle); return(retVal); }
public override IAstNode VisitTopLevelExpression(TopLevelExpressionContext context) { BeginFunctionDefinition( ); var sig = new Prototype(context.GetSourceSpan( ), RuntimeState.GenerateAnonymousName( ), true); var body = ( IExpression )context.expression( ).Accept(this); var retVal = new FunctionDefinition(context.GetSourceSpan( ), sig, body, true); // only add valid definitions to the runtime state. var errors = retVal.CollectErrors( ); if (errors.Count == 0) { RuntimeState.FunctionDefinitions.AddOrReplaceItem(retVal); } return(retVal); }