public void InterpretType(IdentifierExpression identifierExp, ObjectExpression objectExp) { var name = identifierExp.Identifier; var offset = 0; var fields = objectExp.Pairs .Select(x => x.LeftOperand) .Cast<IdentifierExpression>() .Select(x => { var type = GetType(x); var size = ResolveTypeSize(type); var ofs = offset; offset += size; return new StructMember(x.Identifier, type, ofs, size); }) .ToArray(); var structSize = fields.Sum(x => x.Size); var aphidStruct = new AphidStruct(name, fields, structSize); if (!_types.ContainsKey(name)) { _types.Add(name, aphidStruct); } else { _types[name] = aphidStruct; } }
private AphidObject InterpretObjectExpression(ObjectExpression expression) { var obj = new AphidObject(); foreach (var kvp in expression.Pairs) { var id = (kvp.LeftOperand as IdentifierExpression).Identifier; var value = ValueHelper.Wrap(InterpretExpression(kvp.RightOperand)); obj.Add(id, value); } return obj; }
public ExtendExpression(string type, ObjectExpression obj) { ExtendType = type; Object = obj; }