| ... | ... | @@ -1522,6 +1522,47 @@ Happy writing! |
| 1522 | 1522 | return; |
| 1523 | 1523 | } |
| 1524 | 1524 | |
| 1525 | case "unOpIndex": { |
| 1526 | const unOp = zigAnalysis.exprs[expr.unOpIndex]; |
| 1527 | yield* ex(unOp, opts); |
| 1528 | return; |
| 1529 | } |
| 1530 | |
| 1531 | case "unOp": { |
| 1532 | const param = zigAnalysis.exprs[expr.unOp.param]; |
| 1533 | |
| 1534 | switch (expr.unOp.name) { |
| 1535 | case "bit_not": { |
| 1536 | yield { src: "~", tag: Tag.tilde }; |
| 1537 | break; |
| 1538 | } |
| 1539 | case "bool_not": { |
| 1540 | yield { src: "!", tag: Tag.bang }; |
| 1541 | break; |
| 1542 | } |
| 1543 | case "negate_wrap": { |
| 1544 | yield { src: "-%", tag: Tag.minus_percent }; |
| 1545 | break; |
| 1546 | } |
| 1547 | case "negate": { |
| 1548 | yield { src: "-", tag: Tag.minus }; |
| 1549 | break; |
| 1550 | } |
| 1551 | default: |
| 1552 | throw "unOp: `" + expr.unOp.name + "` not implemented yet!" |
| 1553 | } |
| 1554 | |
| 1555 | if (param["binOpIndex"] !== undefined) { |
| 1556 | yield Tok.l_paren; |
| 1557 | yield* ex(param, opts); |
| 1558 | yield Tok.r_paren; |
| 1559 | } else { |
| 1560 | yield* ex(param, opts); |
| 1561 | } |
| 1562 | |
| 1563 | return; |
| 1564 | } |
| 1565 | |
| 1525 | 1566 | case "binOpIndex": { |
| 1526 | 1567 | const binOp = zigAnalysis.exprs[expr.binOpIndex]; |
| 1527 | 1568 | yield* ex(binOp, opts); |
| ... | ... | @@ -1669,6 +1710,52 @@ Happy writing! |
| 1669 | 1710 | return; |
| 1670 | 1711 | } |
| 1671 | 1712 | |
| 1713 | case "builtin": { |
| 1714 | const builtin = expr.builtin; |
| 1715 | let name = "@"; |
| 1716 | const param = zigAnalysis.exprs[builtin.param]; |
| 1717 | switch (builtin.name) { |
| 1718 | case "align_of": { name += "alignOf"; break; } |
| 1719 | case "int_from_bool": { name += "intFromBool"; break; } |
| 1720 | case "embed_file": { name += "embedFile"; break; } |
| 1721 | case "error_name": { name += "errorName"; break; } |
| 1722 | case "panic": { name += "panic"; break; } |
| 1723 | case "set_runtime_safety": { name += "setRuntimeSafety"; break; } |
| 1724 | case "sqrt": { name += "sqrt"; break; } |
| 1725 | case "sin": { name += "sin"; break; } |
| 1726 | case "cos": { name += "cos"; break; } |
| 1727 | case "tan": { name += "tan"; break; } |
| 1728 | case "exp": { name += "exp"; break; } |
| 1729 | case "exp2": { name += "exp2"; break; } |
| 1730 | case "log": { name += "log"; break; } |
| 1731 | case "log2": { name += "log2"; break; } |
| 1732 | case "log10": { name += "log10"; break; } |
| 1733 | case "fabs": { name += "fabs"; break; } |
| 1734 | case "floor": { name += "floor"; break; } |
| 1735 | case "ceil": { name += "ceil"; break; } |
| 1736 | case "trunc": { name += "trunc"; break; } |
| 1737 | case "round": { name += "round"; break; } |
| 1738 | case "tag_name": { name += "tagName"; break; } |
| 1739 | case "type_name": { name += "typeName"; break; } |
| 1740 | case "type_info": { name += "typeInfo"; break; } |
| 1741 | case "frame_type": { name += "Frame"; break; } |
| 1742 | case "frame_size": { name += "frameSize"; break; } |
| 1743 | case "int_from_ptr": { name += "intFromPtr"; break; } |
| 1744 | case "int_from_enum": { name += "intFromEnum"; break; } |
| 1745 | case "clz": { name += "clz"; break; } |
| 1746 | case "ctz": { name += "ctz"; break; } |
| 1747 | case "pop_count": { name += "popCount"; break; } |
| 1748 | case "byte_swap": { name += "byteSwap"; break; } |
| 1749 | case "bit_reverse": { name += "bitReverse"; break; } |
| 1750 | default: throw "builtin: `" + builtin.name + "` not implemented yet!"; |
| 1751 | } |
| 1752 | yield { src: name, tag: Tag.builtin }; |
| 1753 | yield Tok.l_paren; |
| 1754 | yield* ex(param, opts); |
| 1755 | yield Tok.r_paren; |
| 1756 | return; |
| 1757 | } |
| 1758 | |
| 1672 | 1759 | case "builtinBinIndex": { |
| 1673 | 1760 | const builtinBinIndex = zigAnalysis.exprs[expr.builtinBinIndex]; |
| 1674 | 1761 | yield* ex(builtinBinIndex, opts); |
| ... | ... | @@ -1899,15 +1986,6 @@ Happy writing! |
| 1899 | 1986 | return; |
| 1900 | 1987 | } |
| 1901 | 1988 | |
| 1902 | | case "typeInfo": { |
| 1903 | | const arg = zigAnalysis.exprs[expr.typeInfo]; |
| 1904 | | yield { src: "@typeInfo", tag: Tag.builtin }; |
| 1905 | | yield Tok.l_paren; |
| 1906 | | yield* ex(arg, opts); |
| 1907 | | yield Tok.r_paren; |
| 1908 | | return; |
| 1909 | | } |
| 1910 | | |
| 1911 | 1989 | case "switchIndex": { |
| 1912 | 1990 | const switchIndex = zigAnalysis.exprs[expr.switchIndex]; |
| 1913 | 1991 | yield* ex(switchIndex, opts); |
| ... | ... | @@ -4560,16 +4638,16 @@ Happy writing! |
| 4560 | 4638 | switch (ty[0]) { |
| 4561 | 4639 | default: |
| 4562 | 4640 | throw "unhandled type kind!"; |
| 4563 | | case 0: // Unanalyzed |
| 4641 | case typeKinds.Unanalyzed: |
| 4564 | 4642 | throw "unanalyzed type!"; |
| 4565 | | case 1: // Type |
| 4566 | | case 2: // Void |
| 4567 | | case 3: // Bool |
| 4568 | | case 4: // NoReturn |
| 4569 | | case 5: // Int |
| 4570 | | case 6: // Float |
| 4643 | case typeKinds.Type: |
| 4644 | case typeKinds.Void: |
| 4645 | case typeKinds.Bool: |
| 4646 | case typeKinds.NoReturn: |
| 4647 | case typeKinds.Int: |
| 4648 | case typeKinds.Float: |
| 4571 | 4649 | return { kind: ty[0], name: ty[1] }; |
| 4572 | | case 7: // Pointer |
| 4650 | case typeKinds.Pointer: |
| 4573 | 4651 | return { |
| 4574 | 4652 | kind: ty[0], |
| 4575 | 4653 | size: ty[1], |
| ... | ... | @@ -4588,14 +4666,14 @@ Happy writing! |
| 4588 | 4666 | has_addrspace: ty[14], |
| 4589 | 4667 | has_bit_range: ty[15], |
| 4590 | 4668 | }; |
| 4591 | | case 8: // Array |
| 4669 | case typeKinds.Array: |
| 4592 | 4670 | return { |
| 4593 | 4671 | kind: ty[0], |
| 4594 | 4672 | len: ty[1], |
| 4595 | 4673 | child: ty[2], |
| 4596 | 4674 | sentinel: ty[3], |
| 4597 | 4675 | }; |
| 4598 | | case 9: // Struct |
| 4676 | case typeKinds.Struct: |
| 4599 | 4677 | return { |
| 4600 | 4678 | kind: ty[0], |
| 4601 | 4679 | name: ty[1], |
| ... | ... | @@ -4610,36 +4688,36 @@ Happy writing! |
| 4610 | 4688 | parent_container: ty[10], |
| 4611 | 4689 | layout: ty[11], |
| 4612 | 4690 | }; |
| 4613 | | case 10: // ComptimeExpr |
| 4614 | | case 11: // ComptimeFloat |
| 4615 | | case 12: // ComptimeInt |
| 4616 | | case 13: // Undefined |
| 4617 | | case 14: // Null |
| 4691 | case typeKinds.ComptimeExpr: |
| 4692 | case typeKinds.ComptimeFloat: |
| 4693 | case typeKinds.ComptimeInt: |
| 4694 | case typeKinds.Undefined: |
| 4695 | case typeKinds.Null: |
| 4618 | 4696 | return { kind: ty[0], name: ty[1] }; |
| 4619 | | case 15: // Optional |
| 4697 | case typeKinds.Optional: |
| 4620 | 4698 | return { |
| 4621 | 4699 | kind: ty[0], |
| 4622 | 4700 | name: ty[1], |
| 4623 | 4701 | child: ty[2], |
| 4624 | 4702 | }; |
| 4625 | | case 16: // ErrorUnion |
| 4703 | case typeKinds.ErrorUnion: |
| 4626 | 4704 | return { |
| 4627 | 4705 | kind: ty[0], |
| 4628 | 4706 | lhs: ty[1], |
| 4629 | 4707 | rhs: ty[2], |
| 4630 | 4708 | }; |
| 4631 | | case 17: // InferredErrorUnion |
| 4709 | case typeKinds.InferredErrorUnion: |
| 4632 | 4710 | return { |
| 4633 | 4711 | kind: ty[0], |
| 4634 | 4712 | payload: ty[1], |
| 4635 | 4713 | }; |
| 4636 | | case 18: // ErrorSet |
| 4714 | case typeKinds.ErrorSet: |
| 4637 | 4715 | return { |
| 4638 | 4716 | kind: ty[0], |
| 4639 | 4717 | name: ty[1], |
| 4640 | 4718 | fields: ty[2], |
| 4641 | 4719 | }; |
| 4642 | | case 19: // Enum |
| 4720 | case typeKinds.Enum: |
| 4643 | 4721 | return { |
| 4644 | 4722 | kind: ty[0], |
| 4645 | 4723 | name: ty[1], |
| ... | ... | @@ -4651,7 +4729,7 @@ Happy writing! |
| 4651 | 4729 | nonexhaustive: ty[7], |
| 4652 | 4730 | parent_container: ty[8], |
| 4653 | 4731 | }; |
| 4654 | | case 20: // Union |
| 4732 | case typeKinds.Union: |
| 4655 | 4733 | return { |
| 4656 | 4734 | kind: ty[0], |
| 4657 | 4735 | name: ty[1], |
| ... | ... | @@ -4664,7 +4742,7 @@ Happy writing! |
| 4664 | 4742 | parent_container: ty[8], |
| 4665 | 4743 | layout: ty[9], |
| 4666 | 4744 | }; |
| 4667 | | case 21: // Fn |
| 4745 | case typeKinds.Fn: |
| 4668 | 4746 | return { |
| 4669 | 4747 | kind: ty[0], |
| 4670 | 4748 | name: ty[1], |
| ... | ... | @@ -4683,9 +4761,7 @@ Happy writing! |
| 4683 | 4761 | is_test: ty[14], |
| 4684 | 4762 | is_extern: ty[15], |
| 4685 | 4763 | }; |
| 4686 | | case 22: // BoundFn |
| 4687 | | return { kind: ty[0], name: ty[1] }; |
| 4688 | | case 23: // Opaque |
| 4764 | case typeKinds.Opaque: |
| 4689 | 4765 | return { |
| 4690 | 4766 | kind: ty[0], |
| 4691 | 4767 | name: ty[1], |
| ... | ... | @@ -4694,10 +4770,10 @@ Happy writing! |
| 4694 | 4770 | pubDecls: ty[4], |
| 4695 | 4771 | parent_container: ty[5], |
| 4696 | 4772 | }; |
| 4697 | | case 24: // Frame |
| 4698 | | case 25: // AnyFrame |
| 4699 | | case 26: // Vector |
| 4700 | | case 27: // EnumLiteral |
| 4773 | case typeKinds.Frame: |
| 4774 | case typeKinds.AnyFrame: |
| 4775 | case typeKinds.Vector: |
| 4776 | case typeKinds.EnumLiteral: |
| 4701 | 4777 | return { kind: ty[0], name: ty[1] }; |
| 4702 | 4778 | } |
| 4703 | 4779 | } |