public string VisitLiteralExpression(Expression.Literal expression) { if (expression.value == null) { return("nil"); } return(expression.value.ToString()); }
public ByteCodeChunk VisitLiteral(Expression.Literal expression) { var chunk = new ByteCodeChunk(9); switch (expression.Value) { case long i: chunk.AddInstruction(Instruction.Push64, i); break; default: throw new Exception(); } return(chunk); }
public object visitLiteralExpression(Expression.Literal expr) { if (expr.Value is string) { // TODO handle the memory slot correctly wasm.addData(memoryPointer, expr.Value.ToString()); addInstruction(0x41); addInstruction(Util.LEB128encode(memoryPointer)); // addInstruction(0x41); // addInstruction(Util.LEB128encode(memoryPointer)); // addInstruction(0x2d, 0x00, 0x00); memoryPointer += expr.Value.ToString().Length + 1; return(null); } addInstruction(0x41); addInstruction(Util.LEB128encode((int)expr.Value)); return(null); }
protected override Value?Visit(Expression.Literal lit) => lit.Type switch {
public object VisitLiteralExpression(Expression.Literal expression) { return(null); }
public object visitLiteralExpression(Expression.Literal expr) { return(expr.Type); }
public object VisitLiteralExpr(Expression.Literal expr) { return(new Expression.Literal()); }
public object VisitLiteralExpression(Expression.Literal expression) { return(expression.value); }
protected override Node?Visit(Expression.Literal lit) => new Expression.Literal(lit.ParseTreeNode, lit.Type, lit.Value);
public object VisitLiteralExpr(Expression.Literal expr) { return(expr.LiteralValue()); }
private Statement ForStatement() { try { loopDepth++; Consume(TokenType.LEFT_PAREN, "Expect '(' after 'for'."); Statement initialiser = null; if (Match(TokenType.SEMICOLON)) { } else if (Match(TokenType.VAR)) { initialiser = VarDeclaration(); } else { initialiser = ExpressionStatement(); } Expression condition = Expression(); if (!Check(TokenType.SEMICOLON)) { condition = Expression(); } Consume(TokenType.SEMICOLON, "Expect ';' after loop condition."); Expression increment = null; if (!Check(TokenType.RIGHT_PAREN)) { increment = Expression(); } Consume(TokenType.RIGHT_PAREN, "Expect ')' after for clauses."); Statement body = Statement(); if (increment != null) { body = new Statement.Block(new List <Statement> { body, new Statement.Expression(increment) }); } if (condition == null) { condition = new Expression.Literal(true); } body = new Statement.While(condition, body); if (initialiser != null) { body = new Statement.Block(new List <Statement> { initialiser, body }); } return(body); } finally { loopDepth--; } }