private static Expression ParseExpressionCast(Scope scope, LuaLexer code, InvokeResult result, ref bool lWrap) { // cast ::= cast(type, expr) if (code.Current.Typ == LuaToken.KwCast) { Token tStart = code.Current; lWrap |= true; PrefixMemberInfo prefix = new PrefixMemberInfo(tStart, ParsePrefixCast(scope, code), null, null, null); ParseSuffix(scope, code, prefix); return prefix.GenerateGet(scope, result); } else return ParsePrefix(scope, code).GenerateGet(scope, result); }
private static PrefixMemberInfo ParseSuffix(Scope scope, LuaLexer code, PrefixMemberInfo info) { // suffix_opt ::= [ suffix ] // suffix ::= { '[' exp ']' | '.' Identifier | args | ':' Identifier args } // args ::= tablector | string | '(' explist ')' while (true) { switch (code.Current.Typ) { case LuaToken.BracketSquareOpen: // Index code.Next(); info.GenerateGet(scope, InvokeResult.Object); if (code.Current.Typ == LuaToken.BracketSquareClose) info.Indices = new Expression[0]; else info.Indices = ParseExpressionList(scope, code).ToArray(); FetchToken(LuaToken.BracketSquareClose, code); break; case LuaToken.Dot: // Property of an class code.Next(); info.GenerateGet(scope, InvokeResult.Object); info.SetMember(FetchToken(LuaToken.Identifier, code), false); break; case LuaToken.BracketOpen: // List of arguments info.GenerateGet(scope, InvokeResult.Object); info.Arguments = ParseArgumentList(scope, code); break; case LuaToken.BracketCurlyOpen: // LuaTable as an argument info.GenerateGet(scope, InvokeResult.Object); info.Arguments = new ArgumentsList(ParseTableConstructor(scope, code)); break; case LuaToken.String: // String as an argument info.GenerateGet(scope, InvokeResult.Object); info.Arguments = new ArgumentsList(Expression.Constant(FetchToken(LuaToken.String, code).Value, typeof(object))); break; case LuaToken.Colon: // Methodenaufruf code.Next(); // Lese den Namen um den Member zu belegen info.GenerateGet(scope, InvokeResult.Object); info.SetMember(FetchToken(LuaToken.Identifier, code), true); // Parse die Parameter switch (code.Current.Typ) { case LuaToken.BracketOpen: // Argumentenliste info.Arguments = ParseArgumentList(scope, code); break; case LuaToken.BracketCurlyOpen: // LuaTable als Argument info.Arguments = new ArgumentsList(ParseTableConstructor(scope, code) ); break; case LuaToken.String: // String als Argument info.Arguments = new ArgumentsList(Expression.Constant(FetchToken(LuaToken.String, code).Value, typeof(string))); break; } break; default: return info; } } }