Package org.yinwang.yin.value

Examples of org.yinwang.yin.value.Value


    }


    @Override
    public Value typecheck(Scope s) {
        Value v = s.lookup(id);
        if (v != null) {
            return v;
        } else {
            Util.abort(this, "unbound variable: " + id);
            return Value.VOID;
View Full Code Here


    }


    @Override
    public Value interp(Scope s) {
        Value record = value.interp(s);
        if (record instanceof RecordValue) {
            Value a = ((RecordValue) record).properties.lookupLocal(attr.id);
            if (a != null) {
                return a;
            } else {
                Util.abort(attr, "attribute " + attr + " not found in record: " + record);
                return null;
View Full Code Here

    }


    @Override
    public Value typecheck(Scope s) {
        Value record = value.typecheck(s);
        if (record instanceof RecordValue) {
            Value a = ((RecordValue) record).properties.lookupLocal(attr.id);
            if (a != null) {
                return a;
            } else {
                Util.abort(attr, "attribute " + attr + " not found in record: " + record);
                return null;
View Full Code Here

        }
    }


    public void set(Value v, Scope s) {
        Value record = value.interp(s);
        if (record instanceof RecordType) {
            Value a = ((RecordType) record).properties.lookup(attr.id);
            if (a != null) {
                ((RecordType) record).properties.putValue(attr.id, v);
            } else {
                Util.abort(attr,
                        "can only assign to existing attribute in record, " + attr + " not found in: " + record);
View Full Code Here

    }


    @Override
    public Value interp(Scope s) {
        Value vector = value.interp(s);
        Value indexValue = index.interp(s);

        if (!(vector instanceof Vector)) {
            Util.abort(value, "subscripting non-vector: " + vector);
            return null;
        }
View Full Code Here

        return null;
    }


    public void set(Value v, Scope s) {
        Value vector = value.interp(s);
        Value indexValue = index.interp(s);

        if (!(vector instanceof Vector)) {
            Util.abort(value, "subscripting non-vector: " + vector);
        }
View Full Code Here

        this.value = value;
    }


    public Value interp(Scope s) {
        Value valueValue = value.interp(s);
        Binder.checkDup(pattern);
        Binder.define(pattern, valueValue, s);
        return Value.VOID;
    }
View Full Code Here

    }


    @Override
    public Value typecheck(Scope s) {
        Value t = value.typecheck(s);
        Binder.checkDup(pattern);
        Binder.define(pattern, t, s);
        return Value.VOID;
    }
View Full Code Here

        this.orelse = orelse;
    }


    public Value interp(Scope s) {
        Value tv = interp(test, s);
        if (((BoolValue) tv).value) {
            return interp(then, s);
        } else {
            return interp(orelse, s);
        }
View Full Code Here

    }


    @Override
    public Value typecheck(Scope s) {
        Value tv = typecheck(test, s);
        if (!(tv instanceof BoolType)) {
            Util.abort(test, "test is not boolean: " + tv);
            return null;
        }
        Value type1 = typecheck(then, s);
        Value type2 = typecheck(orelse, s);
        return UnionType.union(type1, type2);
    }
View Full Code Here

TOP

Related Classes of org.yinwang.yin.value.Value

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.