Exemplo n.º 1
0
 /// <summary>
 /// Creates an appropriate setter for GetIdentifierNode.
 /// From: a
 /// To:   a = ...
 /// </summary>
 private SetIdentifierNode SetterOf(GetIdentifierNode node)
 {
     return(new SetIdentifierNode
     {
         Identifier = node.Identifier,
         Local = node.Local
     });
 }
Exemplo n.º 2
0
        /// <summary>
        /// Resolves the method as a global function, imported property or a local variable with a delegate.
        /// </summary>
        private void ResolveGetIdentifier(Context ctx, GetIdentifierNode node)
        {
            // local
            var nameInfo = ctx.Scope.FindLocal(node.Identifier);

            if (nameInfo != null)
            {
                ResolveExpression(ctx, node);
                return;
            }

            // function
            try
            {
                _method = ctx.ResolveMethod(
                    ctx.MainType.TypeInfo,
                    node.Identifier,
                    ArgTypes,
                    resolver: (idx, types) => ctx.ResolveLambda(Arguments[idx] as LambdaNode, types)
                    );

                if (_method == null)
                {
                    throw new KeyNotFoundException();
                }

                if (ArgTypes.Length == 0 && node.Identifier.IsAnyOf(EntityNames.RunMethodName, EntityNames.EntryPointMethodName))
                {
                    Error(CompilerMessages.ReservedFunctionInvocation, node.Identifier);
                }

                return;
            }
            catch (AmbiguousMatchException)
            {
                Error(CompilerMessages.FunctionInvocationAmbiguous, node.Identifier);
            }
            catch (KeyNotFoundException)
            {
            }

            // global property with a delegate
            try
            {
                ctx.ResolveGlobalProperty(node.Identifier);
                ResolveExpression(ctx, node);
            }
            catch (KeyNotFoundException)
            {
                Error(CompilerMessages.FunctionNotFound, node.Identifier);
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Resolves the method as a global function, imported property or a local variable with a delegate.
        /// </summary>
        private void resolveGetIdentifier(Context ctx, GetIdentifierNode node)
        {
            var nameInfo = ctx.Scope.FindLocal(node.Identifier);
            if (nameInfo != null)
            {
                resolveExpression(ctx, node);
                return;
            }

            try
            {
                _Method = ctx.ResolveMethod(
                    ctx.MainType.TypeInfo,
                    node.Identifier,
                    _ArgTypes,
                    resolver: (idx, types) => ctx.ResolveLambda(Arguments[idx] as LambdaNode, types)
                );

                if (_Method == null)
                    throw new KeyNotFoundException();

                if(_ArgTypes.Length == 0 && node.Identifier.IsAnyOf(EntityNames.RunMethodName, EntityNames.EntryPointMethodName))
                    error(CompilerMessages.ReservedFunctionInvocation, node.Identifier);
            }
            catch (KeyNotFoundException)
            {
                error(CompilerMessages.FunctionNotFound, node.Identifier);
            }
            catch (AmbiguousMatchException)
            {
                error(CompilerMessages.FunctionInvocationAmbiguous, node.Identifier);
            }
        }