示例#1
0
        public static void ReadBody(CodeModelBuilder model, IMethodSymbol symbol, IFunctionContext destination)
        {
            var syntax = symbol.DeclaringSyntaxReferences
                         .Select(syntaxRef => syntaxRef.GetSyntax())
                         .FirstOrDefault(node => node is BaseMethodDeclarationSyntax || node is ArrowExpressionClauseSyntax);

            if (syntax != null)
            {
                var reader = new OperationReader(model, destination, syntax);
                reader.ReadMethodBody();

                // destination.Body = new BlockStatement();
                //
                // if (syntax.ExpressionBody != null)
                // {
                //     destination.Body.Statements.Add(new ReturnStatement {
                //         Expression = ExpressionReader.ReadExpression(model, syntax.ExpressionBody.Expression)
                //     });
                // }
                // else if (syntax.Body != null)
                // {
                //     foreach (var statementSyntax in syntax.Body.Statements)
                //     {
                //         destination.Body.Statements.Add(StatementReader.ReadStatement(model, statementSyntax));
                //     }
                // }
            }
        }
示例#2
0
 public OperationReader(CodeModelBuilder codeModel, IFunctionContext destination, SyntaxNode syntax)
 {
     _codeModel     = codeModel;
     _destination   = destination;
     _syntax        = syntax;
     _semanticModel = _codeModel.GetSemanticModel(syntax);
 }
示例#3
0
        public void AddHandler(IdentifierName eventName, IFunctionContext handler)
        {
            if (!_eventMap.TryGetValue(eventName, out var list))
            {
                list = new List <IFunctionContext>();
                _eventMap.Add(eventName, list);
            }

            list.Add(handler);
        }
示例#4
0
 public FunctionHandler(IFunctionContext functionContext)
     : base(functionContext)
 {
 }
示例#5
0
 internal ScriptFunction(IFunctionContext block)
 {
     Context = block;
 }
示例#6
0
        private bool TryParseEventHandlerAttachStatement(AbstractStatement statement, out IdentifierName eventName, out IFunctionContext handler)
        {
            eventName = null;
            handler   = null;

            if (!(statement is ExpressionStatement expressionStatement) ||
                !(expressionStatement.Expression is AssignmentExpression assignment))
            {
                return(false);
            }

            if (!(assignment.Left is MemberExpression eventMemberExpression) ||
                !(eventMemberExpression.Member is EventMember eventMember) ||
                !(eventMemberExpression.Target is MemberExpression componentMemberExpression) ||
                !(componentMemberExpression.Target is ThisExpression) ||
                componentMemberExpression.Member != this.DeclaredProperty)
            {
                return(false);
            }

            if (!(assignment.Right is IFunctionContext function))
            {
                return(false);
            }

            eventName = eventMember.Name;
            handler   = function;
            return(true);
        }
 protected BaseFunction(IFunctionContext functionContext)
 {
     Context = functionContext;
 }
示例#8
0
 public DefaultMathContext()
 {
     _parentContext   = null;
     _variableContext = new DefaultVariableContext(this);
     _functionContext = new DefaultFunctionContext(this);
 }
示例#9
0
 public EvaluatorVisitor(IExpressionContext context, IParametersSymbolTable symbolTable, IFunctionContext functionContext)
 {
     m_context         = context;
     m_symbolTable     = symbolTable;
     m_functionContext = functionContext;
 }
示例#10
0
 public override void UpsertCompletionCallback(ref ulong key, ref SpanByte value, IFunctionContext <byte[]> ctx)
 {
     ctx.EndUpsert(key);
 }
示例#11
0
 public override void RMWCompletionCallback(ref ulong key, ref Empty input, IFunctionContext <byte[]> ctx, Status status)
 {
     ctx.EndRMW(status);
 }
示例#12
0
 /// <inheritdoc />
 public override void DeleteCompletionCallback(ref ulong key, IFunctionContext <byte[]> ctx)
 {
     ctx.EndDelete(key);
 }
示例#13
0
 /// <inheritdoc />
 public override void ReadCompletionCallback(ref ulong key, ref Empty input, ref byte[] output, IFunctionContext <byte[]> ctx, Status status)
 {
     if (status != Status.OK)
     {
         ctx.EndRead(status);
     }
     ctx.EndRead(ref output);
 }