Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Translate-c-2 the rest #3935

Merged
merged 38 commits into from
Dec 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
c8c8964
Add comparison and bitwise binary ops in translate-c-2
kavika13 Dec 15, 2019
acff2d4
Add bit shift binary ops in translate-c-2
kavika13 Dec 15, 2019
89ef635
Add boolean and, boolean or binary ops in translate-c-2
kavika13 Dec 16, 2019
0c03fe4
Fix compile errors after rebasing on master (missing switch->else)
kavika13 Dec 16, 2019
d9527ed
translate-c-2 comma operator
Vexu Dec 16, 2019
6265625
translate-c-2 wors-case assign
Vexu Dec 16, 2019
e3f1bfe
translate-c-2 if statements
Vexu Dec 16, 2019
6a3d483
translate-c-2 while loops
Vexu Dec 16, 2019
d54bcb2
translate-c-2 break and continue
Vexu Dec 16, 2019
ab6fe57
translate-c-2 for loops
Vexu Dec 16, 2019
9cda93a
translate-c-2 don't shadow primitive types
Vexu Dec 17, 2019
daa22d4
translate-c-2 floats
Vexu Dec 17, 2019
0283ab8
translate-c-2 conditional operator
Vexu Dec 17, 2019
65531c7
translate-c-2 switch
Vexu Dec 17, 2019
a6960b8
translate-c-2 fix container type resolution
Vexu Dec 17, 2019
6d7025d
translate-c-2 various fixes to get more tests passing
Vexu Dec 17, 2019
21bc335
translate-c-2 character literals and more test fixes
Vexu Dec 17, 2019
90eed41
Merge remote-tracking branch 'kavika13/master' into translate-c-2
Vexu Dec 18, 2019
f54e7d6
translate-c-2 update @kavika13's work to removal of TransResult
Vexu Dec 18, 2019
62bfff5
translate-c-2 fix expression grouping bugs
Vexu Dec 18, 2019
e65b9e8
translate-c-2 stmt expr
Vexu Dec 18, 2019
cf7a5b7
translate-c-2 member access
Vexu Dec 18, 2019
c2666c4
translate-c-2 array access
Vexu Dec 18, 2019
d54c288
translate-c-2 function calls
Vexu Dec 18, 2019
122a9ba
translate-c-2 fix some casts
Vexu Dec 18, 2019
e4c47e8
translate-c-2 unaryexprortypetrait + fixes
Vexu Dec 19, 2019
809deb6
translate-c-2 unary operators common case
Vexu Dec 19, 2019
6cd402f
translate-c-2 increments worst-case
Vexu Dec 19, 2019
f837c7c
translate-c-2 compound assign
Vexu Dec 19, 2019
61482be
translate-c-2 improve macro fn ptr caller
Vexu Dec 19, 2019
b7f1816
translate-c-2 add missing casts
Vexu Dec 19, 2019
d172a73
translate-c-2 copy parametrs to stack
Vexu Dec 19, 2019
daeb939
translate-c-2 fix switch range
Vexu Dec 20, 2019
e0046b7
translate-c-2 improve macro escape sequences
Vexu Dec 20, 2019
9437d99
translate-c-2 final small fixes
Vexu Dec 20, 2019
949f236
translate-c-2 fix bugs found translating SDL
Vexu Dec 20, 2019
40f607d
translate-c-2 fix macro regression
Vexu Dec 20, 2019
9d31b65
translate-c-2 various fixes
Vexu Dec 22, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/std/fmt.zig
Original file line number Diff line number Diff line change
Expand Up @@ -582,7 +582,9 @@ pub fn formatAsciiChar(
comptime Errors: type,
output: fn (@TypeOf(context), []const u8) Errors!void,
) Errors!void {
return output(context, @as(*const [1]u8, &c)[0..]);
if (std.ascii.isPrint(c))
return output(context, @as(*const [1]u8, &c)[0..]);
return format(context, Errors, output, "\\x{x:0<2}", .{c});
}

pub fn formatBuf(
Expand Down
32 changes: 16 additions & 16 deletions lib/std/zig/ast.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1431,13 +1431,13 @@ pub const Node = struct {
AssignBitShiftRight,
AssignBitXor,
AssignDiv,
AssignMinus,
AssignMinusWrap,
AssignSub,
AssignSubWrap,
AssignMod,
AssignPlus,
AssignPlusWrap,
AssignTimes,
AssignTimesWarp,
AssignAdd,
AssignAddWrap,
AssignMul,
AssignMulWrap,
BangEqual,
BitAnd,
BitOr,
Expand All @@ -1456,8 +1456,8 @@ pub const Node = struct {
LessThan,
MergeErrorSets,
Mod,
Mult,
MultWrap,
Mul,
MulWrap,
Period,
Range,
Sub,
Expand Down Expand Up @@ -1490,13 +1490,13 @@ pub const Node = struct {
Op.AssignBitShiftRight,
Op.AssignBitXor,
Op.AssignDiv,
Op.AssignMinus,
Op.AssignMinusWrap,
Op.AssignSub,
Op.AssignSubWrap,
Op.AssignMod,
Op.AssignPlus,
Op.AssignPlusWrap,
Op.AssignTimes,
Op.AssignTimesWarp,
Op.AssignAdd,
Op.AssignAddWrap,
Op.AssignMul,
Op.AssignMulWrap,
Op.BangEqual,
Op.BitAnd,
Op.BitOr,
Expand All @@ -1514,8 +1514,8 @@ pub const Node = struct {
Op.LessThan,
Op.MergeErrorSets,
Op.Mod,
Op.Mult,
Op.MultWrap,
Op.Mul,
Op.MulWrap,
Op.Period,
Op.Range,
Op.Sub,
Expand Down
16 changes: 8 additions & 8 deletions lib/std/zig/parse.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1981,19 +1981,19 @@ fn parseAssignOp(arena: *Allocator, it: *TokenIterator, tree: *Tree) !?*Node {

const token = nextToken(it);
const op = switch (token.ptr.id) {
.AsteriskEqual => Op{ .AssignTimes = {} },
.AsteriskEqual => Op{ .AssignMul = {} },
.SlashEqual => Op{ .AssignDiv = {} },
.PercentEqual => Op{ .AssignMod = {} },
.PlusEqual => Op{ .AssignPlus = {} },
.MinusEqual => Op{ .AssignMinus = {} },
.PlusEqual => Op{ .AssignAdd = {} },
.MinusEqual => Op{ .AssignSub = {} },
.AngleBracketAngleBracketLeftEqual => Op{ .AssignBitShiftLeft = {} },
.AngleBracketAngleBracketRightEqual => Op{ .AssignBitShiftRight = {} },
.AmpersandEqual => Op{ .AssignBitAnd = {} },
.CaretEqual => Op{ .AssignBitXor = {} },
.PipeEqual => Op{ .AssignBitOr = {} },
.AsteriskPercentEqual => Op{ .AssignTimesWarp = {} },
.PlusPercentEqual => Op{ .AssignPlusWrap = {} },
.MinusPercentEqual => Op{ .AssignMinusWrap = {} },
.AsteriskPercentEqual => Op{ .AssignMulWrap = {} },
.PlusPercentEqual => Op{ .AssignAddWrap = {} },
.MinusPercentEqual => Op{ .AssignSubWrap = {} },
.Equal => Op{ .Assign = {} },
else => {
putBackToken(it, token.index);
Expand Down Expand Up @@ -2120,11 +2120,11 @@ fn parseMultiplyOp(arena: *Allocator, it: *TokenIterator, tree: *Tree) !?*Node {
const token = nextToken(it);
const op = switch (token.ptr.id) {
.PipePipe => ops{ .BoolOr = {} },
.Asterisk => ops{ .Mult = {} },
.Asterisk => ops{ .Mul = {} },
.Slash => ops{ .Div = {} },
.Percent => ops{ .Mod = {} },
.AsteriskAsterisk => ops{ .ArrayMult = {} },
.AsteriskPercent => ops{ .MultWrap = {} },
.AsteriskPercent => ops{ .MulWrap = {} },
else => {
putBackToken(it, token.index);
return null;
Expand Down
2 changes: 1 addition & 1 deletion lib/std/zig/render.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1629,7 +1629,7 @@ fn renderExpression(
.If => {
const if_node = @fieldParentPtr(ast.Node.If, "base", base);

const lparen = tree.prevToken(if_node.condition.firstToken());
const lparen = tree.nextToken(if_node.if_token);
const rparen = tree.nextToken(if_node.condition.lastToken());

try renderToken(tree, stream, if_node.if_token, indent, start_col, Space.Space); // if
Expand Down