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

(feat): Add Positional Trait in Go codegen #7

Open
wants to merge 49 commits into
base: scchatur/GoCodegen
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 28 commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
8662494
Add runtime (remove later)
rishav-karanjit Jul 31, 2024
2e05f73
Comment all test model for faster workflow run
rishav-karanjit Jul 31, 2024
ea8fd4a
Add runtime
rishav-karanjit Aug 1, 2024
eb466e3
Changes for the positional trait
rishav-karanjit Aug 5, 2024
fc3244a
Changes for positional trait
rishav-karanjit Aug 5, 2024
3a7264f
Remove redundant code
rishav-karanjit Aug 5, 2024
df3e00c
Add everything
rishav-karanjit Aug 7, 2024
2df4fd0
Revert the unwanted changes
rishav-karanjit Aug 7, 2024
662bb74
Changes for shim
rishav-karanjit Aug 7, 2024
9d3ea35
Update API client return type for interface
rishav-karanjit Aug 9, 2024
68f868f
maybe output to output
rishav-karanjit Aug 9, 2024
f5b9b36
get dafny type from DafnyNameResolver
rishav-karanjit Aug 9, 2024
fd66e38
remove print statement
rishav-karanjit Aug 10, 2024
fa80eb9
api client part where we return values
rishav-karanjit Aug 10, 2024
29f4a01
Uncomment so that CI runs
rishav-karanjit Aug 10, 2024
c6b27c1
Remove runtimes
rishav-karanjit Aug 10, 2024
e0e36d3
Add go.mod
rishav-karanjit Aug 10, 2024
4870e61
remove dafny codegen files
rishav-karanjit Aug 10, 2024
c4c346f
Update go mod
rishav-karanjit Aug 11, 2024
80eea0e
Fix symbolForPositional
rishav-karanjit Aug 11, 2024
fc2464a
Update to DafnyNameResolver
rishav-karanjit Aug 11, 2024
8338b42
Update getSmithyType
rishav-karanjit Aug 11, 2024
918c42e
Replace with isOptional
rishav-karanjit Aug 11, 2024
2f7f0cb
Replaced isOptional with isPointable
rishav-karanjit Aug 12, 2024
dec64c7
Update DafnyNameResolver
rishav-karanjit Aug 13, 2024
ffa8896
Update DafnyNameResolver
rishav-karanjit Aug 13, 2024
470f915
Copy GoPointableIndex from rishav-union
rishav-karanjit Aug 13, 2024
5e0dc6e
Merge with scchatur/GoCodegen
rishav-karanjit Aug 13, 2024
817d7a9
Put check for PositionalTrait outside outputshape check
rishav-karanjit Aug 22, 2024
eb8b0c0
Remove comments
rishav-karanjit Aug 22, 2024
e5c9ffd
Merge from scchatur/GoCodegen
rishav-karanjit Aug 29, 2024
d48e10f
Merge fix
rishav-karanjit Sep 2, 2024
bdd77e3
Merge branch 'scchatur/GoCodegen' into rishav-positional
rishav-karanjit Sep 2, 2024
8fde5f4
feat: Rust codegen for more SimpleTypes models (#542)
alex-chew Sep 2, 2024
dfca8d9
fix: bump Rust version to 1.80 (#553)
ajewellamz Sep 3, 2024
0a707a2
Remove unwanted whitespace
rishav-karanjit Sep 3, 2024
17425b1
chore(ci): make all pull.yml jobs required in branch protection autom…
robin-aws Sep 3, 2024
3c0a1ce
chore: add Dafny 4.8.0 (#522)
josecorella Sep 4, 2024
4a80456
fix: CI
ShubhamChaturvedi7 Sep 4, 2024
2c3f760
Merge branch 'main-1.x' into Golang/dev
ShubhamChaturvedi7 Sep 4, 2024
2cf84b3
fix: use gradle for CI
ShubhamChaturvedi7 Sep 4, 2024
f1504b5
fix: Add CI Tests
ShubhamChaturvedi7 Sep 4, 2024
61cc564
fix: Drop the removeDots script
ShubhamChaturvedi7 Sep 4, 2024
ac8a6a4
fix: prettify
ShubhamChaturvedi7 Sep 4, 2024
61d7284
Merge branch 'Golang/dev' into rishav-positional
rishav-karanjit Sep 5, 2024
ca4d375
Revert "Merge branch 'Golang/dev' into rishav-positional"
rishav-karanjit Sep 9, 2024
2072d44
Revert "Revert "Merge branch 'Golang/dev' into rishav-positional""
rishav-karanjit Sep 9, 2024
32f4f29
Merge fix structure generator
rishav-karanjit Sep 9, 2024
14ccc65
Format
rishav-karanjit Sep 9, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/workflows/test_models_go_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ jobs:
fail-fast: false
matrix:
library: [
# TODO: Uncomment below before making PR
# TestModels/dafny-dependencies/StandardLibrary, # This stores current Polymorph dependencies that all TestModels depend on
TestModels/Aggregate,
# TestModels/AggregateReferences,
Expand All @@ -21,6 +22,7 @@ jobs:
# TestModels/LanguageSpecificLogic,
# TestModels/LocalService,
# TestModels/MultipleModels,
TestModels/Positional,
TestModels/Refinement,
TestModels/Resource,
# TestModels/SimpleTypes/BigDecimal,
Expand Down
5 changes: 5 additions & 0 deletions TestModels/Positional/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ SERVICE_DEPS_SimplePositional :=

SMITHY_DEPS=dafny-dependencies/Model/traits.smithy

GO_MODULE_NAME="github.com/Smithy-dafny/TestModels/Positional"

PROJECT_DTR := \
dafny-dependencies/StandardLibrary/runtimes/go/ImplementationFromDafny-go/ImplementationFromDafny-go.dtr

# This project has no dependencies
# DEPENDENT-MODELS:=

Expand Down
27 changes: 27 additions & 0 deletions TestModels/Positional/removeDotFromExtern.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#!/bin/bash
# TODO: remove this file if codegen is not generating extern with "." in go

removeDotFromExtern() {
local directory="$1"
# Recursively search for all files in the current directory and subdirectories
for file in $(find "$directory" -type f); do
# Check if the file contains the pattern "{:extern "XYZ" }"
if grep -q '{:extern ".*"' "$file"; then
# Extract the "XYZ" part from the pattern
xyz=$(grep -o '{:extern "\([^"]*\)"' "$file" | sed 's/{:extern "\([^"]*\)"/\1/')
# Check if the "XYZ" part contains a dot
if [[ "$xyz" == *"."* ]]; then
# Remove the dot from "XYZ"
new_xyz=$(echo "$xyz" | sed 's/\.//g')
# Update the file with the new pattern
sed "s/{:extern \"$xyz\"/{:extern \"$new_xyz\"/g" $file > $file.tmp
cat $file.tmp > $file
rm $file.tmp
fi
fi
done
}

removeDotFromExtern "Model"
removeDotFromExtern "src"

11 changes: 11 additions & 0 deletions TestModels/Positional/runtimes/go/go.mod
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module github.com/Smithy-dafny/TestModels/Positional

go 1.22.2

require github.com/dafny-lang/DafnyStandardLibGo v0.0.0

require github.com/dafny-lang/DafnyRuntimeGo v0.0.0

replace github.com/dafny-lang/DafnyRuntimeGo => ../../../../../DafnyRuntimeGo/

replace github.com/dafny-lang/DafnyStandardLibGo => ../../../../dafny-dependencies/StandardLibrary/runtimes/go/ImplementationFromDafny-go/
2 changes: 1 addition & 1 deletion TestModels/SimpleTypes/SimpleEnum/src/Index.dfy
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
include "SimpleEnumImpl.dfy"

module {:extern "simpletypessmithyenuminternaldafny" } SimpleEnum refines AbstractSimpleTypesSmithyEnumService {
module {:extern "simple.types.smithyenum.internaldafny" } SimpleEnum refines AbstractSimpleTypesSmithyEnumService {
import Operations = SimpleEnumImpl

function method DefaultSimpleEnumConfig(): SimpleEnumConfig {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// SPDX-License-Identifier: Apache-2.0
include "../Model/SimpleTypesSmithyEnumTypesWrapped.dfy"

module {:extern "simpletypessmithyenuminternaldafnywrapped"} WrappedSimpleTypesEnumService refines WrappedAbstractSimpleTypesSmithyEnumService {
module {:extern "simple.types.smithyenum.internaldafny.wrapped"} WrappedSimpleTypesEnumService refines WrappedAbstractSimpleTypesSmithyEnumService {
import WrappedService = SimpleEnum
function method WrappedDefaultSimpleEnumConfig(): SimpleEnumConfig {
SimpleEnumConfig
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ public void renderStructure(Runnable runnable, boolean isInputStructure) {

if (targetShape.hasTrait(ReferenceTrait.class)) {
memberSymbol = memberSymbol.getProperty("Referred", Symbol.class).get();

var refShape = targetShape.expectTrait(ReferenceTrait.class);
if (refShape.isService()) {
namespace = SmithyNameResolver.shapeNamespace(model.expectShape(refShape.getReferentId()));
Expand All @@ -124,9 +125,7 @@ public void renderStructure(Runnable runnable, boolean isInputStructure) {
writer.addImportFromModule(SmithyNameResolver.getGoModuleNameForSmithyNamespace(targetShape.toShapeId().getNamespace()), namespace);
}
}

writer.write("$L $P", memberName, memberSymbol);

});
writer.closeBlock("}").write("");
renderValidator(symbol, sortedMembers, isInputStructure);
Expand Down
Loading
Loading