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

Basic Dafny to PHP Compiler #519

Open
wants to merge 9 commits into
base: master
Choose a base branch
from

Conversation

scottarc
Copy link
Contributor

@scottarc scottarc commented Jan 23, 2020

This successfully compiles Hello.dfy to a valid Hello.php file that executes successfully and produces almost the correct result.

php.exe Hello.php
Hello, JavaScript! Best, Dafny
x is 14
y is

The next step in this effort will be the development of a fleshed out DafnyRuntime.php.

@robin-aws
Copy link
Member

AWS CodeBuild CI Report

  • CodeBuild project: Dafny
  • Commit ID: 2be4c6e
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@scottarc
Copy link
Contributor Author

The error message seems a little vague. I think I need to add php.exe to the build system first.

Copy link
Member

@robin-aws robin-aws left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed offline, this is far too much code to review effectively at once, especially with just a single integration test to assert that it's all correct. I realize the structure of the compiler plugin mechanism makes it challenging to get things off the ground otherwise though. :)

How many of the Compiler methods could you just throw NotImplementedException from? I'd suggest just removing all the code that you copied and modified from other compilers that isn't necessary to have Hello.dfy pass.

Source/DafnyRuntime/DafnyRuntime.csproj Outdated Show resolved Hide resolved
Test/comp/Hello/Hello.php.expect Outdated Show resolved Hide resolved
@scottarc
Copy link
Contributor Author

This is now significantly trimmed down (and hopefully easier to review) @robin-aws.

@robin-aws
Copy link
Member

AWS CodeBuild CI Report

  • CodeBuild project: Dafny
  • Commit ID: 7dc161e
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@robin-aws
Copy link
Member

AWS CodeBuild CI Report

  • CodeBuild project: Dafny
  • Commit ID: c1b734c
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@robin-aws
Copy link
Member

AWS CodeBuild CI Report

  • CodeBuild project: Dafny
  • Commit ID: 03d935b
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@robin-aws
Copy link
Member

AWS CodeBuild CI Report

  • CodeBuild project: Dafny
  • Commit ID: 1e11588
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@robin-aws
Copy link
Member

AWS CodeBuild CI Report

  • CodeBuild project: Dafny
  • Commit ID: 3e5db67
  • Result: FAILED
  • Build Logs (available for 30 days)

Powered by github-codebuild-logs, available on the AWS Serverless Application Repository

@robin-aws
Copy link
Member

This is now significantly trimmed down (and hopefully easier to review) @robin-aws.

Significantly better, thanks! It's still a lot but I think we're at the minimum without refactoring the Compiler interface. I think that needs to happen sooner rather than later, and once this is merged I want to scope that out to see if it's reasonable to do before any further work here.

Copy link
Member

@robin-aws robin-aws left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just started adding comments but wanted to send the cause of your build failure first before getting too far. May send a second batch of comments shortly after.

The error message seems a little vague. I think I need to add php.exe to the build system first.

You're hitting this assertion in IdProtect, which doesn't know about PHP as a compile target yet:

Contract.Assert(false); // unexpected compile target

I have no clue how this would have worked on your machine. :) Missing a file?

public override string TargetLanguage => "PHP";

protected override void EmitHeader(Program program, TargetWriter wr)
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nit throughout: the standard style in this codebase seems to be same-line open bracket. And hey, that will probably cut another 100 lines or so! :)

{
wr.WriteLine("<?php");
wr.WriteLine("declare(strict_types=1);"); // Weak-typing in PHP is bad.
wr.WriteLine("// Dafny program {0} compiled into PHP", program.Name);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there any way to embed the program text in a way that tooling can extract it from a PHP package?

…piler-php-clean

# Conflicts:
#	Source/Dafny/DafnyPipeline.csproj
#	Source/DafnyDriver/DafnyDriver.cs
#	Source/DafnyRuntime/DafnyRuntime.csproj
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants