elsif v.value.is_a? String
putln state, "Value #{var} = MakeString(#{v.value});"
elsif v.value.is_a? Array
- putln state, "Value #{var} = MakeArrayOfLength(#{v.value.length});"
+ putln state, "Value #{var} = MakeArray(#{v.value.length});"
v.value.each_with_index do |e, i|
val = emit(state, e)
- putln state, "Array_SetIndex(#{var}, #{i}, #{val});"
+ putln state, "Array_Set(#{var}, #{i}, #{val});"
end
elsif v.value.is_a? Hash
-# putln state, "Value #{var} = MakeHash(#{v.value});"
-
- putln state, "Value #{var} = MakeHashOfLength(#{v.value.length});"
+ putln state, "Value #{var} = MakeHash(#{v.value.length});"
v.value.each do |k, v|
val = emit(state, v)
- putln state, "Hash_SetIndex(#{var}, MakeString(#{k.value}), #{val});"
-#
-#
-# pp k
-# val = emit(state, e)
-# putln state, "Array_SetIndex(#{var}, #{i}, #{val});"
-#
+ putln state, "Hash_Set(#{var}, MakeString(#{k.value}), #{val});"
end
-
-
else
raise "code emitting constants of this type not implemented"
end
lvar = emit(state, v.left)
rvar = emit(state, v.right)
result = mktemp(state);
- putln state, "Value #{result} = ArrayOrHashGet(#{lvar}, #{rvar});"
+ putln state, "Value #{result} = Object_Get(#{lvar}, #{rvar});"
else
lvar = emit(state, v.left)
rvar = emit(state, v.right)
object = emit(state, v.name.left)
key = emit(state, v.name.right)
value = emit(state, v.value)
- putln state, "ArrayOrHashSet(#{object}, #{key}, #{value});"
+ putln state, "Object_Set(#{object}, #{key}, #{value});"
else
temp = emit(state, v.value)
raise "invalid local definition: #{v.name.name}" if not state.locals.index(v.name.name)
};
}
-//static inline Value MakeRecord(int32_t nslots) {
-// Value* record = calloc(nslots+1,sizeof(Value));
-// record[0] = MakeInt(nslots);
-// return (Value){ .as_uint64 = (NAN_TAG_RECORD | (uintptr_t)record) };
-//}
-//
-//static inline Value MakeArray(int32_t nslots) {
+static inline Value MakeArray(int32_t nslots) {
// Value* record = calloc(2,sizeof(Value));
// record[0] = MakeInt(1);
// record[1] = MakeInt(nslots); //
// record[2] = MakeInt(nslots); //
-// return (Value){ .as_uint64 = (NAN_TAG_RECORD | (uintptr_t)record) };
-//}
+// return (Value){ .as_uint64 = (NAN_TAG_ARRAY | (uintptr_t)record) };
+ return MakeNil();
+}
+
+
+static inline Value MakeHash(int32_t nslots) {
+// Value* record = calloc(2,sizeof(Value));
+// record[0] = MakeInt(1);
+// record[1] = MakeInt(nslots); //
+// record[2] = MakeInt(nslots); //
+// return (Value){ .as_uint64 = (NAN_TAG_ARRAY | (uintptr_t)record) };
+ return MakeNil();
+}
+
/* Value Type Conversions
*************************************************/
}
return result;
}
+
+/* Arrays And Hashes
+ *************************************************/
+static void Array_Set(Value array, int index, Value value)
+{
+}
+
+static Value Array_Get(Value array, int index)
+{
+ return MakeNil();
+}
+
+static void Hash_Set(Value hash, Value key, Value value)
+{
+}
+
+static Value Hash_Get(Value hash, Value key)
+{
+ return MakeNil();
+}
+
+static Value Object_Get(Value object, Value key)
+{
+ return MakeNil();
+}
+
+static Value Object_Set(Value object, Value key, Value value)
+{
+ return MakeNil();
+}