Esempio n. 1
0
        internal override ObjWastTranspilerContext GetContext(string statement, ObjWastTranspiler transpiler)
        {
            if (!parseBody)
            {
                if (statement == "param")
                {
                    return(new ObjWastParamContext(this));
                }
                else if (statement == "result")
                {
                    return(new ObjWastResultContext(this));
                }
                else if (statement == "local")
                {
                    return(new ObjWastLocalContext(this));
                }
                else
                {
                    parseBody = true;
                }
            }



            return(null);
        }
Esempio n. 2
0
        internal override void Parse(ObjWastTranspiler transpiler)
        {
            // ex. (func private $test (param i32) (result i32) (local i32) ... )

            if (identifier == null && !parseBody)
            {
                string name = transpiler.ParseName();
                access = OwMemberAccess.Private;

                if (!string.IsNullOrWhiteSpace(name))
                {
                    var tempAccess = transpiler.ParseAccess(name);

                    if (tempAccess == null)
                    {
                        throw new Exception();
                    }

                    access = tempAccess.Value;
                }

                identifier = transpiler.ParseIdentifier();
                return;
            }

            parseBody = true;
        }
Esempio n. 3
0
        static void Main(string[] args)
        {
            Console.WriteLine("Loading: src/test.wat");
            ObjWastTranspiler transpiler = new ObjWastTranspiler();

            transpiler.Parse(@"src\test.wat");

            Console.ReadKey(true);
        }
Esempio n. 4
0
        internal override ObjWastTranspilerContext GetContext(string statement, ObjWastTranspiler transpiler)
        {
            string instructionName = statement;

            if (transpiler.PeekSignificant() == '.')
            {
                instructionName += transpiler.Read();
                instructionName += transpiler.ParseName();
            }

            return(Create(() => new ObjWastInstructionContext(this, instructionName)));
        }
Esempio n. 5
0
 internal override void Parse(ObjWastTranspiler transpiler)
 {
     if (char.IsDigit(transpiler.PeekSignificant()))
     {
         long number = transpiler.ParseLong();
         arguments.Add(number);
     }
     else if (transpiler.PeekSignificant() == '$')
     {
         string identifier = transpiler.ParseIdentifier();
         arguments.Add(new ObjWastIdentifier(identifier));
     }
 }
Esempio n. 6
0
        internal override ObjWastTranspilerContext GetContext(string statement, ObjWastTranspiler transpiler)
        {
            if (statement == "struct")
            {
                return(Create(() => new ObjWastStructContext(this)));
            }
            else if (statement == "func")
            {
                return(Create(() => new ObjWastFuncContext(this)));
            }

            return(null);
        }
Esempio n. 7
0
        internal override void Parse(ObjWastTranspiler transpiler)
        {
            // ex. (func $test (param i32) (result i32) (local i32) ... )

            if (identifier == null && !parseBody)
            {
                identifier = transpiler.ParseIdentifier();
                return;
            }

            parseBody = true;
            body.Parse(transpiler);
        }
Esempio n. 8
0
        internal override ObjWastTranspilerContext GetContext(string statement, ObjWastTranspiler transpiler)
        {
            if (statement == "field")
            {
                return(new ObjWastFieldContext(this));
            }
            else if (statement == "func")
            {
                return(new ObjWastMethodContext(this));
            }

            return(null);
        }
Esempio n. 9
0
        internal override void Parse(ObjWastTranspiler transpiler)
        {
            string instructionName = transpiler.ParseName();

            if (transpiler.PeekSignificant() == '.')
            {
                instructionName += transpiler.Read();
                instructionName += transpiler.ParseName();
            }

            var context = Create(() => new ObjWastInstructionContext(this, instructionName));

            context.Parse(transpiler);
        }
Esempio n. 10
0
        internal override void Parse(ObjWastTranspiler transpiler)
        {
            string         identifier = null;
            OwMemberAccess access     = OwMemberAccess.Private;
            OwType         type;

            string name = transpiler.ParseName();

            if (string.IsNullOrWhiteSpace(name))
            {
                // ex. (field $test i32)

                identifier = transpiler.ParseIdentifier();

                if (identifier == null)
                {
                    throw new Exception();
                }

                type = transpiler.ParseType(@struct.Module);
            }
            else
            {
                // ex. (field i32)
                // ex. (field private i32)
                // ex. (field private $test i32)

                OwMemberAccess?tempAccess = transpiler.ParseAccess(name);

                if (tempAccess == null)
                {
                    // ex. (field i32)
                    type = transpiler.ParseType(@struct.Module, name);
                }
                else
                {
                    // ex. (field private i32)
                    // ex. (field private $test i32)

                    access     = tempAccess.Value;
                    identifier = transpiler.ParseIdentifier();
                    type       = transpiler.ParseType(@struct.Module);
                }
            }

            @struct.DefineField(access, identifier, type);
        }
Esempio n. 11
0
 internal override ObjWastTranspilerContext GetContext(string statement, ObjWastTranspiler transpiler)
 {
     return(null);
 }
Esempio n. 12
0
 internal override void Parse(ObjWastTranspiler transpiler)
 {
 }
Esempio n. 13
0
 internal abstract void Parse(ObjWastTranspiler transpiler);
Esempio n. 14
0
 internal abstract ObjWastTranspilerContext GetContext(string statement, ObjWastTranspiler transpiler);
Esempio n. 15
0
        internal override void Parse(ObjWastTranspiler transpiler)
        {
            string name = transpiler.ParseName();

            type = Module.DefineType(name);
        }