-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #28 from lyncmi07/1_native_aliases
1 native aliases
- Loading branch information
Showing
17 changed files
with
130 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
module Com.NoSyn.Ast.If.AliasDefinition where | ||
|
||
import Com.NoSyn.Ast.Traits.TargetCodeGeneratable | ||
import Com.NoSyn.Ast.Traits.EnvironmentUpdater | ||
import Com.NoSyn.Environment.ProgramEnvironment | ||
import Com.NoSyn.Data.Types | ||
import Com.NoSyn.Error.CompilerStatus | ||
import Data.Map.Ordered | ||
|
||
data AliasDefinition = | ||
ADNative Ident String | ||
| ADNoSyn Ident Ident | ||
deriving Show | ||
|
||
instance TargetCodeGeneratable AliasDefinition where | ||
generateD _ (ADNative _ _) = return ""; | ||
generateD _ (ADNoSyn _ _) = return ""; | ||
|
||
instance EnvironmentUpdater AliasDefinition where | ||
updateEnvironment programEnvironment@(PE { aliases = aliasEnvironment }) a@(ADNative _ _) = | ||
Error "Native aliases have not been implemented yet" (show a) | ||
updateEnvironment programEnvironment@(PE { aliases = aliasEnvironment }) (ADNoSyn aliasName aliasType) = do | ||
_ <- lookupDType aliasType aliasEnvironment | ||
let updatedAliasEnvironment = (aliasName, aliasType) |< aliasEnvironment in | ||
return (programEnvironment { aliases = updatedAliasEnvironment }) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
module Com.NoSyn.Ast.Ifm1.AliasDefinition where | ||
|
||
import Com.NoSyn.Ast.Traits.IfElementGeneratable | ||
import Com.NoSyn.Data.Types | ||
import qualified Com.NoSyn.Ast.If.AliasDefinition as IfAliasDefinition | ||
import qualified Com.NoSyn.Ast.If.IfElement as IfElement | ||
|
||
data AliasDefinition = | ||
ADNative Ident String | ||
| ADNoSyn Ident Ident | ||
deriving Show | ||
|
||
instance IfElementGeneratable AliasDefinition where | ||
generateIfElement programEnvironment (ADNative aliasName aliasType) = | ||
return $ IfElement.IfAliasDefinition (IfAliasDefinition.ADNative aliasName aliasType) | ||
generateIfElement programEnvironment (ADNoSyn aliasName aliasType) = | ||
return $ IfElement.IfAliasDefinition (IfAliasDefinition.ADNoSyn aliasName aliasType) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
%%SOURCE%% | ||
|
||
alias AnotherInt = Int; | ||
|
||
native Nothing assignment(Int* a, Int b); | ||
|
||
Nothing infix_:=_(Int* a, AnotherInt b) { | ||
assignment(b, b); | ||
} | ||
|
||
Nothing infix_+_(Int* a, AnotherInt b) { | ||
a := add(a, b); | ||
} | ||
|
||
Int add(Int a, Int b) { | ||
a; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
%%SOURCE%% | ||
|
||
native alias AnotherInt = `long`; | ||
|
||
native Nothing assignment(AnotherInt* a, AnotherInt b); | ||
|
||
Nothing infix_:=_(Int* a, AnotherInt b) { | ||
assignment(b, b); | ||
} | ||
|
||
Nothing infix_+_(Int* a, AnotherInt b) { | ||
a := add(a, b); | ||
} | ||
|
||
AnotherInt add(Int a, AnotherInt b) { | ||
b; | ||
} |