private static void ParseBreak(Scope scope, LuaLexer code) { FetchToken(LuaToken.KwBreak, code); // Erzeuge die Expression scope.AddExpression(Expression.Goto(scope.LookupLabel(null, csBreakLabel))); // Optionales Semicolon FetchToken(LuaToken.Semicolon, code, true); }
private static void ParseLabel(Scope scope, LuaLexer code) { // ::identifier:: FetchToken(LuaToken.ColonColon, code); // Erzeuge das Label scope.AddExpression(Expression.Label(scope.LookupLabel(null, FetchToken(LuaToken.Identifier, code).Value))); FetchToken(LuaToken.ColonColon, code); }
private static void ParseReturn(Scope scope, LuaLexer code) { // eat return code.Next(); // Build the return expression for all parameters Expression exprReturnValue; if (IsExpressionStart(code)) // there is a return value { if (scope.ReturnType == typeof(LuaResult)) { exprReturnValue = GetLuaResultExpression(scope, code.Current, ParseExpressionList(scope, code).ToArray()); } else if (scope.ReturnType.IsArray) { Type typeArray = scope.ReturnType.GetElementType(); exprReturnValue = Expression.NewArrayInit( typeArray, from c in ParseExpressionList(scope, code) select ConvertExpression(scope.Runtime, code.Current, c, typeArray)); } else { List<Expression> exprList = new List<Expression>(ParseExpressionList(scope, code)); if (exprList.Count == 1) exprReturnValue = ConvertExpression(scope.Runtime, code.Current, exprList[0], scope.ReturnType); else { ParameterExpression tmpVar = Expression.Variable(scope.ReturnType); exprList[0] = Expression.Assign(tmpVar, ConvertExpression(scope.Runtime, code.Current, exprList[0], scope.ReturnType)); exprList.Add(tmpVar); exprReturnValue = Expression.Block(scope.ReturnType, new ParameterExpression[] { tmpVar }, exprList); } } } else // use the default-value { if (scope.ReturnType == typeof(LuaResult)) exprReturnValue = Expression.Property(null, Lua.ResultEmptyPropertyInfo); else if (scope.ReturnType.IsArray) exprReturnValue = Expression.NewArrayInit(scope.ReturnType.GetElementType()); else exprReturnValue = Expression.Default(scope.ReturnType); } if (code.Current.Typ == LuaToken.Semicolon) code.Next(); scope.AddExpression(Expression.Goto(scope.LookupLabel(scope.ReturnType, csReturnLabel), exprReturnValue)); }
private static void ParseGoto(Scope scope, LuaLexer code) { // goto Identifier FetchToken(LuaToken.KwGoto, code); var t = FetchToken(LuaToken.Identifier, code); scope.AddExpression(Expression.Goto(scope.LookupLabel(null, t.Value))); }