aboutsummaryrefslogtreecommitdiff
path: root/cs/types.cs
diff options
context:
space:
mode:
authorJoel Martin <github@martintribe.org>2014-04-09 21:57:50 -0500
committerJoel Martin <github@martintribe.org>2014-04-09 21:57:50 -0500
commit17ae845ec1dc2c703f99d3cb9f5c01e1b5c52837 (patch)
tree878484c58d55c138e9553a1bde0d031772c8bbdb /cs/types.cs
parentfaee4d12309cec8c90854456fabf4e5e75370518 (diff)
downloadmal-17ae845ec1dc2c703f99d3cb9f5c01e1b5c52837.tar.gz
mal-17ae845ec1dc2c703f99d3cb9f5c01e1b5c52837.zip
C#: add metadata and atoms.
Diffstat (limited to 'cs/types.cs')
-rw-r--r--cs/types.cs47
1 files changed, 26 insertions, 21 deletions
diff --git a/cs/types.cs b/cs/types.cs
index 642da7a..34985ad 100644
--- a/cs/types.cs
+++ b/cs/types.cs
@@ -65,17 +65,24 @@ namespace Mal {
public abstract class MalVal {
+ MalVal meta = Nil;
+ public virtual MalVal copy() {
+ return (MalVal)this.MemberwiseClone();
+ }
+
// Default is just to call regular toString()
public virtual string ToString(bool print_readably) {
return this.ToString();
}
+ public MalVal getMeta() { return meta; }
+ public MalVal setMeta(MalVal m) { meta = m; return this; }
public virtual bool list_Q() { return false; }
}
public class MalConstant : MalVal {
string value;
public MalConstant(string name) { value = name; }
- public MalConstant copy() { return this; }
+ public new MalConstant copy() { return this; }
public override string ToString() {
return value;
@@ -92,7 +99,7 @@ namespace Mal {
public class MalInteger : MalVal {
int value;
public MalInteger(int v) { value = v; }
- public MalInteger copy() { return this; }
+ public new MalInteger copy() { return this; }
public int getValue() { return value; }
public override string ToString() {
@@ -130,7 +137,7 @@ namespace Mal {
public class MalSymbol : MalVal {
string value;
public MalSymbol(string v) { value = v; }
- public MalSymbol copy() { return this; }
+ public new MalSymbol copy() { return this; }
public string getName() { return value; }
public override string ToString() {
@@ -144,7 +151,7 @@ namespace Mal {
public class MalString : MalVal {
string value;
public MalString(string v) { value = v; }
- public MalString copy() { return this; }
+ public new MalString copy() { return this; }
public string getValue() { return value; }
public override string ToString() {
@@ -177,10 +184,6 @@ namespace Mal {
conj_BANG(mvs);
}
- public MalList copy() {
- return (MalList)this.MemberwiseClone();
- }
-
public List<MalVal> getValue() { return value; }
public override bool list_Q() { return true; }
@@ -232,15 +235,6 @@ namespace Mal {
start = "[";
end = "]";
}
- /*
- public MalVector(MalVal[] mvs) : base(mvs.ToArray()) {
- start = "[";
- end = "]";
- }
- */
- public new MalVector copy() {
- return (MalVector)this.MemberwiseClone();
- }
public override bool list_Q() { return false; }
@@ -259,7 +253,7 @@ namespace Mal {
value = new Dictionary<String, MalVal>();
assoc_BANG(lst);
}
- public MalHashMap copy() {
+ public new MalHashMap copy() {
var new_self = (MalHashMap)this.MemberwiseClone();
new_self.value = new Dictionary<string, MalVal>(value);
return new_self;
@@ -289,6 +283,20 @@ namespace Mal {
}
}
+ public class MalAtom : MalVal {
+ MalVal value;
+ public MalAtom(MalVal value) { this.value = value; }
+ //public MalAtom copy() { return new MalAtom(value); }
+ public MalVal getValue() { return value; }
+ public MalVal setValue(MalVal value) { return this.value = value; }
+ public override string ToString() {
+ return "(atom " + printer._pr_str(value, true) + ")";
+ }
+ public override string ToString(Boolean print_readably) {
+ return "(atom " + printer._pr_str(value, print_readably) + ")";
+ }
+ }
+
public class MalFunction : MalVal {
Func<MalList, MalVal> fn = null;
MalVal ast = null;
@@ -305,9 +313,6 @@ namespace Mal {
this.env = env;
this.fparams = fparams;
}
- public MalFunction copy() {
- return (MalFunction)this.MemberwiseClone();
- }
public override string ToString() {
if (ast != null) {