Skip to content

Commit

Permalink
Adding a variable type check to the standard library
Browse files Browse the repository at this point in the history
  • Loading branch information
larsaugustin committed Jan 11, 2020
1 parent d0ab11f commit 159b5c6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 4 deletions.
8 changes: 4 additions & 4 deletions StarShip.xcodeproj/project.pbxproj
Expand Up @@ -15,8 +15,8 @@
99448BF523B674AF00A20E8B /* Parser.swift in Sources */ = {isa = PBXBuildFile; fileRef = 99448BF423B674AF00A20E8B /* Parser.swift */; };
99448BFA23B6750400A20E8B /* Lexer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 99448BF923B6750400A20E8B /* Lexer.swift */; };
99448BFC23B6752D00A20E8B /* Token.swift in Sources */ = {isa = PBXBuildFile; fileRef = 99448BFB23B6752D00A20E8B /* Token.swift */; };
99448BFF23B6757B00A20E8B /* Global.swift in Sources */ = {isa = PBXBuildFile; fileRef = 99448BFE23B6757B00A20E8B /* Global.swift */; };
99448C0723B792B400A20E8B /* LICENSE in Sources */ = {isa = PBXBuildFile; fileRef = 99448C0623B792B400A20E8B /* LICENSE */; };
996DC06023CA6DEA000E4BB8 /* Global.swift in Sources */ = {isa = PBXBuildFile; fileRef = 996DC05F23CA6DEA000E4BB8 /* Global.swift */; };
/* End PBXBuildFile section */

/* Begin PBXCopyFilesBuildPhase section */
Expand All @@ -41,14 +41,14 @@
99448BF423B674AF00A20E8B /* Parser.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Parser.swift; sourceTree = "<group>"; };
99448BF923B6750400A20E8B /* Lexer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Lexer.swift; sourceTree = "<group>"; };
99448BFB23B6752D00A20E8B /* Token.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Token.swift; sourceTree = "<group>"; };
99448BFE23B6757B00A20E8B /* Global.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Global.swift; sourceTree = "<group>"; };
99448C0023B675B700A20E8B /* README.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = README.md; sourceTree = "<group>"; };
99448C0123B67CC300A20E8B /* SimpleHTML.strs */ = {isa = PBXFileReference; lastKnownFileType = text; path = SimpleHTML.strs; sourceTree = "<group>"; };
99448C0223B67F3100A20E8B /* Hello.strs */ = {isa = PBXFileReference; lastKnownFileType = text; path = Hello.strs; sourceTree = "<group>"; };
99448C0323B682FE00A20E8B /* StandardLibrary.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = StandardLibrary.md; sourceTree = "<group>"; };
99448C0423B69BEE00A20E8B /* Architecture.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = Architecture.md; sourceTree = "<group>"; };
99448C0523B69C7100A20E8B /* Syntax.md */ = {isa = PBXFileReference; lastKnownFileType = net.daringfireball.markdown; path = Syntax.md; sourceTree = "<group>"; };
99448C0623B792B400A20E8B /* LICENSE */ = {isa = PBXFileReference; lastKnownFileType = text; path = LICENSE; sourceTree = "<group>"; };
996DC05F23CA6DEA000E4BB8 /* Global.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Global.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand Down Expand Up @@ -152,7 +152,7 @@
99448BFD23B6756700A20E8B /* Helpers */ = {
isa = PBXGroup;
children = (
99448BFE23B6757B00A20E8B /* Global.swift */,
996DC05F23CA6DEA000E4BB8 /* Global.swift */,
);
path = Helpers;
sourceTree = "<group>";
Expand Down Expand Up @@ -222,8 +222,8 @@
99448BEC23B6740B00A20E8B /* Execution.swift in Sources */,
99448BF023B6745A00A20E8B /* Instruction.swift in Sources */,
99448BFA23B6750400A20E8B /* Lexer.swift in Sources */,
99448BFF23B6757B00A20E8B /* Global.swift in Sources */,
99448BE123B6729D00A20E8B /* main.swift in Sources */,
996DC06023CA6DEA000E4BB8 /* Global.swift in Sources */,
99448C0723B792B400A20E8B /* LICENSE in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down
10 changes: 10 additions & 0 deletions StarShip/Sources/Execution/Execution.swift
Expand Up @@ -255,6 +255,16 @@ public class Execution {
return
}

// check for type
if variablesToReplace.count == 1 {
if newVariable?.dataType != variablesToReplace[0] {
print("variable that has to be replaced didn't match original type")
return
} else {
variablesToReplace.removeAll()
}
}

// random errors
newVariable != nil ? variableStack.append(newVariable!) : print("Couldn't invoke standard function")
instructions.removeFirst()
Expand Down

0 comments on commit 159b5c6

Please sign in to comment.