Skip to content

Commit

Permalink
ezrSquared beta-1.0.0.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
Uralstech committed Dec 23, 2022
1 parent 6bba358 commit a96d34b
Show file tree
Hide file tree
Showing 5 changed files with 31 additions and 20 deletions.
25 changes: 9 additions & 16 deletions Classes/Values.cs
Original file line number Diff line number Diff line change
Expand Up @@ -132,13 +132,6 @@ public item setContext(context? context)
return null;
}

internal context generateContext()
{
context newContext = new context($"{GetType().Name}-internal", context, startPos, false);
newContext.symbolTable = new symbolTable(newContext.parent.symbolTable);
return newContext;
}

public virtual runtimeResult execute(item[] args) { return new runtimeResult().failure(illegalOperation()); }
public virtual runtimeResult retrieve(node node) { return new runtimeResult().failure(illegalOperation()); }

Expand All @@ -156,7 +149,7 @@ internal error illegalOperation(item? other = null)
public override int GetHashCode() { throw new Exception($"No GetHashCode method defined for '{GetType().Name}'!"); }
}

public abstract class value: item
public abstract class value : item
{
public dynamic storedValue;
internal context? internalContext;
Expand All @@ -170,7 +163,7 @@ public value(dynamic storedValue)

internal context generateContext()
{
context newContext = new context($"{GetType().Name}-internal", context, startPos, false);
context newContext = new context($"<<{GetType().Name}> internal>", context, startPos, false);
newContext.symbolTable = new symbolTable(newContext.parent.symbolTable);
return newContext;
}
Expand Down Expand Up @@ -770,9 +763,9 @@ public runtimeResult stringSlice(context context)

if (startAsInt < 0)
return result.failure(new runtimeError(startPos, endPos, RT_TYPE, "Start cannot be less than zero", context));
else if (endAsInt > storedValue.ToString().Length)
else if (endAsInt > storedValue.ToString().Length)
return result.failure(new runtimeError(startPos, endPos, RT_TYPE, "End cannot be greater than length of string", context));
else if (startAsInt > endAsInt)
else if (startAsInt > endAsInt)
return result.failure(new runtimeError(startPos, endPos, RT_TYPE, "Start cannot be greater than end", context));

return result.success(new @string(storedValue.ToString().Substring(startAsInt, endAsInt)));
Expand All @@ -793,7 +786,7 @@ public runtimeResult stringInsert(context context)

if (startAsInt < 0)
return result.failure(new runtimeError(startPos, endPos, RT_TYPE, "Index cannot be less than zero", context));
else if (startAsInt > storedValue.ToString().Length)
else if (startAsInt > storedValue.ToString().Length)
return result.failure(new runtimeError(startPos, endPos, RT_TYPE, "Index cannot be greater than length of string", context));

return result.success(new @string(storedValue.ToString().Insert(startAsInt, ((@string)substring).storedValue.ToString())));
Expand Down Expand Up @@ -854,7 +847,7 @@ public runtimeResult asInteger(context context)
return result.success(new integerNumber(integer));
return result.failure(new runtimeError(startPos, endPos, RT_TYPE, "Could not convert string to integerNumber", context));
}

public runtimeResult asFloat(context context)
{
runtimeResult result = new runtimeResult();
Expand Down Expand Up @@ -1436,7 +1429,7 @@ public override runtimeResult execute(item[] args)
public override string ToString()
{
string[] elementStrings = new string[storedValue.Count];
KeyValuePair <item, item>[] values = ((Dictionary<item, item>)storedValue).AsEnumerable().ToArray();
KeyValuePair<item, item>[] values = ((Dictionary<item, item>)storedValue).AsEnumerable().ToArray();
for (int i = 0; i < values.Length; i++)
elementStrings[i] = $"{values[i].Key} : {values[i].Value}";
return '{' + string.Join(", ", elementStrings) + '}';
Expand All @@ -1462,7 +1455,7 @@ public baseFunction(string? name) : base()
internal context generateContext()
{
context newContext = new context(name, context, startPos, false);
newContext.symbolTable = new symbolTable(context.parent.symbolTable);
newContext.symbolTable = new symbolTable(newContext.parent.symbolTable);
return newContext;
}

Expand Down Expand Up @@ -1633,7 +1626,7 @@ private runtimeResult _run(context context)
return result.failure(new runtimeError(startPos, endPos, RT_IO, $"Failed to load script \"{path}\"\n{exception.Message}", context));
}

error? error = new main.ezr().run(path, script, out item? _);
error? error = new main.ezr().run(Path.GetFileName(path), script, out item? _);
if (error != null)
return result.failure(new runtimeError(startPos, endPos, RT_RUN, $"Failed to execute script \"{path}\"\n\n{error.asString()}", context));
return result.success(new nothing());
Expand Down
2 changes: 1 addition & 1 deletion Constants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
public static class Constants
{
public const string VERSION = "beta-1.0.0.0.1";
public const string VERSION = "beta-1.0.0.0.2";
public const string VERSION_DATE = "23.12.2022";

public const string LETTERS_UNDERSCORE = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ_";
Expand Down
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,18 @@ And the differences:
* QSyntax is not available in ezr
* Count loops are different
* All the variable types have had an overhaul in ezr²
* ezr² is much faster
* ezr² is much faster

## Progress
* **beta-1.0.0.0.2** - [23-12-22]
* Fixed bug in `baseFunction` class - Changed `newContext.symbolTable = new symbolTable(context.parent.symbolTable)` to `newContext.symbolTable = new symbolTable(newContext.parent.symbolTable)`
* For builtin function `run`, changed filename from full path to just file name
* Removed unused `GenerateContext` definition in `item` class
* Fixed bug in `shell` (now `biShell` - builtin shell) for paths given through command line - `Replace("\\", "\\\\")`

* **beta-1.0.0.0.1** - [23-12-22]
* Fixed bug for builtin function `get` - Changed message output from `Writeline` to `Write`
* Changed `value` class' `execute` function check from `left is not baseFunction` to `left is value`

* **beta-1.0.0.0.0** - [22-12-22]
* Initial release!
4 changes: 2 additions & 2 deletions ezrShell.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public static void Main(string[] args)
{
string filepath = string.Empty;
if (args.Length > 0)
filepath = args[0];
filepath = args[0].Replace("\\", "\\\\");

ezr instance = new ezr();
Console.WriteLine($"ezr² Shell version- ({VERSION}) release- [{VERSION_DATE}]");
Expand Down Expand Up @@ -65,7 +65,7 @@ public static void Main(string[] args)
filepath = string.Empty;
}

error? error = instance.run("shell", script, out item? result);
error? error = instance.run("<ezr² biShell>", script, out item? result);
if (error != null) Console.WriteLine(error.asString());
else if (result != null)
{
Expand Down
4 changes: 4 additions & 0 deletions ezrSquared.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,8 @@
<Content Include="Graphics\Icon.ico" />
</ItemGroup>

<ItemGroup>
<Folder Include="Builds\Installer\" />
</ItemGroup>

</Project>

0 comments on commit a96d34b

Please sign in to comment.