public override object VisitNativeStatement([NotNull] ClepsParser.NativeStatementContext context)
        {
            IMethodRegister methodRegister = CodeGenerator.GetMethodRegister(FullyQualifiedClassName, CurrMemberIsStatic, CurrMemberType, CurrMemberName);
            var             startIndex     = context.NativeOpen.StopIndex + 1;
            var             endIndex       = context.NativeClose.StartIndex - 1;
            var             length         = endIndex - startIndex + 1;
            var             nativeCode     = System.IO.File.ReadAllText(FileName).Substring(startIndex, length) + "\n";

            methodRegister.AddNativeCode(nativeCode);
            return(true);
        }
示例#2
0
        public override object VisitNativeStatement([NotNull] ClepsParser.NativeStatementContext context)
        {
            var  startIndex = context.NativeOpen.StopIndex + 1;
            var  endIndex   = context.NativeClose.StartIndex - 1;
            var  length     = endIndex - startIndex + 1;
            var  nativeCode = System.IO.File.ReadAllText(FileName).Substring(startIndex, length) + "\n";
            byte platformId;

            if (!byte.TryParse(context.PlatFormTarget.Text, out platformId))
            {
                string errorMessage = String.Format("Unable to parse '{0}' to a numeric platform id.", context.PlatFormTarget.Text);
                Status.AddError(new CompilerError(FileName, context.PlatFormTarget.Line, context.PlatFormTarget.Column, errorMessage));
                platformId = 0;
            }

            if (platformId == CodeGenerator.GetPlatform())
            {
                return(nativeCode);
            }
            else
            {
                return(null);
            }
        }
示例#3
0
 /// <summary>
 /// Exit a parse tree produced by <see cref="ClepsParser.nativeStatement"/>.
 /// <para>The default implementation does nothing.</para>
 /// </summary>
 /// <param name="context">The parse tree.</param>
 public virtual void ExitNativeStatement([NotNull] ClepsParser.NativeStatementContext context)
 {
 }
示例#4
0
 /// <summary>
 /// Visit a parse tree produced by <see cref="ClepsParser.nativeStatement"/>.
 /// <para>
 /// The default implementation returns the result of calling <see cref="AbstractParseTreeVisitor{Result}.VisitChildren(IRuleNode)"/>
 /// on <paramref name="context"/>.
 /// </para>
 /// </summary>
 /// <param name="context">The parse tree.</param>
 /// <return>The visitor result.</return>
 public virtual Result VisitNativeStatement([NotNull] ClepsParser.NativeStatementContext context)
 {
     return(VisitChildren(context));
 }