-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix bugs and update to lang version 0.1.0-beta.4
- Loading branch information
1 parent
b96ac99
commit 5d18d33
Showing
23 changed files
with
220 additions
and
26 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
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
43 changes: 43 additions & 0 deletions
43
src/main/java/net/arkinsolomon/sakurainterpreter/functions/CanReadFunction.java
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,43 @@ | ||
/* | ||
* Copyright (c) 2023 Arkin Solomon. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, | ||
* either express or implied limitations under the License. | ||
*/ | ||
|
||
package net.arkinsolomon.sakurainterpreter.functions; | ||
|
||
import net.arkinsolomon.sakurainterpreter.exceptions.SakuraException; | ||
import net.arkinsolomon.sakurainterpreter.execution.DataType; | ||
import net.arkinsolomon.sakurainterpreter.execution.ExecutionContext; | ||
import net.arkinsolomon.sakurainterpreter.execution.Value; | ||
|
||
import java.io.File; | ||
import java.util.List; | ||
|
||
/** | ||
* Function to check if read permissions are enabled for a file. | ||
*/ | ||
public final class CanReadFunction implements Function { | ||
|
||
@Override | ||
public Value execute(List<Value> args, ExecutionContext ctx) { | ||
if (args.size() == 0) | ||
throw new SakuraException("The \"canRead()\" requires one parameter."); | ||
else if (args.get(0).type() != DataType.PATH) | ||
throw new SakuraException("The first parameter to \"canRead()\" needs to be of type path."); | ||
|
||
File checkFile = (File) args.get(0).value(); | ||
|
||
boolean canRead = ctx.getOperationConfig().isValidReadPath(checkFile); | ||
return new Value(DataType.BOOLEAN, canRead, false); | ||
} | ||
} |
43 changes: 43 additions & 0 deletions
43
src/main/java/net/arkinsolomon/sakurainterpreter/functions/CanWriteFunction.java
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,43 @@ | ||
/* | ||
* Copyright (c) 2023 Arkin Solomon. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, | ||
* either express or implied limitations under the License. | ||
*/ | ||
|
||
package net.arkinsolomon.sakurainterpreter.functions; | ||
|
||
import net.arkinsolomon.sakurainterpreter.exceptions.SakuraException; | ||
import net.arkinsolomon.sakurainterpreter.execution.DataType; | ||
import net.arkinsolomon.sakurainterpreter.execution.ExecutionContext; | ||
import net.arkinsolomon.sakurainterpreter.execution.Value; | ||
|
||
import java.io.File; | ||
import java.util.List; | ||
|
||
/** | ||
* Function to check if write permissions are enabled for a file. | ||
*/ | ||
public final class CanWriteFunction implements Function { | ||
|
||
@Override | ||
public Value execute(List<Value> args, ExecutionContext ctx) { | ||
if (args.size() == 0) | ||
throw new SakuraException("The \"canWrite()\" requires one parameter."); | ||
else if (args.get(0).type() != DataType.PATH) | ||
throw new SakuraException("The first parameter to \"canWrite()\" needs to be of type path."); | ||
|
||
File checkFile = (File) args.get(0).value(); | ||
|
||
boolean canWrite = ctx.getOperationConfig().isValidWritePath(checkFile); | ||
return new Value(DataType.BOOLEAN, canWrite, false); | ||
} | ||
} |
40 changes: 40 additions & 0 deletions
40
src/main/java/net/arkinsolomon/sakurainterpreter/functions/CustomFunction.java
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,40 @@ | ||
/* | ||
* Copyright (c) 2023 Arkin Solomon. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, | ||
* software distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, | ||
* either express or implied limitations under the License. | ||
*/ | ||
|
||
package net.arkinsolomon.sakurainterpreter.functions; | ||
|
||
import net.arkinsolomon.sakurainterpreter.execution.ExecutionContext; | ||
import net.arkinsolomon.sakurainterpreter.execution.Value; | ||
|
||
import java.util.List; | ||
|
||
/** | ||
* This class should be extended by the executor in order to add a custom function to the interpreter. | ||
*/ | ||
public abstract class CustomFunction implements Function { | ||
|
||
/** | ||
* Hide execution context from executor. | ||
* | ||
* @param args The values of the arguments passed to the function. | ||
* @return The return value of the function, or {@link Value#NULL} if there is none. | ||
*/ | ||
public abstract Value execute(List<Value> args); | ||
|
||
@Override | ||
public final Value execute(List<Value> args, ExecutionContext ctx) { | ||
return execute(args); | ||
} | ||
} |
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
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
Oops, something went wrong.