How do I start implementing a feature?

I downloaded (w/ GitHub Desktop on macOS) a copy of the Swift repository. I ran the build scripts to download the other parts of LLVM, built everything, and created Xcode (9 beta 4) project files. Now how do I actually do a new feature? The number of targets in the Xcode project file is so intimidatingly huge I don’t know where to start.

The feature is a new kind of named type. I need to start with the AST part of the compiler, plus some test cases. The format of the new type of type is:

key-tag identifier : type-inheritance-list definition-block

where the key tag is currently “alter” and the type inheritance list must have exactly one type in it. (So an empty list or an all-protocol list is an error.) Right now, I want a test for accepting the new type at all, rejecting a new type with an empty inheritance list, and rejecting a new type with all protocols in its list. If those last two tests would be part of the semantic phase, I’ll hold off on those until the AST phase is done.

···


Daryle Walker
Mac, Internet, and Video Game Junkie
darylew AT mac DOT com

Hi Daryle,

The easiest way to start adding new features to an existing project is by cribbing from existing features that are sufficiently similar (at least enough to get started and see what fails to compile after some changes). For example, if you wanted to implement a new and awesome loop construct, then start by copying, pasting, and renaming the implementation details for an existing loop that you like (be it “for” or “while”, etc). You’ll learn far faster this way than any other way. :-)

Good luck,
Dave

···

On Aug 21, 2017, at 12:50, Daryle Walker via swift-dev <swift-dev@swift.org> wrote:

I downloaded (w/ GitHub Desktop on macOS) a copy of the Swift repository. I ran the build scripts to download the other parts of LLVM, built everything, and created Xcode (9 beta 4) project files. Now how do I actually do a new feature? The number of targets in the Xcode project file is so intimidatingly huge I don’t know where to start.

The feature is a new kind of named type. I need to start with the AST part of the compiler, plus some test cases. The format of the new type of type is:

key-tag identifier : type-inheritance-list definition-block

where the key tag is currently “alter” and the type inheritance list must have exactly one type in it. (So an empty list or an all-protocol list is an error.) Right now, I want a test for accepting the new type at all, rejecting a new type with an empty inheritance list, and rejecting a new type with all protocols in its list. If those last two tests would be part of the semantic phase, I’ll hold off on those until the AST phase is done.


Daryle Walker
Mac, Internet, and Video Game Junkie
darylew AT mac DOT com

_______________________________________________
swift-dev mailing list
swift-dev@swift.org
https://lists.swift.org/mailman/listinfo/swift-dev

I’m trying to figure out where are these features and what directories I need to look at.

The steps I would go are:
1. Create a new test file for the AST phase with “alter MyAlterTest1 {}”. Figure out where the corresponding makefile/whatever is and add the test file there too. Test and instantly fail, until I do:
2. Copy whichever files handle raw-value enumerations for the “similar existing feature” and alter them to until I get an AST match.
3. ???
4. Profit?

···

On Aug 21, 2017, at 3:55 PM, David Zarzycki <zarzycki@icloud.com> wrote:

The easiest way to start adding new features to an existing project is by cribbing from existing features that are sufficiently similar (at least enough to get started and see what fails to compile after some changes). For example, if you wanted to implement a new and awesome loop construct, then start by copying, pasting, and renaming the implementation details for an existing loop that you like (be it “for” or “while”, etc). You’ll learn far faster this way than any other way. :slight_smile:


Daryle Walker
Mac, Internet, and Video Game Junkie
darylew AT mac DOT com

Just create a test file somewhere in test directory hierarchy. The test suite will automatically notice it when the test suite is run.

As for creating new source files, that tends not to be done in the project. Take parsing for example:

lib/Parse/CMakeLists.txt
lib/Parse/Confusables.cpp
lib/Parse/Lexer.cpp
lib/Parse/ParseDecl.cpp
lib/Parse/ParseExpr.cpp
lib/Parse/ParseGeneric.cpp
lib/Parse/ParseIfConfig.cpp
lib/Parse/ParsePattern.cpp
lib/Parse/ParseStmt.cpp
lib/Parse/ParseType.cpp
lib/Parse/Parser.cpp
lib/Parse/PersistentParserState.cpp
lib/Parse/Scope.cpp

Notice now *all* of the declaration parsing is done in one file. If you want to add a new decl kind, then you’ll need to update that file and dependent files.

Good luck,
Dave

···

On Aug 22, 2017, at 01:24, Daryle Walker <darylew@mac.com> wrote:

On Aug 21, 2017, at 3:55 PM, David Zarzycki <zarzycki@icloud.com> wrote:

The easiest way to start adding new features to an existing project is by cribbing from existing features that are sufficiently similar (at least enough to get started and see what fails to compile after some changes). For example, if you wanted to implement a new and awesome loop construct, then start by copying, pasting, and renaming the implementation details for an existing loop that you like (be it “for” or “while”, etc). You’ll learn far faster this way than any other way. :-)

I’m trying to figure out where are these features and what directories I need to look at.

The steps I would go are:
1. Create a new test file for the AST phase with “alter MyAlterTest1 {}”. Figure out where the corresponding makefile/whatever is and add the test file there too.